Marshalling API version 1.0.0.GA

org.jboss.marshalling
Class AbstractClassResolver

java.lang.Object
  extended by org.jboss.marshalling.AbstractClassResolver
All Implemented Interfaces:
ClassResolver
Direct Known Subclasses:
ContextClassResolver, SimpleClassResolver

public abstract class AbstractClassResolver
extends Object
implements ClassResolver

A base implementation of ClassResolver which simply resolves the class against a classloader which is specified by the subclass implementation.


Constructor Summary
protected AbstractClassResolver()
          Construct a new instance.
 
Method Summary
 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.
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractClassResolver

protected AbstractClassResolver()
Construct a new instance.

Method Detail

getClassLoader

protected abstract ClassLoader getClassLoader()
Get the classloader to use to resolve classes for this resolver.

Returns:
the classloader

annotateClass

public void annotateClass(Marshaller marshaller,
                          Class<?> clazz)
                   throws 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:
annotateClass in interface ClassResolver
Parameters:
marshaller - the marshaller to write to
clazz - the class that was written
Throws:
IOException - if an error occurs
See Also:
ObjectOutputStream.annotateClass(Class)

annotateProxyClass

public void annotateProxyClass(Marshaller marshaller,
                               Class<?> proxyClass)
                        throws 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:
annotateProxyClass in interface ClassResolver
Parameters:
marshaller - the marshaller to write to
proxyClass - the chass that was written
Throws:
IOException - if an error occurs
See Also:
ObjectOutputStream.annotateProxyClass(Class)

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 by 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.

Specified by:
resolveClass in interface ClassResolver
Parameters:
unmarshaller - the unmarshaller from which to read annotation data, if any
name - the class name
serialVersionUID - the serial version UID
Returns:
the corresponding class
Throws:
IOException - if an I/O error occurs
ClassNotFoundException - if the class could not be loaded
See Also:
ObjectInputStream.resolveClass(java.io.ObjectStreamClass)

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 from getClassLoader() and loads each interface by name, returning a proxy class from that class loader.

Specified by:
resolveProxyClass in interface ClassResolver
Parameters:
unmarshaller - the unmarshaller from which to read annotation data, if any
interfaces - the class descriptor
Returns:
the proxy class
Throws:
IOException - if an I/O error occurs
ClassNotFoundException - if the proxy class could not be loaded
See Also:
ObjectInputStream.resolveProxyClass(String[])

Marshalling API version 1.0.0.GA

Copyright © 2008 JBoss, a division of Red Hat, Inc.