public abstract class AbstractClassResolver extends Object implements ClassResolver
ClassResolver
which simply resolves the class
against a classloader which is specified by the subclass implementation.Modifier and Type | Field and Description |
---|---|
protected boolean |
enforceSerialVersionUid
Specifies whether an exception should be thrown on an incorrect serialVersionUID.
|
Modifier | Constructor and Description |
---|---|
protected |
AbstractClassResolver()
Construct a new instance.
|
protected |
AbstractClassResolver(boolean enforceSerialVersionUid)
Construct a new instance.
|
Modifier and Type | Method and Description |
---|---|
void |
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 |
getClassLoader()
Get the classloader to use to resolve classes for this resolver.
|
String |
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<?> |
loadClass(String name)
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.
|
protected final boolean enforceSerialVersionUid
protected AbstractClassResolver()
protected AbstractClassResolver(boolean enforceSerialVersionUid)
enforceSerialVersionUid
- true
if an exception should be thrown on an incorrect serialVersionUIDprotected abstract ClassLoader getClassLoader()
public void annotateClass(Marshaller marshaller, Class<?> clazz) throws IOException
annotateClass
in interface ClassResolver
marshaller
- the marshaller to write toclazz
- the class that was writtenIOException
- if an error occursObjectOutputStream.annotateClass(Class)
public void annotateProxyClass(Marshaller marshaller, Class<?> proxyClass) throws IOException
annotateProxyClass
in interface ClassResolver
marshaller
- the marshaller to write toproxyClass
- the class that was writtenIOException
- if an error occursObjectOutputStream.annotateProxyClass(Class)
public String getClassName(Class<?> clazz) throws IOException
getClassName
in interface ClassResolver
clazz
- the classIOException
- if an error occurspublic String[] getProxyInterfaces(Class<?> proxyClass) throws IOException
getClassName()
implemented by the given class.getProxyInterfaces
in interface ClassResolver
proxyClass
- the proxy classIOException
- if an error occurspublic Class<?> resolveClass(Unmarshaller unmarshaller, String name, long serialVersionUID) throws IOException, ClassNotFoundException
ClassResolver.annotateClass(Marshaller, Class)
should be read by this method. The base implementation uses the class loader returned from getClassLoader()
and
loads the class by name.resolveClass
in interface ClassResolver
unmarshaller
- the unmarshaller from which to read annotation data, if anyname
- the class nameserialVersionUID
- the serial version UIDIOException
- if an I/O error occursClassNotFoundException
- if the class could not be loadedObjectInputStream.resolveClass(java.io.ObjectStreamClass)
protected Class<?> loadClass(String name) throws ClassNotFoundException
getClassLoader()
.name
- the name of the classClassNotFoundException
- if the class is not found, or if there is no classloaderpublic Class<?> resolveProxyClass(Unmarshaller unmarshaller, String[] interfaces) throws IOException, ClassNotFoundException
getClassLoader()
and loads
each interface by name, returning a proxy class from that class loader.resolveProxyClass
in interface ClassResolver
unmarshaller
- the unmarshaller from which to read annotation data, if anyinterfaces
- the class descriptorIOException
- if an I/O error occursClassNotFoundException
- if the proxy class could not be loadedObjectInputStream.resolveProxyClass(String[])
Copyright © 2018 JBoss by Red Hat. All rights reserved.