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

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


org.jboss.mx.loading
Class RepositoryClassLoader

java.lang.Object
  extended byjava.lang.ClassLoader
      extended byjava.security.SecureClassLoader
          extended byjava.net.URLClassLoader
              extended byorg.jboss.mx.loading.RepositoryClassLoader
Direct Known Subclasses:
UnifiedClassLoader

public abstract class RepositoryClassLoader
extends URLClassLoader

A RepositoryClassLoader.

Version:
$Revision: 1.3.4.2 $
Author:
Adrian Brock

Field Summary
protected  EDU.oswego.cs.dl.util.concurrent.ReentrantLock loadLock
          Lock
protected  ClassLoader parent
          The parent classloader
protected  LoaderRepository repository
          Reference to the repository.
 
Constructor Summary
protected RepositoryClassLoader(URL[] urls, ClassLoader parent)
          Create a new LoaderRepositoryClassLoader
 
Method Summary
protected  void acquire()
          Acquire the class loading lock.
 void addToClassBlackList(String name)
          Black list a class
 void addToResourceBlackList(String name)
          Black list a resource
 void addURL(URL url)
          Append the given url to the URLs used for class and resource loading
protected  boolean attempt(long waitMS)
          Attempt to acquire the class loading lock.
 void clearBlackLists()
          Clear all blacklists
 void clearClassBlackList()
          Clear any class black list.
 void clearResourceBlackList()
          Clear any resource blacklist.
protected  void definePackage(String className)
          Define the package for the class if not already done
 boolean equals(Object other)
          This is here to document that this must delegate to the super implementation to perform identity based equality.
protected  Class findClass(String name)
          Called by loadClassLocally to find the requested class within this class loaders class path.
protected  Class findClassLocally(String name)
          Find the class
 Enumeration findResources(String name)
          Find all resource URLs for the given name.
 Enumeration findResourcesLocally(String name)
          Provides the same functionality as URLClassLoader.findResources(java.lang.String).
 int getAddedOrder()
          Get the order this classloader was added to the repository
 URL[] getAllURLs()
          Return all library URLs associated with this RepositoryClassLoader
 URL[] getClasspath()
          This method simply invokes the super.getURLs() method to access the list of URLs that make up the RepositoryClassLoader classpath.
 LoaderRepository getLoaderRepository()
          Get the loader repository for this classloader
abstract  ObjectName getObjectName()
          Get the ObjectName
 Package getPackage(String name)
           
 Package[] getPackages()
           
protected  ProtectionDomain getProtectionDomain(URL codesourceUrl)
          Determine the protection domain.
 URL getResource(String name)
          Attempts to load the resource from its URL and if not found forwards to the request to LoaderRepository.
 URL getResourceLocally(String name)
          Provides the same functionality as ClassLoader.getResource(java.lang.String).
 URL getURL()
          Get the URL associated with the UCL.
 URL[] getURLs()
          Return an empty URL array to force the RMI marshalling subsystem to use the java.server.codebase property as the annotated codebase.
 int hashCode()
          This is here to document that this must delegate to the super implementation to perform identity based hashing.
 boolean isClassBlackListed(String name)
          Is the class black listed?
 boolean isResourceBlackListed(String name)
          Is the resource black listed?
protected  byte[] loadByteCode(String classname)
          Obtain the bytecode for the indicated class from this class loaders classpath.
protected  byte[] loadByteCode(URL classURL)
          Obtain the bytecode for the indicated class from this class loaders classpath.
 Class loadClass(String name, boolean resolve)
          The only caller of this method should be the VM initiated loadClassInternal() method.
 Class loadClassBefore(String name)
          The only caller of this method should be the VM initiated loadClassInternal() method.
 Class loadClassImpl(String name, boolean resolve, int stopAt)
           
 Class loadClassLocally(String name, boolean resolve)
          Called to attempt to load a class from the set of URLs associated with this classloader.
protected  void release()
          Release the class loading lock previous acquired through the acquire method.
 void removeFromClassBlackList(String name)
          Remove class from black list
 void removeFromResourceBlackList(String name)
          Remove resource from black list
 void setAddedOrder(int addedOrder)
          Set the order this classloader was added to the repository
 void setRepository(LoaderRepository repository)
          Set the loader repository
 String toString()
          Returns a string representation.
 void unregister()
           
 
Methods inherited from class java.net.URLClassLoader
definePackage, findResource, getPermissions, newInstance, newInstance
 
Methods inherited from class java.security.SecureClassLoader
defineClass
 
Methods inherited from class java.lang.ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, definePackage, findLibrary, findLoadedClass, findSystemClass, getParent, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

repository

protected LoaderRepository repository
Reference to the repository.


parent

protected ClassLoader parent
The parent classloader


loadLock

protected EDU.oswego.cs.dl.util.concurrent.ReentrantLock loadLock
Lock

Constructor Detail

RepositoryClassLoader

protected RepositoryClassLoader(URL[] urls,
                                ClassLoader parent)
Create a new LoaderRepositoryClassLoader

Parameters:
urls - the urls
parent - the parent classloader
Method Detail

getObjectName

public abstract ObjectName getObjectName()
                                  throws MalformedObjectNameException
Get the ObjectName

Returns:
the object name
Throws:
MalformedObjectNameException

getLoaderRepository

public LoaderRepository getLoaderRepository()
Get the loader repository for this classloader


setRepository

public void setRepository(LoaderRepository repository)
Set the loader repository

Parameters:
repository - the repository

getAddedOrder

public int getAddedOrder()
Get the order this classloader was added to the repository

Returns:
the order

setAddedOrder

public void setAddedOrder(int addedOrder)
Set the order this classloader was added to the repository

Parameters:
addedOrder - the added order

loadClassLocally

public Class loadClassLocally(String name,
                              boolean resolve)
                       throws ClassNotFoundException
Called to attempt to load a class from the set of URLs associated with this classloader.

Throws:
ClassNotFoundException

getResourceLocally

public URL getResourceLocally(String name)
Provides the same functionality as ClassLoader.getResource(java.lang.String).


getURL

public URL getURL()
Get the URL associated with the UCL.

Returns:
the url

unregister

public void unregister()

getClasspath

public URL[] getClasspath()
This method simply invokes the super.getURLs() method to access the list of URLs that make up the RepositoryClassLoader classpath.

Returns:
the urls that make up the classpath

getAllURLs

public URL[] getAllURLs()
Return all library URLs associated with this RepositoryClassLoader

Do not remove this method without running the WebIntegrationTestSuite


addToClassBlackList

public void addToClassBlackList(String name)
Black list a class

Parameters:
name - the name of the class

removeFromClassBlackList

public void removeFromClassBlackList(String name)
Remove class from black list

Parameters:
name - the name of the class

isClassBlackListed

public boolean isClassBlackListed(String name)
Is the class black listed?

Parameters:
name - the name of the class
Returns:
true when the class is black listed, false otherwise

clearClassBlackList

public void clearClassBlackList()
Clear any class black list.


addToResourceBlackList

public void addToResourceBlackList(String name)
Black list a resource

Parameters:
name - the name of the resource

removeFromResourceBlackList

public void removeFromResourceBlackList(String name)
Remove resource from black list

Parameters:
name - the name of the resource

isResourceBlackListed

public boolean isResourceBlackListed(String name)
Is the resource black listed?

Parameters:
name - the name of the resource
Returns:
true when the resource is black listed, false otherwise

clearResourceBlackList

public void clearResourceBlackList()
Clear any resource blacklist.


clearBlackLists

public void clearBlackLists()
Clear all blacklists


loadClass

public Class loadClass(String name,
                       boolean resolve)
                throws ClassNotFoundException
The only caller of this method should be the VM initiated loadClassInternal() method. This method attempts to acquire the UnifiedLoaderRepository2 lock and then asks the repository to load the class.

Forwards request to LoaderRepository.

Throws:
ClassNotFoundException

loadClassBefore

public Class loadClassBefore(String name)
                      throws ClassNotFoundException
The only caller of this method should be the VM initiated loadClassInternal() method. This method attempts to acquire the UnifiedLoaderRepository2 lock and then asks the repository to load the class.

Forwards request to LoaderRepository.

Throws:
ClassNotFoundException

loadClassImpl

public Class loadClassImpl(String name,
                           boolean resolve,
                           int stopAt)
                    throws ClassNotFoundException
Throws:
ClassNotFoundException

getResource

public URL getResource(String name)
Attempts to load the resource from its URL and if not found forwards to the request to LoaderRepository.


findResources

public Enumeration findResources(String name)
                          throws IOException
Find all resource URLs for the given name. This overrides the URLClassLoader version to look for resources in the repository.

Parameters:
name - the name of the resource
Returns:
Enumeration
Throws:
IOException

findResourcesLocally

public Enumeration findResourcesLocally(String name)
                                 throws IOException
Provides the same functionality as URLClassLoader.findResources(java.lang.String).

Throws:
IOException

findClass

protected Class findClass(String name)
                   throws ClassNotFoundException
Called by loadClassLocally to find the requested class within this class loaders class path.

Parameters:
name - the name of the class
Returns:
the resulting class
Throws:
ClassNotFoundException - if the class could not be found

findClassLocally

protected Class findClassLocally(String name)
                          throws ClassNotFoundException
Find the class

Parameters:
name - the name of the class
Returns:
the class
Throws:
ClassNotFoundException

definePackage

protected void definePackage(String className)
Define the package for the class if not already done

Parameters:
className - the class name

addURL

public void addURL(URL url)
Append the given url to the URLs used for class and resource loading

Parameters:
url - the URL to load from

getURLs

public URL[] getURLs()
Return an empty URL array to force the RMI marshalling subsystem to use the java.server.codebase property as the annotated codebase.

Do not remove this method without discussing it on the dev list.

Returns:
Empty URL[]

getPackage

public Package getPackage(String name)

getPackages

public Package[] getPackages()

equals

public final boolean equals(Object other)
This is here to document that this must delegate to the super implementation to perform identity based equality. Using URL based equality caused conflicts with the Class.forName(String, boolean, ClassLoader).


hashCode

public final int hashCode()
This is here to document that this must delegate to the super implementation to perform identity based hashing. Using URL based hashing caused conflicts with the Class.forName(String, boolean, ClassLoader).


toString

public String toString()
Returns a string representation.


attempt

protected boolean attempt(long waitMS)
Attempt to acquire the class loading lock. This lock must be acquired before a thread enters the class loading task loop in loadClass. This method maintains any interrupted state of the calling thread.

See Also:
loadClass(String, boolean)

acquire

protected void acquire()
Acquire the class loading lock. This lock must be acquired before a thread enters the class loading task loop in loadClass.

See Also:
loadClass(String, boolean)

release

protected void release()
Release the class loading lock previous acquired through the acquire method.


loadByteCode

protected byte[] loadByteCode(String classname)
                       throws ClassNotFoundException,
                              IOException
Obtain the bytecode for the indicated class from this class loaders classpath.

Parameters:
classname -
Returns:
the bytecode array if found
Throws:
ClassNotFoundException - - if the class resource could not be found
IOException

loadByteCode

protected byte[] loadByteCode(URL classURL)
                       throws ClassNotFoundException,
                              IOException
Obtain the bytecode for the indicated class from this class loaders classpath.

Parameters:
classURL -
Returns:
the bytecode array if found
Throws:
ClassNotFoundException - - if the class resource could not be found
IOException

getProtectionDomain

protected ProtectionDomain getProtectionDomain(URL codesourceUrl)
Determine the protection domain. If we are a copy of the original deployment, use the original url as the codebase.

Returns:
the protection domain


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