org.jboss.classloading.spi.dependency
Class Module

java.lang.Object
  extended by org.jboss.classloading.spi.helpers.NameAndVersionSupport
      extended by org.jboss.classloading.spi.dependency.Module
All Implemented Interfaces:
Serializable, Cloneable
Direct Known Subclasses:
ClassLoadingMetaDataModule

public abstract class Module
extends NameAndVersionSupport

Module.

Version:
$Revision: 1.1 $
Author:
Adrian Brock
See Also:
Serialized Form

Constructor Summary
Module(String name)
          Create a new Module with the default version
Module(String name, Object version)
          Create a new Module with the given version
Module(String name, String contextName, Object version)
          Create a new Module with the given version
 
Method Summary
protected  void addDelegates(Module module, List<DelegateLoader> delegates, List<DelegateLoader> dynamic, Set<Module> visited, boolean reExport)
          Add delegates
protected  void addIDependOn(RequirementDependencyItem item)
          Add a dependency
protected  void createDependencies()
          Create the dependencies for the module
abstract  DelegateLoader createLazyDelegateLoader(Domain domain, RequirementDependencyItem item)
          Create a lazy delegate loader
protected  List<Capability> defaultCapabilities()
          Determine the default capabilities.
protected  List<Capability> determineCapabilities()
          Determine the capabilities
 List<String> determinePackageNames(boolean optional)
          Determine the package names TODO JBCL-23 Better handling of conflicts for optional packages
 List<Requirement> determineRequirements()
          Determine the requirements.
 boolean equals(Object obj)
           
 List<Capability> getCapabilities()
          Get the capabilities.
protected  ClassLoader getClassLoader()
          Get the classloader for this module
protected  ClassLoader getClassLoaderForClass(String className)
          Get the classloader for a class name
 org.jboss.dependency.spi.ControllerState getClassLoaderState()
          Get the state for the classloader
 String getContextName()
          Get the context name
protected  org.jboss.dependency.spi.ControllerContext getControllerContext()
          Get the controller context.
abstract  DelegateLoader getDelegateLoader(Module requiringModule, Requirement requirement)
          Get the delegate loader
 List<? extends DelegateLoader> getDelegates()
          Get the delegate loaders for this module
 String getDeterminedDomainName()
          Get the determined domain name.
 String getDeterminedParentDomainName()
          Get the determined parentDomain name.
 ParentPolicy getDeterminedParentPolicy()
           
 String getDomainName()
          Get the domain name.
 URL getDynamicClassRoot()
          Return a URL where dynamic classes can be stored
 ClassFilter getExcluded()
          Get a filter for the excluded packages
 ClassFilter getExcludedExport()
          Get a filter for the excluded export packages
 ExportAll getExportAll()
          Get the export all for the module
 ClassFilter getIncluded()
          Get a filter for the included packages
 Module getModuleForClass(String className)
          Find the module that loads a class
 String[] getPackageNames()
          Get the package names
 String getParentDomainName()
          Get the parent domain name.
protected  List<RequirementDependencyItem> getRequirementDependencyItems()
          Get the dependency items
 List<Requirement> getRequirements()
          Get the requirements.
 URL getResource(String resourceName)
          Get a resource for this module
 Enumeration<URL> getResources(String resourceName)
          Get resources for this module
protected  boolean isBlackListable()
          Whether to cache misses
protected  boolean isCacheable()
          Whether to cache
 boolean isImportAll()
          Get the import all for the module
 boolean isJ2seClassLoadingCompliance()
          Get delegate policy
 boolean isValid()
          Whether this is a valid module
 Class<?> loadClass(String className)
          Load a class for this module
protected static void registerModuleClassLoader(Module module, ClassLoader classLoader)
          Register a classloader for a module
 void release()
          Release the module
protected  void removeDependencies()
          Remove dependencies
protected  void removeIDependOn(RequirementDependencyItem item)
          Remove a dependency
 void reset()
          Reset the module
protected  Module resolveModule(RequirementDependencyItem dependency, boolean resolveSpace)
          Resolve a requirement
protected  void setControllerContext(org.jboss.dependency.spi.ControllerContext context)
          Set the controller context
protected static void unregisterModuleClassLoader(Module module, ClassLoader classLoader)
          Register a classloader for a module
 void visit(ResourceVisitor visitor)
          Visit the resources in this module using the filter defined on the visitor
 void visit(ResourceVisitor visitor, ResourceFilter filter)
          Visit the resources in this module using the given filter
 void visit(ResourceVisitor visitor, ResourceFilter filter, ResourceFilter recurseFilter, URL... urls)
          Visit the resources in this module using the given filter(s)

Typically the filter is used to determine which types of files to visit, e.g.

 
Methods inherited from class org.jboss.classloading.spi.helpers.NameAndVersionSupport
clone, getName, getTheVersion, getVersion, hashCode, setName, setTheVersion, setVersion, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Module

public Module(String name)
Create a new Module with the default version

Parameters:
name - the name
Throws:
IllegalArgumentException - for a null parameter

Module

public Module(String name,
              Object version)
Create a new Module with the given version

Parameters:
name - the name
version - pass null for the default version
Throws:
IllegalArgumentException - for a null parameter

Module

public Module(String name,
              String contextName,
              Object version)
Create a new Module with the given version

Parameters:
name - the name
contextName - the real name of the module in the controller
version - pass null for the default version
Throws:
IllegalArgumentException - for a null parameter
Method Detail

registerModuleClassLoader

protected static void registerModuleClassLoader(Module module,
                                                ClassLoader classLoader)
Register a classloader for a module

Parameters:
module - the module
classLoader - the classloader
Throws:
IllegalArgumentException - for a null parameter

unregisterModuleClassLoader

protected static void unregisterModuleClassLoader(Module module,
                                                  ClassLoader classLoader)
Register a classloader for a module

Parameters:
module - the module
classLoader - the classloader
Throws:
IllegalArgumentException - for a null parameter

getContextName

public String getContextName()
Get the context name

Returns:
the context name

isValid

public boolean isValid()
Whether this is a valid module

Returns:
true when valid

getDomainName

public String getDomainName()
Get the domain name.

Returns:
the domain name.

getDeterminedDomainName

public String getDeterminedDomainName()
Get the determined domain name.

Returns:
the determined domain.

getParentDomainName

public String getParentDomainName()
Get the parent domain name.

Returns:
the parent domain name.

getDeterminedParentDomainName

public String getDeterminedParentDomainName()
Get the determined parentDomain name.

Returns:
the parentDomain.

getExportAll

public ExportAll getExportAll()
Get the export all for the module

Returns:
the export all

getIncluded

public ClassFilter getIncluded()
Get a filter for the included packages

Returns:
the excluded packages

getExcluded

public ClassFilter getExcluded()
Get a filter for the excluded packages

Returns:
the excluded packages

getExcludedExport

public ClassFilter getExcludedExport()
Get a filter for the excluded export packages

Returns:
the excluded packages

isImportAll

public boolean isImportAll()
Get the import all for the module

Returns:
the import all

isJ2seClassLoadingCompliance

public boolean isJ2seClassLoadingCompliance()
Get delegate policy

Returns:
the delegation policy

getDeterminedParentPolicy

public ParentPolicy getDeterminedParentPolicy()

isCacheable

protected boolean isCacheable()
Whether to cache

Returns:
true to cache

isBlackListable

protected boolean isBlackListable()
Whether to cache misses

Returns:
true to cache misses

getModuleForClass

public Module getModuleForClass(String className)
                         throws ClassNotFoundException
Find the module that loads a class

Parameters:
className - the class name
Returns:
the module or null if the class is not loaded by a registered module classloader
Throws:
ClassNotFoundException - when the class is not found
IllegalStateException - when the module is not associated with a classloader

getClassLoaderForClass

protected ClassLoader getClassLoaderForClass(String className)
                                      throws ClassNotFoundException
Get the classloader for a class name

Parameters:
className - the class name
Returns:
the class
Throws:
ClassNotFoundException - when the class is not found
IllegalStateException - when the module is not associated with a classloader

loadClass

public Class<?> loadClass(String className)
                   throws ClassNotFoundException
Load a class for this module

Parameters:
className - the class name
Returns:
the class
Throws:
ClassNotFoundException - when the class is not found
IllegalStateException - when the module is not associated with a classloader

getResource

public URL getResource(String resourceName)
Get a resource for this module

Parameters:
resourceName - the resource name
Returns:
the class
Throws:
IllegalStateException - when the module is not associated with a classloader

getResources

public Enumeration<URL> getResources(String resourceName)
                              throws IOException
Get resources for this module

Parameters:
resourceName - the resource name
Returns:
the class
Throws:
IOException - for an error
IllegalStateException - when the module is not associated with a classloader

getClassLoader

protected ClassLoader getClassLoader()
Get the classloader for this module

Returns:
the classloader

visit

public void visit(ResourceVisitor visitor)
Visit the resources in this module using the filter defined on the visitor

Parameters:
visitor - the visitor

visit

public void visit(ResourceVisitor visitor,
                  ResourceFilter filter)
Visit the resources in this module using the given filter

Parameters:
visitor - the visitor
filter - the filter

visit

public void visit(ResourceVisitor visitor,
                  ResourceFilter filter,
                  ResourceFilter recurseFilter,
                  URL... urls)
Visit the resources in this module using the given filter(s)

Typically the filter is used to determine which types of files to visit, e.g. .class files. While the recurseFilter determines which jars/directories to recurse into.

Parameters:
visitor - the visitor
filter - the filter
recurseFilter - the recursion filter (null means recurse into everything)
urls - the urls we should visit

getDelegates

public List<? extends DelegateLoader> getDelegates()
Get the delegate loaders for this module

Returns:
the delegates

getRequirementDependencyItems

protected List<RequirementDependencyItem> getRequirementDependencyItems()
Get the dependency items

Returns:
the depenency items

addDelegates

protected void addDelegates(Module module,
                            List<DelegateLoader> delegates,
                            List<DelegateLoader> dynamic,
                            Set<Module> visited,
                            boolean reExport)
Add delegates

Parameters:
module - the module to add delegates from
delegates - the current list of delegates
dynamic - the dynamic delegates
visited - the visited modules
reExport - whether to only add re-exports

createLazyDelegateLoader

public abstract DelegateLoader createLazyDelegateLoader(Domain domain,
                                                        RequirementDependencyItem item)
Create a lazy delegate loader

Parameters:
domain - the domain
item - the dependency item
Returns:
the delegate loader

getDelegateLoader

public abstract DelegateLoader getDelegateLoader(Module requiringModule,
                                                 Requirement requirement)
Get the delegate loader

Parameters:
requiringModule - the requiring module
requirement - the requirement
Returns:
the delegate loader

getCapabilities

public List<Capability> getCapabilities()
Get the capabilities.

Returns:
the capabilities.

determineCapabilities

protected List<Capability> determineCapabilities()
Determine the capabilities

Returns:
the capabilities

defaultCapabilities

protected List<Capability> defaultCapabilities()
Determine the default capabilities.

By default it is just the module capability

Returns:
the capabilities

getPackageNames

public String[] getPackageNames()
Get the package names

Returns:
the package names

determinePackageNames

public List<String> determinePackageNames(boolean optional)
Determine the package names TODO JBCL-23 Better handling of conflicts for optional packages

Parameters:
optional - whether to include optional packages
Returns:
the package names

getClassLoaderState

public org.jboss.dependency.spi.ControllerState getClassLoaderState()
Get the state for the classloader

Returns:
the state

getRequirements

public List<Requirement> getRequirements()
Get the requirements.

Returns:
the requirements.

determineRequirements

public List<Requirement> determineRequirements()
Determine the requirements.

Returns:
the requirements.

getDynamicClassRoot

public URL getDynamicClassRoot()
Return a URL where dynamic classes can be stored

Returns:
the url or null if there isn't one

createDependencies

protected void createDependencies()
Create the dependencies for the module


removeDependencies

protected void removeDependencies()
Remove dependencies


getControllerContext

protected org.jboss.dependency.spi.ControllerContext getControllerContext()
Get the controller context.

Returns:
the controller context.

setControllerContext

protected void setControllerContext(org.jboss.dependency.spi.ControllerContext context)
Set the controller context

Parameters:
context - the context

addIDependOn

protected void addIDependOn(RequirementDependencyItem item)
Add a dependency

Parameters:
item - the dependency item

removeIDependOn

protected void removeIDependOn(RequirementDependencyItem item)
Remove a dependency

Parameters:
item - the dependency item

resolveModule

protected Module resolveModule(RequirementDependencyItem dependency,
                               boolean resolveSpace)
Resolve a requirement

Parameters:
dependency - the dependency the dependency
resolveSpace - whether to resolve the module in the classloading space
Returns:
the resolved name or null if not resolved

release

public void release()
Release the module


reset

public void reset()
Reset the module


equals

public boolean equals(Object obj)
Overrides:
equals in class NameAndVersionSupport


Copyright © 2011 JBoss, a division of Red Hat, Inc.. All Rights Reserved.