Class ModularClassResolver

  • All Implemented Interfaces:
    ClassResolver

    public final class ModularClassResolver
    extends java.lang.Object
    implements ClassResolver
    A class table which implements an alternate class resolution strategy based on JBoss Modules. Each class name is stored along with its corresponding module identifier, which allows the object graph to be exactly reconstituted on the remote side. This class should be used when the marshalling and unmarshalling side may have differing class files.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static java.lang.ClassLoader MODULE_CLASS_LOADER  
      private org.jboss.modules.ModuleLoader moduleLoader  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private ModularClassResolver​(org.jboss.modules.ModuleLoader moduleLoader)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void annotateClass​(Marshaller marshaller, java.lang.Class<?> clazz)
      Add optional information about a class to a stream.
      void annotateProxyClass​(Marshaller marshaller, java.lang.Class<?> proxyClass)
      Add optional information about a proxy class to a stream.
      java.lang.String getClassName​(java.lang.Class<?> clazz)
      Get the class name to write for a given class.
      static ModularClassResolver getInstance​(org.jboss.modules.ModuleLoader moduleLoader)
      Construct a new instance using the given module loader.
      java.lang.String[] getProxyInterfaces​(java.lang.Class<?> proxyClass)
      Get the interface names to write for a given proxy class.
      java.lang.Class<?> resolveClass​(Unmarshaller unmarshaller, java.lang.String className, long serialVersionUID)
      Load the local class for a class descriptor.
      java.lang.Class<?> resolveProxyClass​(Unmarshaller unmarshaller, java.lang.String[] names)
      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
    • Field Detail

      • moduleLoader

        private final org.jboss.modules.ModuleLoader moduleLoader
      • MODULE_CLASS_LOADER

        private static final java.lang.ClassLoader MODULE_CLASS_LOADER
    • Constructor Detail

      • ModularClassResolver

        private ModularClassResolver​(org.jboss.modules.ModuleLoader moduleLoader)
    • Method Detail

      • getInstance

        public static ModularClassResolver getInstance​(org.jboss.modules.ModuleLoader moduleLoader)
        Construct a new instance using the given module loader.
        Parameters:
        moduleLoader - the module loader
        Returns:
        the new instance
      • 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.
        Specified by:
        annotateClass in interface ClassResolver
        Parameters:
        marshaller - the marshaller to write to
        clazz - 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.
        Specified by:
        annotateProxyClass in interface ClassResolver
        Parameters:
        marshaller - the marshaller to write to
        proxyClass - the class that was written
        Throws:
        java.io.IOException - if an error occurs
        See Also:
        ObjectOutputStream.annotateProxyClass(Class)
      • getClassName

        public java.lang.String getClassName​(java.lang.Class<?> clazz)
                                      throws java.io.IOException
        Get the class name to write for a given class. The class name will be written as part of the class descriptor.
        Specified by:
        getClassName in interface ClassResolver
        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.IOException
        Get the interface names to write for a given proxy class. The interface names will be written as part of the class descriptor.
        Specified by:
        getProxyInterfaces in interface ClassResolver
        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 className,
                                               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 by ClassResolver.annotateClass(Marshaller, Class) should be read by this method.
        Specified by:
        resolveClass in interface ClassResolver
        Parameters:
        unmarshaller - the unmarshaller from which to read annotation data, if any
        className - the class name
        serialVersionUID - the serial version UID
        Returns:
        the corresponding class
        Throws:
        java.io.IOException - if an I/O error occurs
        java.lang.ClassNotFoundException - if the class could not be loaded
        See Also:
        ObjectInputStream.resolveClass(java.io.ObjectStreamClass)
      • resolveProxyClass

        public java.lang.Class<?> resolveProxyClass​(Unmarshaller unmarshaller,
                                                    java.lang.String[] names)
                                             throws java.io.IOException,
                                                    java.lang.ClassNotFoundException
        Load a proxy class that implements the given interfaces.
        Specified by:
        resolveProxyClass in interface ClassResolver
        Parameters:
        unmarshaller - the unmarshaller from which to read annotation data, if any
        names - the class descriptor
        Returns:
        the proxy class
        Throws:
        java.io.IOException - if an I/O error occurs
        java.lang.ClassNotFoundException - if the proxy class could not be loaded
        See Also:
        ObjectInputStream.resolveProxyClass(String[])