Top Description Inners Fields Constructors Methods
com.thoughtworks.xstream.converters.reflection

public Class CGLIBEnhancedConverter

extends SerializableConverter
Class Inheritance
Imports
com.thoughtworks.xstream.converters.ConversionException, .MarshallingContext, .UnmarshallingContext, com.thoughtworks.xstream.core.ClassLoaderReference, com.thoughtworks.xstream.io.ExtendedHierarchicalStreamWriterHelper, .HierarchicalStreamReader, .HierarchicalStreamWriter, com.thoughtworks.xstream.mapper.CGLIBMapper, .Mapper, net.sf.cglib.proxy.Callback, .CallbackFilter, .Enhancer, .Factory, .MethodInterceptor, .NoOp, java.lang.reflect.Field, .InvocationHandler, .InvocationTargetException, .Method, .Modifier, .Proxy, java.util.ArrayList, .Arrays, .HashMap, .HashSet, .Iterator, .List, .Map, .Set

Converts a proxy created by the CGLIB Enhancer. Such a proxy is recreated while deserializing the proxy. The converter does only work, if
Note, that the this converter relies on the CGLIBMapper.
Author
Jörg Schaible
Since
1.2

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private static class
private static class

Field Summary

Modifier and TypeField and Description
private static String
private static String
private transient Map<K, V>

Constructor Summary

AccessConstructor and Description
public
CGLIBEnhancedConverter(Mapper
the mapper chain instance
mapper
,
ReflectionProvider
the reflection provider
reflectionProvider
,
ClassLoaderReference
the reference to the ClassLoader of the XStream instance
classLoaderReference
)

Construct a CGLIBEnhancedConverter.

public
public

Method Summary

Modifier and TypeMethod and Description
public boolean
canConvert(Class<T>
the Class representing the object type to be converted
type
)

Overrides com.thoughtworks.xstream.converters.reflection.SerializableConverter.canConvert.

Implements com.thoughtworks.xstream.converters.ConverterMatcher.canConvert.

Determines whether the converter can marshall a particular type.
private Object
create(final Enhancer enhancer, List<E> callbacks, boolean useFactory)

private Map<K, V>
private Object[]
createNullArguments(Class<T>[] parameterTypes)

private Callback
createReverseEngineeredCallbackOfProperType(Callback callback, int index, Map<K, V> callbackIndexMap)

private Callback[]
protected List<E>
public void
marshal(Object
The object to be marshalled.
source
,
HierarchicalStreamWriter
A stream to write to.
writer
,
MarshallingContext
A context that allows nested objects to be processed by XStream.
context
)

Overrides com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.marshal.

Implements com.thoughtworks.xstream.converters.Converter.marshal.

Convert an object to textual data.
private void
readCallback(HierarchicalStreamReader reader, UnmarshallingContext context, List<E> callbacksToEnhance, List<E> callbacks)

protected Object
public Object
Inherited from com.thoughtworks.xstream.converters.reflection.SerializableConverter:
doMarshaldoMarshalConditionallydoUnmarshaldoUnmarshalConditionallymarshalUnserializableParent

Field Detail

CALLBACK_MARKERback to summary
private static String CALLBACK_MARKER
DEFAULT_NAMING_MARKERback to summary
private static String DEFAULT_NAMING_MARKER
fieldCacheback to summary
private transient Map<K, V> fieldCache

Constructor Detail

CGLIBEnhancedConverterback to summary
public CGLIBEnhancedConverter(Mapper mapper, ReflectionProvider reflectionProvider, ClassLoaderReference classLoaderReference)

Construct a CGLIBEnhancedConverter.

Parameters
mapper:Mapper

the mapper chain instance

reflectionProvider:ReflectionProvider

the reflection provider

classLoaderReference:ClassLoaderReference

the reference to the ClassLoader of the XStream instance

Since
1.4.5
CGLIBEnhancedConverterback to summary
public CGLIBEnhancedConverter(Mapper mapper, ReflectionProvider reflectionProvider, ClassLoader classLoader)
CGLIBEnhancedConverterback to summary
public CGLIBEnhancedConverter(Mapper mapper, ReflectionProvider reflectionProvider)

Method Detail

canConvertback to summary
public boolean canConvert(Class<T> type)

Overrides com.thoughtworks.xstream.converters.reflection.SerializableConverter.canConvert.

Implements com.thoughtworks.xstream.converters.ConverterMatcher.canConvert.

Doc from com.thoughtworks.xstream.converters.ConverterMatcher.canConvert.

Determines whether the converter can marshall a particular type.

Parameters
type:Class<T>

the Class representing the object type to be converted

createback to summary
private Object create(final Enhancer enhancer, List<E> callbacks, boolean useFactory)
createCallbackIndexMapback to summary
private Map<K, V> createCallbackIndexMap(Factory source)
createNullArgumentsback to summary
private Object[] createNullArguments(Class<T>[] parameterTypes)
createReverseEngineeredCallbackOfProperTypeback to summary
private Callback createReverseEngineeredCallbackOfProperType(Callback callback, int index, Map<K, V> callbackIndexMap)
getCallbacksback to summary
private Callback[] getCallbacks(Object source)
hierarchyForback to summary
protected List<E> hierarchyFor(Class<T> type)

Overrides com.thoughtworks.xstream.converters.reflection.SerializableConverter.hierarchyFor.

marshalback to summary
public void marshal(Object source, HierarchicalStreamWriter writer, MarshallingContext context)

Overrides com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.marshal.

Implements com.thoughtworks.xstream.converters.Converter.marshal.

Doc from com.thoughtworks.xstream.converters.Converter.marshal.

Convert an object to textual data.

Parameters
source:Object

The object to be marshalled.

writer:HierarchicalStreamWriter

A stream to write to.

context:MarshallingContext

A context that allows nested objects to be processed by XStream.

readCallbackback to summary
private void readCallback(HierarchicalStreamReader reader, UnmarshallingContext context, List<E> callbacksToEnhance, List<E> callbacks)
readResolveback to summary
protected Object readResolve()

Overrides com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.readResolve.

unmarshalback to summary
public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context)

Overrides com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal.

Implements com.thoughtworks.xstream.converters.Converter.unmarshal.

Doc from com.thoughtworks.xstream.converters.Converter.unmarshal.

Convert textual data back into an object.

Parameters
reader:HierarchicalStreamReader

The stream to read the text from.

Returns:Object

The resulting object.

com.thoughtworks.xstream.converters.reflection back to summary

private Class CGLIBEnhancedConverter.CGLIBFilteringReflectionProvider

extends ReflectionProviderWrapper
Class Inheritance

Field Summary

Inherited from com.thoughtworks.xstream.converters.reflection.ReflectionProviderWrapper:
wrapped

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
Inherited from com.thoughtworks.xstream.converters.reflection.ReflectionProviderWrapper:
fieldDefinedInClassgetFieldgetFieldOrNullgetFieldTypenewInstancewriteField

Constructor Detail

CGLIBFilteringReflectionProviderback to summary
public CGLIBFilteringReflectionProvider(final ReflectionProvider reflectionProvider)

Method Detail

visitSerializableFieldsback to summary
public void visitSerializableFields(final Object object, final ReflectionProvider.Visitor visitor)

Overrides com.thoughtworks.xstream.converters.reflection.ReflectionProviderWrapper.visitSerializableFields.

Implements com.thoughtworks.xstream.converters.reflection.ReflectionProvider.visitSerializableFields.

com.thoughtworks.xstream.converters.reflection back to summary

private Class CGLIBEnhancedConverter.ReverseEngineeredCallbackFilter

extends Object
implements CallbackFilter
Class Inheritance
  • java.lang.Object
  • com.thoughtworks.xstream.converters.reflection.CGLIBEnhancedConverter.ReverseEngineeredCallbackFilter
All Implemented Interfaces
net.sf.cglib.proxy.CallbackFilter

Field Summary

Modifier and TypeField and Description
private final Map<K, V>

Constructor Summary

AccessConstructor and Description
public
ReverseEngineeredCallbackFilter(Map<K, V> callbackIndexMap)

Method Summary

Modifier and TypeMethod and Description
public int
accept(Method
the intercepted method
method
)

Implements net.sf.cglib.proxy.CallbackFilter.accept.

Map a method to a callback.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

callbackIndexMapback to summary
private final Map<K, V> callbackIndexMap

Constructor Detail

ReverseEngineeredCallbackFilterback to summary
public ReverseEngineeredCallbackFilter(Map<K, V> callbackIndexMap)

Method Detail

acceptback to summary
public int accept(Method method)

Implements net.sf.cglib.proxy.CallbackFilter.accept.

Doc from net.sf.cglib.proxy.CallbackFilter.accept.

Map a method to a callback.

Parameters
method:Method

the intercepted method

Returns:int

the index into the array of callbacks (as specified by Enhancer#setCallbacks) to use for the method,

com.thoughtworks.xstream.converters.reflection back to summary

private final Class CGLIBEnhancedConverter.ReverseEngineeringInvocationHandler

extends Object
implements InvocationHandler
Class Inheritance
  • java.lang.Object
  • com.thoughtworks.xstream.converters.reflection.CGLIBEnhancedConverter.ReverseEngineeringInvocationHandler
All Implemented Interfaces
java.lang.reflect.InvocationHandler

Field Summary

Modifier and TypeField and Description
private final Integer
private final Map<K, V>

Constructor Summary

AccessConstructor and Description
public
ReverseEngineeringInvocationHandler(int index, Map<K, V> indexMap)

Method Summary

Modifier and TypeMethod and Description
public Object
invoke(Object
the proxy instance that the method was invoked on
proxy
,
Method
the Method instance corresponding to the interface method invoked on the proxy instance. The declaring class of the Method object will be the interface that the method was declared in, which may be a superinterface of the proxy interface that the proxy class inherits the method through.
method
,
Object[]
an array of objects containing the values of the arguments passed in the method invocation on the proxy instance, or null if interface method takes no arguments. Arguments of primitive types are wrapped in instances of the appropriate primitive wrapper class, such as java.lang.Integer or java.lang.Boolean.
args
)

Implements java.lang.reflect.InvocationHandler.invoke.

Processes a method invocation on a proxy instance and returns the result.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

indexback to summary
private final Integer index
indexMapback to summary
private final Map<K, V> indexMap

Constructor Detail

ReverseEngineeringInvocationHandlerback to summary
public ReverseEngineeringInvocationHandler(int index, Map<K, V> indexMap)

Method Detail

invokeback to summary
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable

Implements java.lang.reflect.InvocationHandler.invoke.

Doc from java.lang.reflect.InvocationHandler.invoke.

Processes a method invocation on a proxy instance and returns the result. This method will be invoked on an invocation handler when a method is invoked on a proxy instance that it is associated with.

Parameters
proxy:Object

the proxy instance that the method was invoked on

method:Method

the Method instance corresponding to the interface method invoked on the proxy instance. The declaring class of the Method object will be the interface that the method was declared in, which may be a superinterface of the proxy interface that the proxy class inherits the method through.

args:Object[]

an array of objects containing the values of the arguments passed in the method invocation on the proxy instance, or null if interface method takes no arguments. Arguments of primitive types are wrapped in instances of the appropriate primitive wrapper class, such as java.lang.Integer or java.lang.Boolean.

Returns:Object

the value to return from the method invocation on the proxy instance. If the declared return type of the interface method is a primitive type, then the value returned by this method must be an instance of the corresponding primitive wrapper class; otherwise, it must be a type assignable to the declared return type. If the value returned by this method is null and the interface method's return type is primitive, then a NullPointerException will be thrown by the method invocation on the proxy instance. If the value returned by this method is otherwise not compatible with the interface method's declared return type as described above, a ClassCastException will be thrown by the method invocation on the proxy instance.

Exceptions
Throwable:
the exception to throw from the method invocation on the proxy instance. The exception's type must be assignable either to any of the exception types declared in the throws clause of the interface method or to the unchecked exception types java.lang.RuntimeException or java.lang.Error. If a checked exception is thrown by this method that is not assignable to any of the exception types declared in the throws clause of the interface method, then an UndeclaredThrowableException containing the exception that was thrown by this method will be thrown by the method invocation on the proxy instance.