|
JBoss Modules 1.1.2.GA | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jboss.modules.Module
public final class Module
A module is a unit of classes and other resources, along with the specification of what is imported and exported
by this module from and to other modules. Modules are created by ModuleLoader
s which build modules from
various configuration information and resource roots.
Method Summary | ||
---|---|---|
static Module |
forClass(Class<?> clazz)
Get the module for a loaded class, or null if the class did not come from any module. |
|
static Module |
forClassLoader(ClassLoader cl,
boolean search)
Get the module for a class loader, or null if the class loader is not associated with any module. |
|
static ModuleLoader |
getBootModuleLoader()
Gets the boot module loader. |
|
static Module |
getCallerModule()
Get the caller's module. |
|
static ModuleLoader |
getCallerModuleLoader()
Gets the current module loader. |
|
ModuleClassLoader |
getClassLoader()
Get the class loader for a module. |
|
static ModuleLoader |
getContextModuleLoader()
Get the current thread's context module loader. |
|
Set<String> |
getExportedPaths()
Get all the paths exported by this module. |
|
URL |
getExportedResource(String name)
Get an exported resource URL. |
|
Resource |
getExportedResource(String rootPath,
String resourcePath)
Get an exported resource from a specific root in this module. |
|
Enumeration<URL> |
getExportedResources(String name)
Get all exported resource URLs for a resource name. |
|
ModuleIdentifier |
getIdentifier()
Get this module's identifier. |
|
Module |
getModule(ModuleIdentifier identifier)
Get the module with the given identifier from the module loader used by this module. |
|
static Module |
getModuleFromCallerModuleLoader(ModuleIdentifier identifier)
Get a module from the current module loader. |
|
ModuleLoader |
getModuleLoader()
Get the module loader which created this module. |
|
static ModuleLogger |
getModuleLogger()
Get the logger used by the module system. |
|
String |
getProperty(String name)
Get the property with the given name, or null if none was defined. |
|
String |
getProperty(String name,
String defaultVal)
Get the property with the given name, or a default value if none was defined. |
|
List<String> |
getPropertyNames()
Get a copy of the list of property names. |
|
static long |
getStartTime()
Return the start time in millis when Module.class was loaded. |
|
static Class<?> |
loadClassFromBootModuleLoader(ModuleIdentifier moduleIdentifier,
String className)
Load a class from a module in the system module loader. |
|
static Class<?> |
loadClassFromCallerModuleLoader(ModuleIdentifier moduleIdentifier,
String className)
Load a class from a module in the caller's module loader. |
|
|
loadService(Class<S> serviceType)
Load a service loader from this module. |
|
static
|
loadServiceFromCallerModuleLoader(ModuleIdentifier identifier,
Class<S> serviceType)
Load a service loader from a module in the caller's module loader. |
|
static void |
registerContentHandlerFactoryModule(Module module)
Register an additional module which contains content handlers. |
|
static void |
registerURLStreamHandlerFactoryModule(Module module)
Register an additional module which contains URL handlers. |
|
void |
run(String[] args)
Run a module's main class, if any. |
|
static void |
setModuleLogger(ModuleLogger logger)
Change the logger used by the module system. |
|
String |
toString()
Get the string representation of this module. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Method Detail |
---|
public Resource getExportedResource(String rootPath, String resourcePath)
rootPath
- the module root to searchresourcePath
- the path of the resource
public void run(String[] args) throws NoSuchMethodException, InvocationTargetException, ClassNotFoundException
args
- the arguments to pass
NoSuchMethodException
- if there is no main method
InvocationTargetException
- if the main method failed
ClassNotFoundException
- if the main class is not foundpublic ModuleIdentifier getIdentifier()
public ModuleLoader getModuleLoader()
public <S> ServiceLoader<S> loadService(Class<S> serviceType)
S
- the service typeserviceType
- the service type class
public static <S> ServiceLoader<S> loadServiceFromCallerModuleLoader(ModuleIdentifier identifier, Class<S> serviceType) throws ModuleLoadException
loadService(Class)
is more efficient since it does not need to crawl
the stack.
S
- the the service typeidentifier
- the module identifier containing the service loaderserviceType
- the service type class
ModuleLoadException
- if the named module failed to loadpublic ModuleClassLoader getClassLoader()
If a security manager is present, then this method invokes the security manager's checkPermission
method
with a RuntimePermission("getClassLoader")
permission to verify access to the class loader. If
access is not granted, a SecurityException
will be thrown.
public Set<String> getExportedPaths()
public static Module forClass(Class<?> clazz)
null
if the class did not come from any module.
clazz
- the class
public static Module forClassLoader(ClassLoader cl, boolean search)
null
if the class loader is not associated with any module. If
the class loader is unknown, it is possible to check the parent class loader up the chain, and so on until a module is found.
cl
- the class loadersearch
- true
to search up the delegation chain
public static ModuleLoader getBootModuleLoader()
boot.module.loader
system
property.
public static ModuleLoader getCallerModuleLoader()
null
if this method is called outside of a modulepublic static ModuleLoader getContextModuleLoader()
null
is returned.
null
if none is setpublic static Module getModuleFromCallerModuleLoader(ModuleIdentifier identifier) throws ModuleLoadException
identifier
- the module identifier
ModuleLoadException
- if the module could not be loadedgetCallerModuleLoader()
public static Module getCallerModule()
public Module getModule(ModuleIdentifier identifier) throws ModuleLoadException
identifier
- the module identifier
ModuleLoadException
- if an error occurspublic static Class<?> loadClassFromBootModuleLoader(ModuleIdentifier moduleIdentifier, String className) throws ModuleLoadException, ClassNotFoundException
moduleIdentifier
- the identifier of the module from which the class
should be loadedclassName
- the class name to load
ModuleLoadException
- if the module could not be loaded
ClassNotFoundException
- if the class could not be loadedgetBootModuleLoader()
public static Class<?> loadClassFromCallerModuleLoader(ModuleIdentifier moduleIdentifier, String className) throws ModuleLoadException, ClassNotFoundException
moduleIdentifier
- the identifier of the module from which the class
should be loadedclassName
- the class name to load
ModuleLoadException
- if the module could not be loaded
ClassNotFoundException
- if the class could not be loadedgetCallerModuleLoader()
public URL getExportedResource(String name)
name
- the resource name
null
if it was not foundpublic Enumeration<URL> getExportedResources(String name)
name
- the resource name
public String getProperty(String name)
null
if none was defined.
name
- the property name
public String getProperty(String name, String defaultVal)
name
- the property namedefaultVal
- the default value
public List<String> getPropertyNames()
public String toString()
toString
in class Object
public static ModuleLogger getModuleLogger()
If a security manager is present, then this method invokes the security manager's checkPermission
method
with a RuntimePermission("accessModuleLogger")
permission to verify access to the module logger. If
access is not granted, a SecurityException
will be thrown.
public static void setModuleLogger(ModuleLogger logger)
If a security manager is present, then this method invokes the security manager's checkPermission
method
with a RuntimePermission("accessModuleLogger")
permission to verify access to the module logger. If
access is not granted, a SecurityException
will be thrown.
logger
- the new logger, must not be null
public static long getStartTime()
public static void registerContentHandlerFactoryModule(Module module)
If a security manager is present, then this method invokes the security manager's checkPermission
method
with a RuntimePermission("addContentHandlerFactory")
permission to verify access. If
access is not granted, a SecurityException
will be thrown.
module
- the module to addpublic static void registerURLStreamHandlerFactoryModule(Module module)
If a security manager is present, then this method invokes the security manager's checkPermission
method
with a RuntimePermission("addURLStreamHandlerFactory")
permission to verify access. If
access is not granted, a SecurityException
will be thrown.
module
- the module to add
|
JBoss Modules 1.1.2.GA | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |