org.jboss.deployment.scope
Class Scope

java.lang.Object
  |
  +--org.jboss.deployment.scope.Scope

public class Scope
extends java.lang.Object

Scope is a manager/mediator that connects several ScopedURLClassLoaders with each other and computes their dependencies. The locks used in the scope implementation are quite coarse-grained, maybe thread-unfriendly, but the rationale is that classloading a) happens not too often (hopefully) in the lifecycle of an application b) will dispatch only in special cases (where applications depliberately share classes) to this scope class and c) is optimized by caching the locations.

Version:
0.8
Author:
cgjung

Field Summary
protected  java.util.Map classLoaders
          keeps a map of class loaders that participate in this scope
protected  java.util.Map classLocations
          keeps a hashtable of class appearances
protected  java.util.Map dependencies
          keeps a hashtable of dependencies between the classLoaders
protected  Logger log
          keeps a reference to a logger which which to interact
protected  java.util.Map resourceLocations
          keeps a hashtable of resource appearances
 
Constructor Summary
Scope(Logger log)
          Creates new Scope
 
Method Summary
protected  boolean addDependency(ScopedURLClassLoader source, ScopedURLClassLoader target)
          adds a dependency between two classloaders.
protected  void clearByValue(java.util.Map map, java.lang.Object value)
          helper method that will clear all entries from a map with a dedicated target value.
 ScopedURLClassLoader deRegisterClassLoader(ScopedURLClassLoader loader)
          deRegisters a classloader in this scope removes all cached data related to this classloader
 java.util.Set getDependentClassLoaders(ScopedURLClassLoader loader)
          returns the classLoaders that a particular classLoader is dependent on.
 java.net.URL getResource(java.lang.String name, ScopedURLClassLoader source)
          gets a URL on behalf of a given classloader which may be null in case that we do not check dependencies
 java.lang.Class loadClass(java.lang.String className, boolean resolve, ScopedURLClassLoader source)
          loads a class on behalf of a given classloader
 ScopedURLClassLoader registerClassLoader(ScopedURLClassLoader loader)
          registers a classloader in this scope
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

classLoaders

protected final java.util.Map classLoaders
keeps a map of class loaders that participate in this scope

dependencies

protected final java.util.Map dependencies
keeps a hashtable of dependencies between the classLoaders

classLocations

protected final java.util.Map classLocations
keeps a hashtable of class appearances

resourceLocations

protected final java.util.Map resourceLocations
keeps a hashtable of resource appearances

log

protected final Logger log
keeps a reference to a logger which which to interact
Constructor Detail

Scope

public Scope(Logger log)
Creates new Scope
Method Detail

registerClassLoader

public ScopedURLClassLoader registerClassLoader(ScopedURLClassLoader loader)
registers a classloader in this scope

deRegisterClassLoader

public ScopedURLClassLoader deRegisterClassLoader(ScopedURLClassLoader loader)
deRegisters a classloader in this scope removes all cached data related to this classloader

clearByValue

protected void clearByValue(java.util.Map map,
                            java.lang.Object value)
helper method that will clear all entries from a map with a dedicated target value.

getDependentClassLoaders

public java.util.Set getDependentClassLoaders(ScopedURLClassLoader loader)
returns the classLoaders that a particular classLoader is dependent on. Should be called after locking classLoaders

addDependency

protected boolean addDependency(ScopedURLClassLoader source,
                                ScopedURLClassLoader target)
adds a dependency between two classloaders. this can be called from within application threads that require resource loading. Should be called after locking classLoaders

loadClass

public java.lang.Class loadClass(java.lang.String className,
                                 boolean resolve,
                                 ScopedURLClassLoader source)
                          throws java.lang.ClassNotFoundException
loads a class on behalf of a given classloader

getResource

public java.net.URL getResource(java.lang.String name,
                                ScopedURLClassLoader source)
gets a URL on behalf of a given classloader which may be null in case that we do not check dependencies


Copyright © 2000 The JBoss Organization. All Rights Reserved.