站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > JBoss 4.0.1 sp1 jmx API Documentation 英文版文档

UnifiedLoaderRepository3 (JBoss/JMX API) - JBoss 4.0.1 sp1 jmx API Documentation 英文版文档


org.jboss.mx.loading
Class UnifiedLoaderRepository3

java.lang.Object
  extended byorg.jboss.mx.loading.LoaderRepository
      extended byorg.jboss.mx.loading.UnifiedLoaderRepository3
All Implemented Interfaces:
ClassLoaderRepository, MBeanRegistration, NotificationBroadcaster, NotificationEmitter, ServerConstants, UnifiedLoaderRepository3MBean, UnifiedLoaderRepositoryMBean
Direct Known Subclasses:
HeirarchicalLoaderRepository3

public class UnifiedLoaderRepository3
extends LoaderRepository
implements MBeanRegistration, NotificationEmitter, UnifiedLoaderRepository3MBean

A repository of class loaders that form a flat namespace of classes and resources. This version uses UnifiedClassLoader3 instances. Class and resource loading is synchronized by the acquiring the monitor to the associated repository structure monitor. See the variable javadoc comments for what monitor is used to access a given structure.

Version:
$Revision: 1.30.4.1 $ just a hint... xdoclet not really used
Author:
Scott Stark., Adrian Brock.

Field Summary
 
Fields inherited from class org.jboss.mx.loading.LoaderRepository
instance, loaders, translator
 
Fields inherited from interface org.jboss.mx.server.ServerConstants
CLASS_REMOVED, CLASSLOADER, CLASSLOADER_ADDED, CLASSLOADER_REMOVED, DEFAULT_DOMAIN, DEFAULT_LOADER_NAME, DEFAULT_LOADER_REPOSITORY_CLASS, DEFAULT_MBEAN_REGISTRY_CLASS, DEFAULT_MBEAN_SERVER_BUILDER_CLASS, DEFAULT_REQUIRED_MODELMBEAN_CLASS, DEFAULT_SCOPED_REPOSITORY_CLASS, DEFAULT_SCOPED_REPOSITORY_PARSER_CLASS, IMPLEMENTATION_NAME, IMPLEMENTATION_VENDOR, IMPLEMENTATION_VERSION, JMI_DOMAIN, LOADER_REPOSITORY_CLASS_PROPERTY, MBEAN_REGISTRY, MBEAN_REGISTRY_CLASS_PROPERTY, MBEAN_SERVER_BUILDER_CLASS_PROPERTY, MBEAN_SERVER_CONFIGURATION, MBEAN_SERVER_DELEGATE, OPTIMIZE_REFLECTED_DISPATCHER, REQUIRED_MODELMBEAN_CLASS_PROPERTY, SPECIFICATION_NAME, SPECIFICATION_VENDOR, SPECIFICATION_VERSION, UNIFIED_LOADER_REPOSITORY_CLASS
 
Constructor Summary
UnifiedLoaderRepository3()
           
 
Method Summary
 void addClassLoader(ClassLoader loader)
          Add a class loader to the repository.
 boolean addClassLoaderURL(ClassLoader cl, URL url)
          Update the set of URLs known to be associated with a previously added class loader.
 void addNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback)
          addNotificationListener delegates to the broadcaster object we hold.
 void cacheLoadedClass(String name, Class cls, ClassLoader cl)
          Add a Class to the repository cache.
 String displayClassInfo(String className)
          A utility method that iterates over all repository class loaders and display the class information for every UCL that contains the given className
 void flush()
          Flush the ULR classes cache
 Class getCachedClass(String classname)
           
 int getCacheSize()
          Get the number of classes loaded into the ULR cache.
 int getClassLoadersSize()
          Get the number of UnifiedClassLoader3s (UCLs) in the ULR
 LoaderRepository getInstance()
           
 MBeanNotificationInfo[] getNotificationInfo()
          Returns the notification metadata associated with the MBean.
 Set getPackageClassLoaders(String className)
          Called by LoadMgr to obtain all class loaders for the given className
 URL getResource(String name, ClassLoader cl)
          Loads a resource following the Unified ClassLoader architecture
protected  URL getResourceFromGlobalCache(String name)
          Check for a resource in the global cache Synchronizes access to globalResources using the loaderToResourcesMap monitor
protected  URL getResourceFromRepository(String name, ClassLoader cl)
           
 void getResources(String name, ClassLoader cl, List urls)
          Find all resource URLs for the given name.
 URL[] getURLs()
          This is a utility method a listing of the URL for all UnifiedClassLoaders associated with the repository.
 RepositoryClassLoader getWrappingClassLoader(ClassLoader cl)
          Get any wrapping classloader for the passed classloader
 Class loadClass(String className)
          First tries to load from any UCL in the ULR, and if the class is not found, next tries the current thread context class loader.
 Class loadClass(String name, boolean resolve, ClassLoader cl)
          Unlike other implementations of LoaderRepository, this method does nothing but ask the UnifiedClassLoader3 to load the class as UCL3s do not use this method.
 Class loadClassBefore(ClassLoader stop, String className)
          Loads a class from the repository, using the classloaders that were registered before the given classloader.
 Class loadClassFromCache(String name)
          Lookup a Class from the repository cache.
 Class loadClassWithout(ClassLoader loader, String className)
          Loads a class from the repository, excluding the given classloader.
 RepositoryClassLoader newClassLoader(URL url, boolean addToRepository)
          Create RepositoryClassLoader and optionally add it to the repository
 RepositoryClassLoader newClassLoader(URL url, URL origURL, boolean addToRepository)
          Create RepositoryClassLoader and optionally add it to the repository
 void postDeregister()
          This method is called by the MBeanServer after deregistration takes place.
 void postRegister(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 preRegister(MBeanServer server, ObjectName name)
          This method is called by the MBeanServer before registration takes place.
 LoaderRepository registerClassLoader(RepositoryClassLoader ucl)
          This method provides an mbean-accessible way to add a UnifiedClassloader, and sends a notification when it is added.
 void removeClassLoader(ClassLoader loader)
          Remove the class loader from the repository.
 void removeNotificationListener(NotificationListener listener)
          removeNotificationListener delegates to our broadcaster object
 void removeNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback)
          Removes a listener from the Emitter.
 
Methods inherited from class org.jboss.mx.loading.LoaderRepository
compare, getLoaders, getNativeClassForName, getTranslator, reverseCompare, setTranslator
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jboss.mx.loading.UnifiedLoaderRepositoryMBean
getTranslator, setTranslator
 

Constructor Detail

UnifiedLoaderRepository3

public UnifiedLoaderRepository3()
Method Detail

newClassLoader

public RepositoryClassLoader newClassLoader(URL url,
                                            boolean addToRepository)
                                     throws Exception
Description copied from class: LoaderRepository
Create RepositoryClassLoader and optionally add it to the repository

Specified by:
newClassLoader in interface UnifiedLoaderRepositoryMBean
Specified by:
newClassLoader in class LoaderRepository
Parameters:
url - the URL to use for class loading
addToRepository - a flag indicating if the CL should be added to the repository
Returns:
the UCL instance
Throws:
Exception

newClassLoader

public RepositoryClassLoader newClassLoader(URL url,
                                            URL origURL,
                                            boolean addToRepository)
                                     throws Exception
Description copied from class: LoaderRepository
Create RepositoryClassLoader and optionally add it to the repository

Specified by:
newClassLoader in interface UnifiedLoaderRepositoryMBean
Specified by:
newClassLoader in class LoaderRepository
Parameters:
url - the URL to use for class loading
origURL - an orignal URL to use as the URL for the CL CodeSource. This is useful when the url is a local copy that is difficult to use for security policy writing.
addToRepository - a flag indicating if the CL should be added to the repository
Returns:
the CL instance
Throws:
Exception

getCacheSize

public int getCacheSize()
Description copied from interface: UnifiedLoaderRepository3MBean
Get the number of classes loaded into the ULR cache.

Specified by:
getCacheSize in interface UnifiedLoaderRepository3MBean
Returns:
the classes cache size.

getClassLoadersSize

public int getClassLoadersSize()
Description copied from interface: UnifiedLoaderRepository3MBean
Get the number of UnifiedClassLoader3s (UCLs) in the ULR

Specified by:
getClassLoadersSize in interface UnifiedLoaderRepository3MBean
Returns:
the number of UCLs in the ULR

flush

public void flush()
Description copied from interface: UnifiedLoaderRepository3MBean
Flush the ULR classes cache

Specified by:
flush in interface UnifiedLoaderRepository3MBean

getCachedClass

public Class getCachedClass(String classname)
Overrides:
getCachedClass in class LoaderRepository

loadClass

public Class loadClass(String name,
                       boolean resolve,
                       ClassLoader cl)
                throws ClassNotFoundException
Unlike other implementations of LoaderRepository, this method does nothing but ask the UnifiedClassLoader3 to load the class as UCL3s do not use this method.

Specified by:
loadClass in class LoaderRepository
Parameters:
name -
resolve -
cl -
Returns:
Throws:
ClassNotFoundException

getPackageClassLoaders

public Set getPackageClassLoaders(String className)
Called by LoadMgr to obtain all class loaders for the given className

Specified by:
getPackageClassLoaders in interface UnifiedLoaderRepository3MBean
Returns:
Set, may be null

loadClassFromCache

public Class loadClassFromCache(String name)
Lookup a Class from the repository cache.

Parameters:
name - the fully qualified class name
Returns:
the cached Class if found, null otherwise

cacheLoadedClass

public void cacheLoadedClass(String name,
                             Class cls,
                             ClassLoader cl)
Add a Class to the repository cache.

Parameters:
name - the fully qualified class name
cls - the Class instance
cl - the repository UCL

getResource

public URL getResource(String name,
                       ClassLoader cl)
Loads a resource following the Unified ClassLoader architecture

Specified by:
getResource in class LoaderRepository
Parameters:
name - the resource name
cl - the requesting class loader
Returns:
The resource URL if found, null otherwise

getResources

public void getResources(String name,
                         ClassLoader cl,
                         List urls)
Find all resource URLs for the given name. This is entails an exhuastive search of the repository and is an expensive operation.

Specified by:
getResources in class LoaderRepository
Parameters:
name - the resource name
cl - the requesting class loader
urls - a list into which the located resource URLs will be placed

getResourceFromGlobalCache

protected URL getResourceFromGlobalCache(String name)
Check for a resource in the global cache Synchronizes access to globalResources using the loaderToResourcesMap monitor

Parameters:
name -
Returns:

getResourceFromRepository

protected URL getResourceFromRepository(String name,
                                        ClassLoader cl)

getURLs

public URL[] getURLs()
This is a utility method a listing of the URL for all UnifiedClassLoaders associated with the repository. It is never called in response to class or resource loading.

Specified by:
getURLs in interface UnifiedLoaderRepositoryMBean
Overrides:
getURLs in class LoaderRepository

displayClassInfo

public String displayClassInfo(String className)
A utility method that iterates over all repository class loaders and display the class information for every UCL that contains the given className

Specified by:
displayClassInfo in interface UnifiedLoaderRepository3MBean

loadClass

public Class loadClass(String className)
                throws ClassNotFoundException
First tries to load from any UCL in the ULR, and if the class is not found, next tries the current thread context class loader.

Specified by:
loadClass in interface ClassLoaderRepository
Specified by:
loadClass in class LoaderRepository
Parameters:
className - - the class to load
Returns:
the found class
Throws:
ClassNotFoundException - when there is no such class

loadClassWithout

public Class loadClassWithout(ClassLoader loader,
                              String className)
                       throws ClassNotFoundException
Loads a class from the repository, excluding the given classloader.

Specified by:
loadClassWithout in interface ClassLoaderRepository
Specified by:
loadClassWithout in class LoaderRepository
Parameters:
loader - the classloader to exclude
className - the class to load
Returns:
the found class
Throws:
ClassNotFoundException - when there is no such class

loadClassBefore

public Class loadClassBefore(ClassLoader stop,
                             String className)
                      throws ClassNotFoundException
Loads a class from the repository, using the classloaders that were registered before the given classloader.

Specified by:
loadClassBefore in interface ClassLoaderRepository
Specified by:
loadClassBefore in class LoaderRepository
Parameters:
stop - consult all the classloaders registered before this one in an attempt to load a class
className - name of the class to load
Returns:
loaded class instance
Throws:
ClassNotFoundException - if none of the consulted classloaders were able to load the requested class

getWrappingClassLoader

public RepositoryClassLoader getWrappingClassLoader(ClassLoader cl)
Get any wrapping classloader for the passed classloader

Specified by:
getWrappingClassLoader in interface UnifiedLoaderRepositoryMBean
Parameters:
cl - the wrapped classloader
Returns:
the wrapping classloader or null if not wrapped

addClassLoader

public void addClassLoader(ClassLoader loader)
Add a class loader to the repository.

Specified by:
addClassLoader in class LoaderRepository

addClassLoaderURL

public boolean addClassLoaderURL(ClassLoader cl,
                                 URL url)
Description copied from class: LoaderRepository
Update the set of URLs known to be associated with a previously added class loader.

Specified by:
addClassLoaderURL in class LoaderRepository
Parameters:
cl -
url -

removeClassLoader

public void removeClassLoader(ClassLoader loader)
Remove the class loader from the repository. This synchronizes on the this.classLoaders

Specified by:
removeClassLoader in interface UnifiedLoaderRepositoryMBean
Specified by:
removeClassLoader in class LoaderRepository
Parameters:
loader -

registerClassLoader

public LoaderRepository registerClassLoader(RepositoryClassLoader ucl)
This method provides an mbean-accessible way to add a UnifiedClassloader, and sends a notification when it is added.

Specified by:
registerClassLoader in interface UnifiedLoaderRepositoryMBean
Parameters:
ucl - an UnifiedClassLoader value
Returns:
a LoaderRepository value

getInstance

public LoaderRepository getInstance()
Specified by:
getInstance in interface UnifiedLoaderRepositoryMBean

addNotificationListener

public void addNotificationListener(NotificationListener listener,
                                    NotificationFilter filter,
                                    Object handback)
                             throws IllegalArgumentException
addNotificationListener delegates to the broadcaster object we hold.

Specified by:
addNotificationListener in interface NotificationBroadcaster
Parameters:
listener - a NotificationListener value
filter - a NotificationFilter value
handback - an Object value
Throws:
IllegalArgumentException - if an error occurs

getNotificationInfo

public MBeanNotificationInfo[] getNotificationInfo()
Description copied from interface: NotificationBroadcaster
Returns the notification metadata associated with the MBean.

Specified by:
getNotificationInfo in interface NotificationBroadcaster
Returns:
See Also:
MBeanNotificationInfo

removeNotificationListener

public void removeNotificationListener(NotificationListener listener)
                                throws ListenerNotFoundException
removeNotificationListener delegates to our broadcaster object

Specified by:
removeNotificationListener in interface NotificationBroadcaster
Parameters:
listener - a NotificationListener value
Throws:
ListenerNotFoundException - if an error occurs

removeNotificationListener

public void removeNotificationListener(NotificationListener listener,
                                       NotificationFilter filter,
                                       Object handback)
                                throws ListenerNotFoundException
Description copied from interface: NotificationEmitter
Removes a listener from the Emitter.

Only the listener, filter, handback triplet is removed

Specified by:
removeNotificationListener in interface NotificationEmitter
Parameters:
listener - the listener object to remove
filter - the filter registered with the listener
handback - the handback object associated with the registered listener
Throws:
ListenerNotFoundException - if the listener was not found

preRegister

public ObjectName preRegister(MBeanServer server,
                              ObjectName name)
                       throws Exception
Description copied from interface: MBeanRegistration
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
Returns:
the actual ObjectName to register this MBean with.
Throws:
Exception - for any error, the MBean is not registered.

postRegister

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

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

preDeregister

public void preDeregister()
                   throws Exception
Description copied from interface: MBeanRegistration
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
Throws:
Exception

postDeregister

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

Specified by:
postDeregister in interface MBeanRegistration


Copyright © 2002 JBoss Group, LLC. All Rights Reserved.