Package org.jboss.marshalling
Class AbstractClassResolver
java.lang.Object
org.jboss.marshalling.AbstractClassResolver
- All Implemented Interfaces:
ClassResolver
- Direct Known Subclasses:
ContextClassResolver
,SimpleClassResolver
A base implementation of
ClassResolver
which simply resolves the class
against a classloader which is specified by the subclass implementation.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final boolean
Specifies whether an exception should be thrown on an incorrect serialVersionUID.private static final SerializableClassRegistry
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Construct a new instance.protected
AbstractClassResolver
(boolean enforceSerialVersionUid) Construct a new instance. -
Method Summary
Modifier and TypeMethodDescriptionvoid
annotateClass
(Marshaller marshaller, Class<?> clazz) Add optional information about a class to a stream.void
annotateProxyClass
(Marshaller marshaller, Class<?> proxyClass) Add optional information about a proxy class to a stream.protected abstract ClassLoader
Get the classloader to use to resolve classes for this resolver.private ClassLoader
getClassName
(Class<?> clazz) Get the class name to write for a given class.String[]
getProxyInterfaces
(Class<?> proxyClass) Get the interface names to write for a given proxy class.protected Class
<?> Load a class with the given name.Class
<?> resolveClass
(Unmarshaller unmarshaller, String name, long serialVersionUID) Load the local class for a class descriptor.Class
<?> resolveProxyClass
(Unmarshaller unmarshaller, String[] interfaces) Load a proxy class that implements the given interfaces.
-
Field Details
-
enforceSerialVersionUid
protected final boolean enforceSerialVersionUidSpecifies whether an exception should be thrown on an incorrect serialVersionUID. -
registry
-
primitives
-
-
Constructor Details
-
AbstractClassResolver
protected AbstractClassResolver()Construct a new instance. -
AbstractClassResolver
protected AbstractClassResolver(boolean enforceSerialVersionUid) Construct a new instance.- Parameters:
enforceSerialVersionUid
-true
if an exception should be thrown on an incorrect serialVersionUID
-
-
Method Details
-
getClassLoader
Get the classloader to use to resolve classes for this resolver.- Returns:
- the classloader
-
annotateClass
Add optional information about a class to a stream. The class descriptor will already have been written. The base implementation takes no action.- Specified by:
annotateClass
in interfaceClassResolver
- Parameters:
marshaller
- the marshaller to write toclazz
- the class that was written- Throws:
IOException
- if an error occurs- See Also:
-
annotateProxyClass
Add optional information about a proxy class to a stream. The class descriptor will already have been written. The base implementation takes no action.- Specified by:
annotateProxyClass
in interfaceClassResolver
- Parameters:
marshaller
- the marshaller to write toproxyClass
- the class that was written- Throws:
IOException
- if an error occurs- See Also:
-
getClassLoaderChecked
- Throws:
ClassNotFoundException
-
getClassName
Get the class name to write for a given class. The class name will be written as part of the class descriptor. The base implementation returns the name of the class.- Specified by:
getClassName
in interfaceClassResolver
- Parameters:
clazz
- the class- Returns:
- the class name
- Throws:
IOException
- if an error occurs
-
getProxyInterfaces
Get the interface names to write for a given proxy class. The interface names will be written as part of the class descriptor. The base implementation returns the name of each interface (viagetClassName()
implemented by the given class.- Specified by:
getProxyInterfaces
in interfaceClassResolver
- Parameters:
proxyClass
- the proxy class- Returns:
- the proxy class interface names
- Throws:
IOException
- if an error occurs
-
resolveClass
public Class<?> resolveClass(Unmarshaller unmarshaller, String name, long serialVersionUID) throws IOException, ClassNotFoundException Load the local class for a class descriptor. The class descriptor has already been read, but any data written byClassResolver.annotateClass(Marshaller, Class)
should be read by this method. The base implementation uses the class loader returned fromgetClassLoader()
and loads the class by name.- Specified by:
resolveClass
in interfaceClassResolver
- Parameters:
unmarshaller
- the unmarshaller from which to read annotation data, if anyname
- the class nameserialVersionUID
- the serial version UID- Returns:
- the corresponding class
- Throws:
IOException
- if an I/O error occursClassNotFoundException
- if the class could not be loaded- See Also:
-
loadClass
Load a class with the given name. The base implementation uses the classloader returned fromgetClassLoader()
.- Parameters:
name
- the name of the class- Returns:
- the class
- Throws:
ClassNotFoundException
- if the class is not found, or if there is no classloader
-
resolveProxyClass
public Class<?> resolveProxyClass(Unmarshaller unmarshaller, String[] interfaces) throws IOException, ClassNotFoundException Load a proxy class that implements the given interfaces. The base implementation uses the class loader returned fromgetClassLoader()
and loads each interface by name, returning a proxy class from that class loader.- Specified by:
resolveProxyClass
in interfaceClassResolver
- Parameters:
unmarshaller
- the unmarshaller from which to read annotation data, if anyinterfaces
- the class descriptor- Returns:
- the proxy class
- Throws:
IOException
- if an I/O error occursClassNotFoundException
- if the proxy class could not be loaded- See Also:
-