public RobustCollectionConverter(Mapper mapper, ReflectionProvider reflectionProvider) { super(mapper); sc = new SerializableConverter(mapper,reflectionProvider); }
protected void doMarshalConditionally(final Object source, final HierarchicalStreamWriter writer, final MarshallingContext context) { if(isSerializable(source.getClass())) { doMarshal(source, writer, context); } else { super.doMarshal(source, writer, context); } }
protected Object doUnmarshalConditionally(final Object result, final HierarchicalStreamReader reader, final UnmarshallingContext context) { return isSerializable(result.getClass()) ? doUnmarshal(result, reader, context) : super.doUnmarshal(result, reader, context); }
private boolean isSerializable(Class type) { if (type != null && Serializable.class.isAssignableFrom(type) && !type.isInterface() && (serializationMembers.supportsReadObject(type, true) || serializationMembers.supportsWriteObject(type, true))) { for (Iterator iter = hierarchyFor(type).iterator(); iter.hasNext();) { if (!Serializable.class.isAssignableFrom((Class)iter.next())) { return canAccess(type); } } return true; } return false; }
Iterator classHieararchy = hierarchyFor(source.getClass()).iterator(); while (classHieararchy.hasNext()) { currentType[0] = (Class) classHieararchy.next(); } else { if (mustHandleUnserializableParent) { marshalUnserializableParent(writer, context, source); mustHandleUnserializableParent = false;
protected List hierarchyFor(Class type) { List typeHierarchy = super.hierarchyFor(type); // drop the CGLIB proxy typeHierarchy.remove(typeHierarchy.size() - 1); return typeHierarchy; }
} else if (reader.getNodeName().equals("instance")) { result = create(enhancer, callbacks, useFactory); super.doUnmarshalConditionally(result, reader, context);
super.doMarshalConditionally(source, writer, context); writer.endNode();
public boolean canConvert(Class type) { return JVM.canCreateDerivedObjectOutputStream() && isSerializable(type); }
@Override public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) { // CopyOnWriteArrayList used to serialize as custom serialization, // so read it in a compatible fashion. String s = reader.getAttribute("serialization"); if(s!=null && s.equals("custom")) { return sc.unmarshal(reader,context); } else { return super.unmarshal(reader, context); } }
Iterator classHieararchy = hierarchyFor(source.getClass()).iterator(); while (classHieararchy.hasNext()) { currentType[0] = (Class) classHieararchy.next(); } else { if (mustHandleUnserializableParent) { marshalUnserializableParent(writer, context, source); mustHandleUnserializableParent = false;
private boolean isSerializable(Class type) { if (Serializable.class.isAssignableFrom(type) && ( serializationMethodInvoker.supportsReadObject(type, true) || serializationMethodInvoker.supportsWriteObject(type, true) )) { for(Iterator iter = hierarchyFor(type).iterator(); iter.hasNext(); ) { if (!Serializable.class.isAssignableFrom((Class)iter.next())) { return canAccess(type); } } return true; } return false; }
protected List hierarchyFor(Class type) { List typeHierarchy = super.hierarchyFor(type); // drop the CGLIB proxy typeHierarchy.remove(typeHierarchy.size() - 1); return typeHierarchy; }
} else if (reader.getNodeName().equals("instance")) { result = create(enhancer, callbacks, useFactory); super.doUnmarshalConditionally(result, reader, context);
super.doMarshalConditionally(source, writer, context); writer.endNode();
public boolean canConvert(Class type) { return isSerializable(type); }
@Override public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) { // CopyOnWriteArrayList used to serialize as custom serialization, // so read it in a compatible fashion. String s = reader.getAttribute("serialization"); if(s!=null && s.equals("custom")) { return sc.unmarshal(reader,context); } else { return super.unmarshal(reader, context); } }
public ImmutableSetConverter(Mapper mapper, ReflectionProvider reflectionProvider) { super(mapper); sc = new SerializableConverter(mapper,reflectionProvider); }
protected void doMarshalConditionally(final Object source, final HierarchicalStreamWriter writer, final MarshallingContext context) { if(isSerializable(source.getClass())) { doMarshal(source, writer, context); } else { super.doMarshal(source, writer, context); } }
protected Object doUnmarshalConditionally(final Object result, final HierarchicalStreamReader reader, final UnmarshallingContext context) { return isSerializable(result.getClass()) ? doUnmarshal(result, reader, context) : super.doUnmarshal(result, reader, context); }