com.sun.jaw.impl.agent.services.mlet
Class MLetClassLoader

java.lang.Object
  |
  +--java.lang.ClassLoader
        |
        +--java.security.SecureClassLoader
              |
              +--java.net.URLClassLoader
                    |
                    +--com.sun.jaw.impl.agent.services.mlet.MLetClassLoader

public class MLetClassLoader
extends java.net.URLClassLoader
implements java.io.Externalizable

This class represents the class loader that the m-let service uses to load classes and resources.

This class loader can load classes and resources from:

Note - Do not instantiate this class explicitly. The m-let service instantiates this class each time a load URL method is invoked.

When it instantiates this class, the m-let service registers the instance with the repository. This enables a client application to instantiate an m-bean loaded through this class loader by specifying its object name.

The class loader created is registered with an object name of the form:

defaultDomain:JavaClass.codebase=baseURL

where:

See Also:
Serialized Form

Constructor Summary
MLetClassLoader()
          Instantiates the m-let class loader.
MLetClassLoader(java.net.URL codebase)
          Instantiates the m-let class loader with a specified codebase.
 
Method Summary
 void addJarFileURL(java.lang.String url)
          Appends the specified JAR file URL to the list of URLs to search for classes and resources.
 void deleteCmf()
          Deletes the m-let class loader.
protected  java.lang.Class findClass(java.lang.String name)
          This is the main method for class loaders that is being redefined.
protected  java.lang.String findLibrary(java.lang.String libname)
          Returns the absolute path name of a native library.
static java.lang.String getClassVersion()
          Gets the version of this class.
 java.net.URL getCodeBase()
          Gets the code base of this instance of MLetClassLoader.
 ObjectName getLoaderName()
          Gets the object name of this instance of MLetClassLoader.
 void initCmf(Framework cmf, ObjectName name, boolean db, ModificationList list)
          Initializes the m-let class loader and sets its codebase property.
 java.lang.Object loadSerializedObject(java.net.URL codebase, java.lang.String filename)
          Loads the serialized object specified by the OBJECT attribute of the MLET tag.
 void readExternal(java.io.ObjectInput in)
          This method reads the objects contents during Object Serialization.
 void writeExternal(java.io.ObjectOutput out)
          This method saves the objects contents during Object Serialization.
 
Methods inherited from class java.net.URLClassLoader
addURL, definePackage, findResource, findResources, getPermissions, getURLs, newInstance, newInstance
 
Methods inherited from class java.security.SecureClassLoader
defineClass
 
Methods inherited from class java.lang.ClassLoader
defineClass, defineClass, defineClass, definePackage, findLoadedClass, findSystemClass, getPackage, getPackages, getParent, getResource, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, loadClass, resolveClass, setSigners
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MLetClassLoader

public MLetClassLoader()
Instantiates the m-let class loader.

MLetClassLoader

public MLetClassLoader(java.net.URL codebase)
Instantiates the m-let class loader with a specified codebase.
Parameters:
codebase - The codebase.
Method Detail

initCmf

public void initCmf(Framework cmf,
                    ObjectName name,
                    boolean db,
                    ModificationList list)
             throws java.lang.IllegalAccessException,
                    InstanceAlreadyExistException
Initializes the m-let class loader and sets its codebase property. The method registers the m-let class loader with the core management framework.

This method is not intent to be called directly by the user.

Parameters:
cmf - The core management framework to register the service with.
name - The object name containing configuration information.
db - Indicates if persistent storage is required.
list - The modification list to use for setting up parameters.
Throws:
java.lang.IllegalAccessException - The method cannot access the class definition of the m-let class loader.
InstanceAlreadyExistException - The m-let class loader is already registered.

deleteCmf

public void deleteCmf()
Deletes the m-let class loader.

This method is not intent to be called directly by the user.


addJarFileURL

public void addJarFileURL(java.lang.String url)
Appends the specified JAR file URL to the list of URLs to search for classes and resources.
Parameters:
url - The URL to be added to the search path of URLs.

findClass

protected java.lang.Class findClass(java.lang.String name)
                             throws java.lang.ClassNotFoundException
This is the main method for class loaders that is being redefined.
Parameters:
name - The name of the class.
Returns:
The resulting Class object.
Throws:
java.lang.ClassNotFoundException - The specified class could not be found.
Overrides:
findClass in class java.net.URLClassLoader

loadSerializedObject

public java.lang.Object loadSerializedObject(java.net.URL codebase,
                                             java.lang.String filename)
                                      throws java.io.IOException,
                                             java.lang.ClassNotFoundException
Loads the serialized object specified by the OBJECT attribute of the MLET tag.
Parameters:
codebase - The codebase.
filename - The name of the file containing the serialized object.
Returns:
The serialized object.
Throws:
java.lang.ClassNotFoundException - The specified serialized object could not be found.
java.io.IOException - An I/O error occurred while loading serialized object.

findLibrary

protected java.lang.String findLibrary(java.lang.String libname)
Returns the absolute path name of a native library. The VM invokes this method to locate the native libraries that belong to classes loaded with this class loader. Libraries are searched in the JAR files using first just the native library name and if not found the native library name together with the architecture-specific path name (OSName/OSArch/OSVersion/lib/nativelibname), i.e.

the library stat on Solaris SPARC 5.7 will be searched in the JAR file as:

  1. libstat.so
  2. SunOS/sparc/5.7/lib/libstat.so
the library stat on Windows NT 4.0 will be searched in the JAR file as:
  1. stat.dll
  2. WindowsNT/x86/4.0/lib/stat.dll

If this method returns null, i.e. the libraries were not found in any of the JAR files loaded with this class loader, the VM searches the library along the path specified as the java.library.path property.

Parameters:
libname - The library name.
Returns:
The absolute path of the native library.
Overrides:
findLibrary in class java.lang.ClassLoader

writeExternal

public void writeExternal(java.io.ObjectOutput out)
                   throws java.io.IOException
This method saves the objects contents during Object Serialization.
Specified by:
writeExternal in interface java.io.Externalizable
Parameters:
out - The serialization output stream.
Throws:
java.io.IOException - Signals that an I/O exception of some sort has occurred.

readExternal

public void readExternal(java.io.ObjectInput in)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
This method reads the objects contents during Object Serialization.
Specified by:
readExternal in interface java.io.Externalizable
Parameters:
in - The serialization input stream.
Throws:
java.io.IOException - Signals that an I/O exception of some sort has occurred.
java.lang.ClassNotFoundException - The class for an object being restored cannot be found.

getClassVersion

public static java.lang.String getClassVersion()
Gets the version of this class.
Returns:
The version of this class.

getCodeBase

public java.net.URL getCodeBase()
Gets the code base of this instance of MLetClassLoader.
Returns:
The code base of this instance of MLetClassLoader.

getLoaderName

public ObjectName getLoaderName()
Gets the object name of this instance of MLetClassLoader.
Returns:
The object name of this instance of MLetClassLoader.