|
Préférences
Moteurs de recherche
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
JavaTM 2 Platform Std. Ed. v1.5.0
javax.management.loading
|
Constructor Summary | |
---|---|
MLet()
Constructs a new MLet using the default delegation parent ClassLoader. |
|
MLet(URL[] urls)
Constructs a new MLet for the specified URLs using the default delegation parent ClassLoader. |
|
MLet(URL[] urls,
boolean delegateToCLR)
Constructs a new MLet for the specified URLs using the default delegation parent ClassLoader. |
|
MLet(URL[] urls,
ClassLoader parent)
Constructs a new MLet for the given URLs. |
|
MLet(URL[] urls,
ClassLoader parent,
boolean delegateToCLR)
Constructs a new MLet for the given URLs. |
|
MLet(URL[] urls,
ClassLoader parent,
URLStreamHandlerFactory factory)
Constructs a new MLet for the specified URLs, parent class loader, and URLStreamHandlerFactory. |
|
MLet(URL[] urls,
ClassLoader parent,
URLStreamHandlerFactory factory,
boolean delegateToCLR)
Constructs a new MLet for the specified URLs, parent class loader, and URLStreamHandlerFactory. |
Method Summary | |
---|---|
void |
addURL(String url)
Appends the specified URL to the list of URLs to search for classes and resources. |
void |
addURL(URL url)
Appends the specified URL to the list of URLs to search for classes and resources. |
protected URL |
check(String version,
URL codebase,
String jarfile,
javax.management.loading.MLetContent mlet)
This method is to be overridden when extending this service to support caching and versioning. |
protected Class |
findClass(String name)
This is the main method for class loaders that is being redefined. |
protected String |
findLibrary(String libname)
Returns the absolute path name of a native library. |
String |
getLibraryDirectory()
Gets the current directory used by the library loader for storing native libraries before they are loaded into memory. |
Set |
getMBeansFromURL(String url)
Loads a text file containing MLET tags that define the MBeans to be added to the agent. |
Set |
getMBeansFromURL(URL url)
Loads a text file containing MLET tags that define the MBeans to be added to the agent. |
URL[] |
getURLs()
Returns the search path of URLs for loading classes and resources. |
Class |
loadClass(String name,
ClassLoaderRepository clr)
Load a class, using the given ClassLoaderRepository if
the class is not found in this MLet's URLs. |
void |
postDeregister()
Allows the m-let to perform any operations needed after having been unregistered in the MBean server. |
void |
postRegister(Boolean registrationDone)
Allows the m-let to perform any operations needed after having been registered in the MBean server or after the registration has failed. |
void |
preDeregister()
Allows the m-let to perform any operations it needs before being unregistered by the MBean server. |
ObjectName |
preRegister(MBeanServer server,
ObjectName name)
Allows the m-let to perform any operations it needs before being registered in the MBean server. |
void |
readExternal(ObjectInput in)
Restore this MLet's contents from the given ObjectInput . |
void |
setLibraryDirectory(String libdir)
Sets the directory used by the library loader for storing native libraries before they are loaded into memory. |
void |
writeExternal(ObjectOutput out)
Save this MLet's contents to the given ObjectOutput . |
Methods inherited from class java.net.URLClassLoader |
---|
definePackage, findResource, findResources, getPermissions, newInstance, newInstance |
Methods inherited from class java.security.SecureClassLoader |
---|
defineClass, defineClass |
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 |
---|
getResource, getResourceAsStream, getResources |
Constructor Detail |
---|
public MLet()
public MLet(URL[] urls)
urls
- The URLs from which to load classes and resources.public MLet(URL[] urls, ClassLoader parent)
urls
- The URLs from which to load classes and resources.parent
- The parent class loader for delegation.public MLet(URL[] urls, ClassLoader parent, URLStreamHandlerFactory factory)
urls
- The URLs from which to load classes and resources.parent
- The parent class loader for delegation.factory
- The URLStreamHandlerFactory to use when creating URLs.public MLet(URL[] urls, boolean delegateToCLR)
urls
- The URLs from which to load classes and resources.delegateToCLR
- True if, when a class is not found in
either the parent ClassLoader or the URLs, the MLet should delegate
to its containing MBeanServer's ClassLoaderRepository
.public MLet(URL[] urls, ClassLoader parent, boolean delegateToCLR)
urls
- The URLs from which to load classes and resources.parent
- The parent class loader for delegation.delegateToCLR
- True if, when a class is not found in
either the parent ClassLoader or the URLs, the MLet should delegate
to its containing MBeanServer's ClassLoaderRepository
.public MLet(URL[] urls, ClassLoader parent, URLStreamHandlerFactory factory, boolean delegateToCLR)
urls
- The URLs from which to load classes and resources.parent
- The parent class loader for delegation.factory
- The URLStreamHandlerFactory to use when creating URLs.delegateToCLR
- True if, when a class is not found in
either the parent ClassLoader or the URLs, the MLet should delegate
to its containing MBeanServer's ClassLoaderRepository
.Method Detail |
---|
public void addURL(URL url)
addURL
in interface MLetMBean
addURL
in class URLClassLoader
url
- the URL to be added to the search path of URLspublic void addURL(String url) throws ServiceNotFoundException
url
- the URL to add.
ServiceNotFoundException
- The specified URL is malformed.public URL[] getURLs()
getURLs
in interface MLetMBean
getURLs
in class URLClassLoader
public Set getMBeansFromURL(URL url) throws ServiceNotFoundException
getMBeansFromURL
in interface MLetMBean
url
- The URL of the text file to be loaded as URL object.
ServiceNotFoundException
- One of the following errors has occurred: The m-let text file does
not contain an MLET tag, the m-let text file is not found, a mandatory
attribute of the MLET tag is not specified, the value of url is
null.
IllegalStateException
- MLet MBean is not registered with an MBeanServer.public Set getMBeansFromURL(String url) throws ServiceNotFoundException
getMBeansFromURL
in interface MLetMBean
url
- The URL of the text file to be loaded as String object.
ServiceNotFoundException
- One of the following errors has occurred: The m-let text file does
not contain an MLET tag, the m-let text file is not found, a mandatory
attribute of the MLET tag is not specified, the url is malformed.
IllegalStateException
- MLet MBean is not registered with an MBeanServer.public String getLibraryDirectory()
getLibraryDirectory
in interface MLetMBean
setLibraryDirectory(java.lang.String)
public void setLibraryDirectory(String libdir)
setLibraryDirectory
in interface MLetMBean
libdir
- The directory used by the library loader.getLibraryDirectory()
public ObjectName preRegister(MBeanServer server, ObjectName name) throws Exception
preRegister
in interface MBeanRegistration
server
- The MBean server in which the m-let will be registered.name
- The object name of the m-let.
Exception
- This exception should be caught by the MBean server and re-thrown
as an MBeanRegistrationException.public void postRegister(Boolean registrationDone)
postRegister
in interface MBeanRegistration
registrationDone
- Indicates whether or not the m-let has been successfully registered in
the MBean server. The value false means that either the registration phase
has failed.public void preDeregister() throws Exception
preDeregister
in interface MBeanRegistration
java.langException
- This exception should be caught by the MBean server and re-thrown
as an MBeanRegistrationException.
Exception
- This exception will be caught by
the MBean server and re-thrown as an MBeanRegistrationException
.public void postDeregister()
postDeregister
in interface MBeanRegistration
public void writeExternal(ObjectOutput out) throws IOException, UnsupportedOperationException
Save this MLet's contents to the given ObjectOutput
.
Not all implementations support this method. Those that do not
throw UnsupportedOperationException
. A subclass may
override this method to support it or to change the format of
the written data.
The format of the written data is not specified, but if
an implementation supports writeExternal(java.io.ObjectOutput)
it must
also support readExternal(java.io.ObjectInput)
in such a way that what is
written by the former can be read by the latter.
writeExternal
in interface Externalizable
out
- The object output stream to write to.
IOException
- If a problem occurred while writing.
UnsupportedOperationException
- If this
implementation does not support this operation.public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException, UnsupportedOperationException
Restore this MLet's contents from the given ObjectInput
.
Not all implementations support this method. Those that do not
throw UnsupportedOperationException
. A subclass may
override this method to support it or to change the format of
the read data.
The format of the read data is not specified, but if an
implementation supports readExternal(java.io.ObjectInput)
it must also
support writeExternal(java.io.ObjectOutput)
in such a way that what is
written by the latter can be read by the former.
readExternal
in interface Externalizable
in
- The object input stream to read from.
IOException
- if a problem occurred while reading.
ClassNotFoundException
- if the class for the object
being restored cannot be found.
UnsupportedOperationException
- if this
implementation does not support this operation.public Class loadClass(String name, ClassLoaderRepository clr) throws 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.
name
- The name of the class we want to load.clr
- The ClassLoaderRepository that will be used to search
for the given class, if it is not found in this
ClassLoader. May be null.
ClassNotFoundException
- The specified class could not be
found in this ClassLoader nor in the given
ClassLoaderRepository.protected Class findClass(String name) throws ClassNotFoundException
findClass
in class URLClassLoader
name
- The name of the class.
ClassNotFoundException
- The specified class could not be
found.protected String findLibrary(String libname)
OSName/OSArch/OSVersion/lib/nativelibname
), i.e.
the library stat on Solaris SPARC 5.7 will be searched in the JAR file as:
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.
findLibrary
in class ClassLoader
libname
- The library name.
System.loadLibrary(String)
,
System.mapLibraryName(String)
protected URL check(String version, URL codebase, String jarfile, javax.management.loading.MLetContent mlet) throws 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.
version
- The version number of the .jar
file stored locally.codebase
- The base URL of the remote .jar
file.jarfile
- The name of the .jar
file to be loaded.mlet
- The MLetContent
instance that
represents the MLET
tag.
Exception
- if the MBean is not to be loaded for some
reason. The exception will be added to the set returned by
getMBeansFromURL
.