org.jboss.mx.loading
Class UnifiedClassLoader

java.lang.Object
  extended byjava.lang.ClassLoader
      extended byjava.security.SecureClassLoader
          extended byjava.net.URLClassLoader
              extended byorg.jboss.mx.loading.RepositoryClassLoader (src) 
                  extended byorg.jboss.mx.loading.UnifiedClassLoader
All Implemented Interfaces:
Translatable (src) , UnifiedClassLoaderMBean (src)
Direct Known Subclasses:
UnifiedClassLoader3 (src)

public class UnifiedClassLoader
extends RepositoryClassLoader (src)
implements UnifiedClassLoaderMBean (src) , Translatable (src)

A ClassLoader which loads classes from a single URL in conjunction with the LoaderRepository (src) . Notice that this classloader does not work independently of the repository. A repository reference must be provided via the constructor or the classloader must be explicitly registered to the repository before any attempt to load a class. At this point this is little more than an abstract class maintained as the interface for class loaders as the algorithm of the UnifiedLoaderRepository fails with deadlocks, and several other class loading exceptions in multi- threaded environments.


Field Summary
protected  java.net.URL origURL
          An optional URL from which url may have been copied.
protected  java.net.URL url
          One URL per ClassLoader in our case
 
Fields inherited from class org.jboss.mx.loading.RepositoryClassLoader (src)
loadLock, parent, repository, unregisterTrace
 
Constructor Summary
UnifiedClassLoader(java.net.URL url)
          Construct a UnifiedClassLoader without registering it to the classloader repository.
UnifiedClassLoader(java.net.URL url, LoaderRepository (src)  repository)
          Construct a UnifiedClassLoader and registers it to the given repository.
UnifiedClassLoader(java.net.URL url, MBeanServer (src)  server, ObjectName (src)  repositoryName)
          UnifiedClassLoader constructor that can be used to register with a particular Loader Repository identified by ObjectName.
UnifiedClassLoader(java.net.URL url, java.net.URL origURL)
          Construct a UnifiedClassLoader without registering it to the classloader repository.
UnifiedClassLoader(java.net.URL url, java.net.URL origURL, java.lang.ClassLoader parent)
          Construct a UnifiedClassLoader without registering with the classloader repository.
UnifiedClassLoader(java.net.URL url, java.net.URL origURL, LoaderRepository (src)  repository)
          Construct a UnifiedClassLoader and registers it to the given repository.
UnifiedClassLoader(java.net.URL url, java.net.URL origURL, MBeanServer (src)  server, ObjectName (src)  repositoryName)
          UnifiedClassLoader constructor that can be used to register with a particular Loader Repository identified by ObjectName.
 
Method Summary
 ObjectName (src) getObjectName()
          Obtain the ObjectName under which the UCL can be registered with the JMX server.
 java.net.URL getOrigURL()
          Get the original URL associated with the UCL.
protected  java.security.PermissionCollection getPermissions(java.security.CodeSource cs)
          Override the permissions accessor to use the CodeSource based on the original URL if one exists.
protected  java.security.ProtectionDomain getProtectionDomain()
          Determine the protection domain.
 java.net.URL getURL()
          Get the URL associated with the UCL.
 void unregister()
           
 
Methods inherited from class org.jboss.mx.loading.RepositoryClassLoader (src)
acquire, addToClassBlackList, addToResourceBlackList, addURL, attempt, clearBlackLists, clearClassBlackList, clearResourceBlackList, definePackage, equals, findClass, findClassLocally, findResources, findResourcesLocally, getAddedOrder, getAllURLs, getClasspath, getLoaderRepository, getPackage, getPackages, getProtectionDomain, getResource, getResourceLocally, getURLs, hashCode, isClassBlackListed, isResourceBlackListed, loadByteCode, loadByteCode, loadClass, loadClassBefore, loadClassImpl, loadClassLocally, release, removeFromClassBlackList, removeFromResourceBlackList, setAddedOrder, setRepository, toString
 
Methods inherited from class java.net.URLClassLoader
definePackage, findResource, 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
 
Methods inherited from interface org.jboss.util.loading.Translatable (src)
getResourceLocally
 

Field Detail

url

protected java.net.URL url
One URL per ClassLoader in our case


origURL

protected java.net.URL origURL
An optional URL from which url may have been copied. It is used to allow the security permissions to be based on a static url namespace.

Constructor Detail

UnifiedClassLoader

public UnifiedClassLoader(java.net.URL url)
Construct a UnifiedClassLoader without registering it to the classloader repository.

Parameters:
url - the single URL to load classes from.

UnifiedClassLoader

public UnifiedClassLoader(java.net.URL url,
                          java.net.URL origURL)
Construct a UnifiedClassLoader without registering it to the classloader repository.

Parameters:
url - the single URL to load classes from.
origURL - the possibly null original URL from which url may be a local copy or nested jar.

UnifiedClassLoader

public UnifiedClassLoader(java.net.URL url,
                          java.net.URL origURL,
                          java.lang.ClassLoader parent)
Construct a UnifiedClassLoader without registering with the classloader repository.

Parameters:
url - the single URL to load classes from.
origURL - the possibly null original URL from which url may be a local copy or nested jar.
parent - the parent class loader to use

UnifiedClassLoader

public UnifiedClassLoader(java.net.URL url,
                          LoaderRepository (src)  repository)
Construct a UnifiedClassLoader and registers it to the given repository.

Parameters:
url - The single URL to load classes from.
repository - the repository this classloader delegates to

UnifiedClassLoader

public UnifiedClassLoader(java.net.URL url,
                          java.net.URL origURL,
                          LoaderRepository (src)  repository)
Construct a UnifiedClassLoader and registers it to the given repository.

Parameters:
url - The single URL to load classes from.
origURL - the possibly null original URL from which url may be a local copy or nested jar.
repository - the repository this classloader delegates to be a local copy or nested jar.

UnifiedClassLoader

public UnifiedClassLoader(java.net.URL url,
                          MBeanServer (src)  server,
                          ObjectName (src)  repositoryName)
                   throws java.lang.Exception
UnifiedClassLoader constructor that can be used to register with a particular Loader Repository identified by ObjectName.

Parameters:
url - an URL value
server - a MBeanServer value
repositoryName - an ObjectName value
Throws:
java.lang.Exception - if an error occurs

UnifiedClassLoader

public UnifiedClassLoader(java.net.URL url,
                          java.net.URL origURL,
                          MBeanServer (src)  server,
                          ObjectName (src)  repositoryName)
                   throws java.lang.Exception
UnifiedClassLoader constructor that can be used to register with a particular Loader Repository identified by ObjectName.

Parameters:
url - an URL value
origURL - the possibly null original URL from which url may be a local copy or nested jar.
server - a MBeanServer value
repositoryName - an ObjectName value
Throws:
java.lang.Exception - if an error occurs
Method Detail

getObjectName

public ObjectName (src)  getObjectName()
                         throws MalformedObjectNameException (src) 
Obtain the ObjectName under which the UCL can be registered with the JMX server. This creates a name of the form "jmx.loading:UCL=hashCode" since we don't currently care that UCL be easily queriable.

Specified by:
getObjectName in class RepositoryClassLoader (src)
Returns:
the object name
Throws:
MalformedObjectNameException (src)

unregister

public void unregister()
Overrides:
unregister in class RepositoryClassLoader (src)

getURL

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

Overrides:
getURL in class RepositoryClassLoader (src)
Returns:
the url

getOrigURL

public java.net.URL getOrigURL()
Get the original URL associated with the UCL. This may be null.


getPermissions

protected java.security.PermissionCollection getPermissions(java.security.CodeSource cs)
Override the permissions accessor to use the CodeSource based on the original URL if one exists. This allows the security policy to be defined in terms of the static URL namespace rather than the local copy or nested URL. This builds a PermissionCollection from: 1. The origURL CodeSource 2. The argument CodeSource 3. The Policy.getPermission(origURL CodeSource) This is necessary because we cannot define the CodeSource the SecureClassLoader uses to register the class under.

Parameters:
cs - the location and signatures of the codebase.

getProtectionDomain

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

Returns:
the protection domain