javax.management.loading
Class MLet

java.lang.Object
  extended byjava.lang.ClassLoader
      extended byjava.security.SecureClassLoader
          extended byjava.net.URLClassLoader
              extended byjavax.management.loading.MLet
All Implemented Interfaces:
java.io.Externalizable, MBeanRegistration (src) , MLetMBean (src) , java.io.Serializable
Direct Known Subclasses:
PrivateMLet (src)

public class MLet
extends java.net.URLClassLoader
implements MLetMBean (src) , MBeanRegistration (src) , java.io.Externalizable

URL classloader capable of parsing an MLet text file adhering to the file format defined in the JMX specification (v1.0).

See Also:
MLetMBean (src) , Serialized Form

Constructor Summary
MLet()
           
MLet(java.net.URL[] urls)
           
MLet(java.net.URL[] urls, boolean delegateToCLR)
           
MLet(java.net.URL[] urls, java.lang.ClassLoader parent)
           
MLet(java.net.URL[] urls, java.lang.ClassLoader parent, boolean delegateToCLR)
           
MLet(java.net.URL[] urls, java.lang.ClassLoader parent, java.net.URLStreamHandlerFactory factory)
           
MLet(java.net.URL[] urls, java.lang.ClassLoader parent, java.net.URLStreamHandlerFactory factory, boolean delegateToCLR)
           
 
Method Summary
 void addURL(java.lang.String url)
          Adds the given URL to the MLet's classpath.
 void addURL(java.net.URL url)
          Adds the given URL to the MLet's classpath.
protected  java.net.URL check(java.lang.String version, java.net.URL codebase, java.lang.String jarfile, javax.management.loading.MLetContent mlet)
          This method is to be overridden when extending this service to support caching and versioning.
protected  java.lang.Class findClass(java.lang.String name)
           
protected  java.lang.String findLibrary(java.lang.String libname)
           
 java.lang.String getLibraryDirectory()
           
 java.util.Set getMBeansFromURL(java.lang.String url)
          Loads an MLET text file from a given url.
 java.util.Set getMBeansFromURL(java.net.URL url)
          Loads an MLET text file from a given url.
 java.net.URL[] getURLs()
          Returns the search path of URLs for loading classes and resources.
protected  java.lang.Class loadClass(java.lang.String name, boolean resolve)
           
 java.lang.Class loadClass(java.lang.String name, ClassLoaderRepository (src)  clr)
          Load a class, using the given ClassLoaderRepository if the class is not found in this MLet's URLs.
 void postDeregister()
          This method is called by the MBeanServer after deregistration takes place.
 void postRegister(java.lang.Boolean registrationDone)
          This method is called by the MBeanServer after registration takes place or when registration fails.
 void preDeregister()
          This method is called by the MBeanServer before deregistration takes place.
 ObjectName (src) preRegister(MBeanServer (src)  server, ObjectName (src)  name)
          This method is called by the MBeanServer before registration takes place.
 void readExternal(java.io.ObjectInput in)
          This implementation does not support externalizing an MLet.
 void setLibraryDirectory(java.lang.String libdir)
           
 void writeExternal(java.io.ObjectOutput out)
          This implementation does not support externalizing an MLet.
 
Methods inherited from class java.net.URLClassLoader
definePackage, findResource, findResources, getPermissions, newInstance, newInstance
 
Methods inherited from class java.security.SecureClassLoader
defineClass
 
Methods inherited from class java.lang.ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, definePackage, findLoadedClass, findSystemClass, getPackage, getPackages, getParent, getResource, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.management.loading.MLetMBean (src)
getResource, getResourceAsStream, getResources
 

Constructor Detail

MLet

public MLet()

MLet

public MLet(java.net.URL[] urls)

MLet

public MLet(java.net.URL[] urls,
            java.lang.ClassLoader parent)

MLet

public MLet(java.net.URL[] urls,
            java.lang.ClassLoader parent,
            java.net.URLStreamHandlerFactory factory)

MLet

public MLet(java.net.URL[] urls,
            boolean delegateToCLR)

MLet

public MLet(java.net.URL[] urls,
            java.lang.ClassLoader parent,
            boolean delegateToCLR)

MLet

public MLet(java.net.URL[] urls,
            java.lang.ClassLoader parent,
            java.net.URLStreamHandlerFactory factory,
            boolean delegateToCLR)
Method Detail

preRegister

public ObjectName (src)  preRegister(MBeanServer (src)  server,
                              ObjectName (src)  name)
                       throws java.lang.Exception
Description copied from interface: MBeanRegistration (src)
This method is called by the MBeanServer before registration takes place. The MBean is passed a reference of the MBeanServer it is about to be registered with. The MBean must return the ObjectName it will be registered with. The MBeanServer can pass a suggested object depending upon how the MBean is registered.

The MBean can stop the registration by throwing an exception.The exception is forwarded to the invoker wrapped in an MBeanRegistrationException.

Specified by:
preRegister in interface MBeanRegistration (src)
Returns:
the actual ObjectName to register this MBean with.
Throws:
java.lang.Exception - for any error, the MBean is not registered.

postRegister

public void postRegister(java.lang.Boolean registrationDone)
Description copied from interface: MBeanRegistration (src)
This method is called by the MBeanServer after registration takes place or when registration fails.

Specified by:
postRegister in interface MBeanRegistration (src)
Parameters:
registrationDone - the MBeanServer passes true when the MBean was registered, false otherwise.

preDeregister

public void preDeregister()
                   throws java.lang.Exception
Description copied from interface: MBeanRegistration (src)
This method is called by the MBeanServer before deregistration takes place.

The MBean can throw an exception, this will stop the deregistration. The exception is forwarded to the invoker wrapped in an MBeanRegistrationException.

Specified by:
preDeregister in interface MBeanRegistration (src)
Throws:
java.lang.Exception

postDeregister

public void postDeregister()
Description copied from interface: MBeanRegistration (src)
This method is called by the MBeanServer after deregistration takes place.

Specified by:
postDeregister in interface MBeanRegistration (src)

getMBeansFromURL

public java.util.Set getMBeansFromURL(java.lang.String url)
                               throws ServiceNotFoundException (src) 
Description copied from interface: MLetMBean (src)
Loads an MLET text file from a given url. The MLET text file is parsed and the declared MBeans will be registered to the MBean server.

Specified by:
getMBeansFromURL in interface MLetMBean (src)
Parameters:
url - url to load the MLET text file from
Returns:
A set of ObjectInstance instances for each registered MBean. If there was an error registering the MBean, a Throwable instance is added to the returned collection.
Throws:
ServiceNotFoundException (src) - if the given URL is malformed, or the given MLET text file cannot be found, or the given text file does not contain an <MLET> tag or one of the specified mandatory attributes (see the JMX specification for a list of mandatory attributes in an MLET text file).

getMBeansFromURL

public java.util.Set getMBeansFromURL(java.net.URL url)
                               throws ServiceNotFoundException (src) 
Description copied from interface: MLetMBean (src)
Loads an MLET text file from a given url. The MLET text file is parsed and the declared MBeans will be registered to the MBean server.

Specified by:
getMBeansFromURL in interface MLetMBean (src)
Parameters:
url - url to load the MLET text file from
Returns:
A set of ObjectInstance instances for each registered MBean. If there was an error registering the MBean, a Throwable instance is added to the returned collection.
Throws:
ServiceNotFoundException (src) - if the given MLET text file cannot be found, or the given text file does not contain an <MLET> tag or one of the specified mandatory attributes (see the JMX specification for a list of mandatory attributes in an MLET text file).

addURL

public void addURL(java.net.URL url)
Description copied from interface: MLetMBean (src)
Adds the given URL to the MLet's classpath.

Specified by:
addURL in interface MLetMBean (src)

addURL

public void addURL(java.lang.String url)
            throws ServiceNotFoundException (src) 
Description copied from interface: MLetMBean (src)
Adds the given URL to the MLet's classpath.

Specified by:
addURL in interface MLetMBean (src)
Parameters:
url - url
Throws:
ServiceNotFoundException (src) - if the given URL is malformed

getURLs

public java.net.URL[] getURLs()
Returns the search path of URLs for loading classes and resources. This includes the original list of URLs specified to the constructor, along with any URLs subsequently appended by the addURL() method.

Specified by:
getURLs in interface MLetMBean (src)
Returns:

getLibraryDirectory

public java.lang.String getLibraryDirectory()
Specified by:
getLibraryDirectory in interface MLetMBean (src)

setLibraryDirectory

public void setLibraryDirectory(java.lang.String libdir)
Specified by:
setLibraryDirectory in interface MLetMBean (src)

readExternal

public void readExternal(java.io.ObjectInput in)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException,
                         java.lang.UnsupportedOperationException
This implementation does not support externalizing an MLet.

Specified by:
readExternal in interface java.io.Externalizable
Throws:
java.lang.UnsupportedOperationException
java.io.IOException
java.lang.ClassNotFoundException

writeExternal

public void writeExternal(java.io.ObjectOutput out)
                   throws java.io.IOException,
                          java.lang.UnsupportedOperationException
This implementation does not support externalizing an MLet.

Specified by:
writeExternal in interface java.io.Externalizable
Throws:
java.lang.UnsupportedOperationException
java.io.IOException

loadClass

public java.lang.Class loadClass(java.lang.String name,
                                 ClassLoaderRepository (src)  clr)
                          throws java.lang.ClassNotFoundException
Load a class, using the given ClassLoaderRepository if the class is not found in this MLet's URLs. The given ClassLoaderRepository can be null, in which case a ClassNotFoundException occurs immediately if the class is not found in this MLet's URLs.

Parameters:
name -
clr -
Returns:
Throws:
java.lang.ClassNotFoundException

check

protected java.net.URL check(java.lang.String version,
                             java.net.URL codebase,
                             java.lang.String jarfile,
                             javax.management.loading.MLetContent mlet)
                      throws java.lang.Exception
This method is to be overridden when extending this service to support caching and versioning. It is called from getMBeansFromURL when the version, codebase, and jarfile have been extracted from the MLet file, and can be used to verify that it is all right to load the given MBean, or to replace the given URL with a different one. The default implementation of this method returns codebase unchanged.

Parameters:
version -
codebase -
jarfile -
mlet -
Returns:
Throws:
java.lang.Exception

loadClass

protected java.lang.Class loadClass(java.lang.String name,
                                    boolean resolve)
                             throws java.lang.ClassNotFoundException
Throws:
java.lang.ClassNotFoundException

findClass

protected java.lang.Class findClass(java.lang.String name)
                             throws java.lang.ClassNotFoundException
Throws:
java.lang.ClassNotFoundException

findLibrary

protected java.lang.String findLibrary(java.lang.String libname)