|
||||||||||
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. |
|
static Module |
getCurrentModule()
Deprecated. use getCallerModule() instead. |
|
static ModuleLoader |
getCurrentModuleLoader()
Deprecated. use getCallerModuleLoader() instead. |
|
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. |
|
static Module |
getModuleFromCurrentLoader(ModuleIdentifier identifier)
Deprecated. use getModuleFromCallerModuleLoader(ModuleIdentifier) instead. |
|
ModuleLoader |
getModuleLoader()
Get the module loader which created this module. |
|
static ModuleLogger |
getModuleLogger()
Get the logger used by the module system. |
|
static long |
getStartTime()
Return the start time in millis when Module.class was loaded. |
|
static Module |
getSystemModule()
Get the system module. |
|
static ModuleLoader |
getSystemModuleLoader()
Deprecated. Use getBootModuleLoader() . This method will be removed. |
|
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. |
|
static Class<?> |
loadClassFromCurrentLoader(ModuleIdentifier moduleIdentifier,
String className)
Deprecated. use loadClassFromCallerModuleLoader(ModuleIdentifier, String) instead. |
|
static Class<?> |
loadClassFromSystemLoader(ModuleIdentifier moduleIdentifier,
String className)
Deprecated. use loadClassFromBootModuleLoader(ModuleIdentifier, String) instead. |
|
|
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
|
loadServiceFromCurrent(ModuleIdentifier identifier,
Class<S> serviceType)
Deprecated. use loadServiceFromCallerModuleLoader(ModuleIdentifier, Class) instead. |
|
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 static Module getSystemModule()
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 load@Deprecated public static <S> ServiceLoader<S> loadServiceFromCurrent(ModuleIdentifier identifier, Class<S> serviceType) throws ModuleLoadException
loadServiceFromCallerModuleLoader(ModuleIdentifier, Class)
instead.
ModuleLoadException
public 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.
@Deprecated public static ModuleLoader getSystemModuleLoader()
getBootModuleLoader()
. This method will be removed.
public static ModuleLoader getCallerModuleLoader()
@Deprecated public static ModuleLoader getCurrentModuleLoader()
getCallerModuleLoader()
instead.
public 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()
@Deprecated public static Module getModuleFromCurrentLoader(ModuleIdentifier identifier) throws ModuleLoadException
getModuleFromCallerModuleLoader(ModuleIdentifier)
instead.
ModuleLoadException
public static Module getCallerModule()
@Deprecated public static Module getCurrentModule()
getCallerModule()
instead.
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()
@Deprecated public static Class<?> loadClassFromSystemLoader(ModuleIdentifier moduleIdentifier, String className) throws ModuleLoadException, ClassNotFoundException
loadClassFromBootModuleLoader(ModuleIdentifier, String)
instead.
ModuleLoadException
ClassNotFoundException
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()
@Deprecated public static Class<?> loadClassFromCurrentLoader(ModuleIdentifier moduleIdentifier, String className) throws ModuleLoadException, ClassNotFoundException
loadClassFromCallerModuleLoader(ModuleIdentifier, String)
instead.
ModuleLoadException
ClassNotFoundException
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 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
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |