Package org.jboss.marshalling
Class AbstractClassResolver
- java.lang.Object
-
- org.jboss.marshalling.AbstractClassResolver
-
- All Implemented Interfaces:
ClassResolver
- Direct Known Subclasses:
ContextClassResolver,SimpleClassResolver
public abstract class AbstractClassResolver extends java.lang.Object implements ClassResolver
A base implementation ofClassResolverwhich simply resolves the class against a classloader which is specified by the subclass implementation.
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanenforceSerialVersionUidSpecifies whether an exception should be thrown on an incorrect serialVersionUID.private static java.util.Map<java.lang.String,java.lang.Class<?>>primitivesprivate static SerializableClassRegistryregistry
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractClassResolver()Construct a new instance.protectedAbstractClassResolver(boolean enforceSerialVersionUid)Construct a new instance.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidannotateClass(Marshaller marshaller, java.lang.Class<?> clazz)Add optional information about a class to a stream.voidannotateProxyClass(Marshaller marshaller, java.lang.Class<?> proxyClass)Add optional information about a proxy class to a stream.protected abstract java.lang.ClassLoadergetClassLoader()Get the classloader to use to resolve classes for this resolver.private java.lang.ClassLoadergetClassLoaderChecked()java.lang.StringgetClassName(java.lang.Class<?> clazz)Get the class name to write for a given class.java.lang.String[]getProxyInterfaces(java.lang.Class<?> proxyClass)Get the interface names to write for a given proxy class.protected java.lang.Class<?>loadClass(java.lang.String name)Load a class with the given name.java.lang.Class<?>resolveClass(Unmarshaller unmarshaller, java.lang.String name, long serialVersionUID)Load the local class for a class descriptor.java.lang.Class<?>resolveProxyClass(Unmarshaller unmarshaller, java.lang.String[] interfaces)Load a proxy class that implements the given interfaces.
-
-
-
Field Detail
-
enforceSerialVersionUid
protected final boolean enforceSerialVersionUid
Specifies whether an exception should be thrown on an incorrect serialVersionUID.
-
registry
private static final SerializableClassRegistry registry
-
primitives
private static final java.util.Map<java.lang.String,java.lang.Class<?>> primitives
-
-
Constructor Detail
-
AbstractClassResolver
protected AbstractClassResolver()
Construct a new instance.
-
AbstractClassResolver
protected AbstractClassResolver(boolean enforceSerialVersionUid)
Construct a new instance.- Parameters:
enforceSerialVersionUid-trueif an exception should be thrown on an incorrect serialVersionUID
-
-
Method Detail
-
getClassLoader
protected abstract java.lang.ClassLoader getClassLoader()
Get the classloader to use to resolve classes for this resolver.- Returns:
- the classloader
-
annotateClass
public void annotateClass(Marshaller marshaller, java.lang.Class<?> clazz) throws java.io.IOException
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:
annotateClassin interfaceClassResolver- Parameters:
marshaller- the marshaller to write toclazz- the class that was written- Throws:
java.io.IOException- if an error occurs- See Also:
ObjectOutputStream.annotateClass(Class)
-
annotateProxyClass
public void annotateProxyClass(Marshaller marshaller, java.lang.Class<?> proxyClass) throws java.io.IOException
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:
annotateProxyClassin interfaceClassResolver- Parameters:
marshaller- the marshaller to write toproxyClass- the class that was written- Throws:
java.io.IOException- if an error occurs- See Also:
ObjectOutputStream.annotateProxyClass(Class)
-
getClassLoaderChecked
private java.lang.ClassLoader getClassLoaderChecked() throws java.lang.ClassNotFoundException- Throws:
java.lang.ClassNotFoundException
-
getClassName
public java.lang.String getClassName(java.lang.Class<?> clazz) throws java.io.IOExceptionGet 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:
getClassNamein interfaceClassResolver- Parameters:
clazz- the class- Returns:
- the class name
- Throws:
java.io.IOException- if an error occurs
-
getProxyInterfaces
public java.lang.String[] getProxyInterfaces(java.lang.Class<?> proxyClass) throws java.io.IOExceptionGet 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:
getProxyInterfacesin interfaceClassResolver- Parameters:
proxyClass- the proxy class- Returns:
- the proxy class interface names
- Throws:
java.io.IOException- if an error occurs
-
resolveClass
public java.lang.Class<?> resolveClass(Unmarshaller unmarshaller, java.lang.String name, long serialVersionUID) throws java.io.IOException, java.lang.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:
resolveClassin 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:
java.io.IOException- if an I/O error occursjava.lang.ClassNotFoundException- if the class could not be loaded- See Also:
ObjectInputStream.resolveClass(java.io.ObjectStreamClass)
-
loadClass
protected java.lang.Class<?> loadClass(java.lang.String name) throws java.lang.ClassNotFoundExceptionLoad 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:
java.lang.ClassNotFoundException- if the class is not found, or if there is no classloader
-
resolveProxyClass
public java.lang.Class<?> resolveProxyClass(Unmarshaller unmarshaller, java.lang.String[] interfaces) throws java.io.IOException, java.lang.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:
resolveProxyClassin interfaceClassResolver- Parameters:
unmarshaller- the unmarshaller from which to read annotation data, if anyinterfaces- the class descriptor- Returns:
- the proxy class
- Throws:
java.io.IOException- if an I/O error occursjava.lang.ClassNotFoundException- if the proxy class could not be loaded- See Also:
ObjectInputStream.resolveProxyClass(String[])
-
-