Class CGLIBEnhancedConverter
- java.lang.Object
-
- com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter
-
- com.thoughtworks.xstream.converters.reflection.SerializableConverter
-
- com.thoughtworks.xstream.converters.reflection.CGLIBEnhancedConverter
-
- All Implemented Interfaces:
Converter
,ConverterMatcher
,Caching
public class CGLIBEnhancedConverter extends SerializableConverter
Converts a proxy created by the CGLIBEnhancer
. Such a proxy is recreated while deserializing the proxy. The converter does only work, if
- the DefaultNamingPolicy is used for the proxy's name
- the proxy uses a factory or only one Callback is registered
- a possible super class has at least a protected default constructor
- Since:
- 1.2
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
CGLIBEnhancedConverter.CGLIBFilteringReflectionProvider
private static class
CGLIBEnhancedConverter.ReverseEngineeredCallbackFilter
private static class
CGLIBEnhancedConverter.ReverseEngineeringInvocationHandler
-
Nested classes/interfaces inherited from class com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter
AbstractReflectionConverter.DuplicateFieldException, AbstractReflectionConverter.UnknownFieldException
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String
CALLBACK_MARKER
private static java.lang.String
DEFAULT_NAMING_MARKER
private java.util.Map
fieldCache
-
Fields inherited from class com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter
mapper, reflectionProvider, serializationMembers, serializationMethodInvoker
-
-
Constructor Summary
Constructors Constructor Description CGLIBEnhancedConverter(Mapper mapper, ReflectionProvider reflectionProvider)
Deprecated.CGLIBEnhancedConverter(Mapper mapper, ReflectionProvider reflectionProvider, ClassLoaderReference classLoaderReference)
Construct a CGLIBEnhancedConverter.CGLIBEnhancedConverter(Mapper mapper, ReflectionProvider reflectionProvider, java.lang.ClassLoader classLoader)
Deprecated.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
canConvert(java.lang.Class type)
Determines whether the converter can marshall a particular type.private java.lang.Object
create(net.sf.cglib.proxy.Enhancer enhancer, java.util.List callbacks, boolean useFactory)
private java.util.Map
createCallbackIndexMap(net.sf.cglib.proxy.Factory source)
private java.lang.Object[]
createNullArguments(java.lang.Class[] parameterTypes)
private net.sf.cglib.proxy.Callback
createReverseEngineeredCallbackOfProperType(net.sf.cglib.proxy.Callback callback, int index, java.util.Map callbackIndexMap)
private net.sf.cglib.proxy.Callback[]
getCallbacks(java.lang.Object source)
protected java.util.List
hierarchyFor(java.lang.Class type)
void
marshal(java.lang.Object source, HierarchicalStreamWriter writer, MarshallingContext context)
Convert an object to textual data.private void
readCallback(HierarchicalStreamReader reader, UnmarshallingContext context, java.util.List callbacksToEnhance, java.util.List callbacks)
protected java.lang.Object
readResolve()
java.lang.Object
unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context)
Convert textual data back into an object.-
Methods inherited from class com.thoughtworks.xstream.converters.reflection.SerializableConverter
doMarshal, doMarshalConditionally, doUnmarshal, doUnmarshalConditionally, marshalUnserializableParent
-
Methods inherited from class com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter
canAccess, flushCache, instantiateNewInstance, marshallField, shouldUnmarshalField, shouldUnmarshalTransientFields, unmarshallField
-
-
-
-
Constructor Detail
-
CGLIBEnhancedConverter
public CGLIBEnhancedConverter(Mapper mapper, ReflectionProvider reflectionProvider, ClassLoaderReference classLoaderReference)
Construct a CGLIBEnhancedConverter.- Parameters:
mapper
- the mapper chain instancereflectionProvider
- the reflection providerclassLoaderReference
- the reference to theClassLoader
of the XStream instance- Since:
- 1.4.5
-
CGLIBEnhancedConverter
public CGLIBEnhancedConverter(Mapper mapper, ReflectionProvider reflectionProvider, java.lang.ClassLoader classLoader)
Deprecated.
-
CGLIBEnhancedConverter
public CGLIBEnhancedConverter(Mapper mapper, ReflectionProvider reflectionProvider)
Deprecated.
-
-
Method Detail
-
canConvert
public boolean canConvert(java.lang.Class type)
Description copied from interface:ConverterMatcher
Determines whether the converter can marshall a particular type.- Specified by:
canConvert
in interfaceConverterMatcher
- Overrides:
canConvert
in classSerializableConverter
- Parameters:
type
- the Class representing the object type to be converted
-
marshal
public void marshal(java.lang.Object source, HierarchicalStreamWriter writer, MarshallingContext context)
Description copied from interface:Converter
Convert an object to textual data.- Specified by:
marshal
in interfaceConverter
- Overrides:
marshal
in classAbstractReflectionConverter
- Parameters:
source
- The object to be marshalled.writer
- A stream to write to.context
- A context that allows nested objects to be processed by XStream.
-
getCallbacks
private net.sf.cglib.proxy.Callback[] getCallbacks(java.lang.Object source)
-
createCallbackIndexMap
private java.util.Map createCallbackIndexMap(net.sf.cglib.proxy.Factory source)
-
createNullArguments
private java.lang.Object[] createNullArguments(java.lang.Class[] parameterTypes)
-
createReverseEngineeredCallbackOfProperType
private net.sf.cglib.proxy.Callback createReverseEngineeredCallbackOfProperType(net.sf.cglib.proxy.Callback callback, int index, java.util.Map callbackIndexMap)
-
unmarshal
public java.lang.Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context)
Description copied from interface:Converter
Convert textual data back into an object.- Specified by:
unmarshal
in interfaceConverter
- Overrides:
unmarshal
in classAbstractReflectionConverter
- Parameters:
reader
- The stream to read the text from.- Returns:
- The resulting object.
-
readCallback
private void readCallback(HierarchicalStreamReader reader, UnmarshallingContext context, java.util.List callbacksToEnhance, java.util.List callbacks)
-
create
private java.lang.Object create(net.sf.cglib.proxy.Enhancer enhancer, java.util.List callbacks, boolean useFactory)
-
hierarchyFor
protected java.util.List hierarchyFor(java.lang.Class type)
- Overrides:
hierarchyFor
in classSerializableConverter
-
readResolve
protected java.lang.Object readResolve()
- Overrides:
readResolve
in classAbstractReflectionConverter
-
-