Top Description Inners Fields Constructors Methods
org.jboss.modules

public final Class Module

extends Object
Class Inheritance
Imports
java.io.IOException, .InputStream, java.lang.invoke.MethodHandle, .MethodHandles, .MethodType, java.lang.reflect.InvocationTargetException, java.net.URL, .URLConnection, java.security.AccessController, .Permission, .PermissionCollection, .Permissions, .PrivilegedAction, java.util.ArrayList, .Collections, .Enumeration, .HashMap, .HashSet, .Iterator, .LinkedHashMap, .List, .ListIterator, .Map, .NoSuchElementException, .ServiceLoader, .Set, java.util.concurrent.atomic.AtomicReference, java.util.function.Predicate, org.jboss.modules._private.ModulesPrivateAccess, org.jboss.modules.filter.ClassFilter, .ClassFilters, .PathFilter, .PathFilters, org.jboss.modules.log.ModuleLogger, .NoopModuleLogger, org.jboss.modules.security.ModularPermissionFactory

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 ModuleLoaders which build modules from various configuration information and resource roots.
Authors
David M. Lloyd, John Bailey, Flavia Rainone, Jason T. Greene, [email protected]

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class

Field Summary

Modifier and TypeField and Description
private static final RuntimePermission
private static final RuntimePermission
private static final RuntimePermission
pack-priv volatile Set<String>
aliases

Module aliases

private static final AtomicReference<ModuleLoader>
private static final FastCopyHashSet<ClassFilter>
private static final FastCopyHashSet<PathFilter>
private final LocalLoader
fallbackLoader

The fallback local loader, if any is defined.

private static final RuntimePermission
private static final RuntimePermission
private static final RuntimePermission
private volatile Linkage
linkage

The linkage state.

pack-priv static volatile ModuleLogger
log

The system-wide module logger, which may be changed via setModuleLogger(org.jboss.modules.log.ModuleLogger).

private static final MethodType
private final String
mainClassName

The name of the main class, if any (may be null).

private final ModuleClassLoader
moduleClassLoader

The module class loader for this module.

private final ModuleLoader
moduleLoader

The module loader which created this module.

private final String
name

The name of this module.

private static final PermissionCollection
private final PermissionCollection
permissionCollection

The assigned permission collection.

pack-priv static final ModulesPrivateAccess
private final Map<String, String>
properties

The properties map specified when this module was defined.

pack-priv static final String[]
pack-priv static final String[]
private final Version
version

The (optional) module version.

Constructor Summary

AccessConstructor and Description
pack-priv
Module(final ConcreteModuleSpec
the module specification
spec
,
final ModuleLoader
the module loader
moduleLoader
)

Construct a new instance from a module specification.

Method Summary

Modifier and TypeMethod and Description
private long
addExportedPaths(Dependency[] dependencies, Map<String, List<LocalLoader>> map, FastCopyHashSet<PathFilter> filterStack, FastCopyHashSet<ClassFilter> classFilterStack, final FastCopyHashSet<PathFilter> resourceFilterStack, Set<Module.Visited> visited)

private long
addPaths(Dependency[] dependencies, Map<String, List<LocalLoader>> map, FastCopyHashSet<PathFilter> filterStack, FastCopyHashSet<ClassFilter> classFilterStack, final FastCopyHashSet<PathFilter> resourceFilterStack, Set<Module.Visited> visited)

private Dependency[]
calculateDependencies(final DependencySpec[] dependencySpecs)

private static PermissionCollection
copyPermissions(PermissionCollection permissionCollection)

private LocalLoader
private LocalLoader
pack-priv static String

Returns:

the name of the corresponding class file
fileNameOfClass
(final String
the class name
className
)

Get the file name of a class.

public static <T> Iterable<T>

Returns:

An iterable of available and filtered providers of given type
findServices
(final Class<T>
service provider type
type
,
final Predicate<Class<?>>
to specify which providers to load
filter
,
final ClassLoader
to be used for providers lookup
loader
)

Returns an iterable of available and filtered providers of given type.

public static Module

Returns:

the module it came from
forClass
(Class<?>
the class
clazz
)

Get the module for a loaded class, or null if the class did not come from any module.

public static Module

Returns:

the associated module
forClassLoader
(ClassLoader
the class loader
cl
,
boolean
true to search up the delegation chain
search
)

Get the module for a class loader, or null if the class loader is not associated with any module.

public static ModuleLoader

Returns:

the boot module loader
getBootModuleLoader
()

Gets the boot module loader.

public static Module

Returns:

the current module
getCallerModule
()

Get the caller's module.

public static ModuleLoader

Returns:

the current module loader, or null if this method is called outside of a module
getCallerModuleLoader
()

Gets the current module loader.

public ModuleClassLoader

Returns:

the module class loader
getClassLoader
()

Get the class loader for a module.

pack-priv ModuleClassLoader
public static ModuleLoader

Returns:

the module loader, or null if none is set
getContextModuleLoader
()

Get the current thread's context module loader.

public DependencySpec[]

Returns:

the current dependencies of this module
getDependencies
()

Get the current dependencies of this module.

pack-priv Dependency[]
pack-priv DependencySpec[]
public Set<String>

Returns:

the paths that are exported by this module
getExportedPaths
()

Get all the paths exported by this module.

public Resource

Returns:

the resource
getExportedResource
(final String
the module root to search
rootPath
,
final String
the path of the resource
resourcePath
)

Deprecated Resource root names are deprecated.
Get an exported resource from a specific root in this module.
public URL

Returns:

the resource, or null if it was not found
getExportedResource
(final String
the resource name
name
)

Get an exported resource URL.

public Enumeration<URL>

Returns:

the resource URLs
getExportedResources
(final String
the resource name
name
)

Get all exported resource URLs for a resource name.

pack-priv LocalLoader
public ModuleIdentifier

Returns:

the identifier
getIdentifier
()

Deprecated Use getName() instead.
Get this module's identifier.
public Set<String>

Returns:

the set of paths
getImportedPaths
()

Get the (unmodifiable) set of paths which are imported into this module class loader, including local paths.

pack-priv String
public Module

Returns:

the module
getModule
(final ModuleIdentifier
the module identifier
identifier
)

Deprecated Use getModule(String) instead.
Get the module with the given identifier from the module loader used by this module.
public Module

Returns:

the module
getModule
(final String
the module name
name
)

Get the module with the given identifier from the module loader used by this module.

public static Module

Returns:

the module
getModuleFromCallerModuleLoader
(final ModuleIdentifier
the module identifier
identifier
)

Deprecated Use getModuleFromCallerModuleLoader(String) instead.
Get a module from the current module loader.
public static Module

Returns:

the module
getModuleFromCallerModuleLoader
(final String
the module name
name
)

Get a module from the current module loader.

public ModuleLoader

Returns:

the module loader of this module
getModuleLoader
()

Get the module loader which created this module.

public static ModuleLogger

Returns:

the module logger
getModuleLogger
()

Get the logger used by the module system.

public String

Returns:

this module's name
getName
()

Get this module's name.

pack-priv Package
getPackage(final String name)

pack-priv Package[]
pack-priv Map<String, List<LocalLoader>>
pack-priv Map<String, List<LocalLoader>>
public PermissionCollection

Returns:

the module permission collection
getPermissionCollection
()

Get the module's configured permission collection.

public static String

Returns:

the platform identifier
getPlatformIdentifier
()

Get the platform identifier.

public static ModulesPrivateAccess
getPrivateAccess()

Private access for module internal code.

public String

Returns:

the property value
getProperty
(String
the property name
name
)

Get the property with the given name, or null if none was defined.

public String

Returns:

the property value
getProperty
(String
the property name
name
,
String
the default value
defaultVal
)

Get the property with the given name, or a default value if none was defined.

public List<String>

Returns:

the property names list
getPropertyNames
()

Get a copy of the list of property names.

pack-priv URL

Returns:

the resource URL, or null if not found
getResource
(final String
the resource name
name
)

Load a resource from a local loader.

pack-priv InputStream

Returns:

the resource stream, or null if not found
getResourceAsStream
(final String
the resource name
name
)

Load a resource from a local loader.

pack-priv Enumeration<URL>

Returns:

the enumeration of all the matching resource URLs (may be empty)
getResources
(final String
the resource name
name
)

Load all resources of a given name from a local loader.

public static long

Returns:

start time of Module.class load
getStartTime
()

Return the start time in millis when Module.class was loaded.

public static ModuleLoader

Returns:

the system module loader
getSystemModuleLoader
()

Get the system module loader.

public Version

Returns:

the module version, or null if none was set
getVersion
()

Get the module version.

public Iterator<Resource>

Returns:

the iterator
globResources
(final String
the glob to apply
glob
)

Enumerate all imported resources in this module which match the given glob expression.

pack-priv static void
public Iterator<Resource>

Returns:

the resource iterator (possibly empty)
iterateResources
(final PathFilter
the filter to apply to the search
filter
)

Enumerate all the imported resources in this module, subject to a path filter.

public static Class<?>

Returns:

the class
loadClassFromBootModuleLoader
(final ModuleIdentifier
the identifier of the module from which the class should be loaded
moduleIdentifier
,
final String
the class name to load
className
)

Load a class from a module in the system module loader.
public static Class<?>

Returns:

the class
loadClassFromBootModuleLoader
(final String
the name of the module from which the class should be loaded
name
,
final String
the class name to load
className
)

Load a class from a module in the system module loader.

public static Class<?>

Returns:

the class
loadClassFromCallerModuleLoader
(final ModuleIdentifier
the identifier of the module from which the class should be loaded
moduleIdentifier
,
final String
the class name to load
className
)

Load a class from a module in the caller's module loader.
public static Class<?>

Returns:

the class
loadClassFromCallerModuleLoader
(final String
the name of the module from which the class should be loaded
name
,
final String
the class name to load
className
)

Load a class from a module in the caller's module loader.

pack-priv Class<?>

Returns:

the class
loadModuleClass
(final String
the class name
className
,
final boolean
true to resolve the class after definition
resolve
)

Load a class from a local loader.

public <
the service type
S
>
ServiceLoader<S>

Returns:

the service loader
loadService
(Class<S>
the service type class
serviceType
)

Load a service loader from this module.

public <
the service type
S
>
ServiceLoader<S>

Returns:

the service loader
loadServiceDirectly
(Class<S>
the service type class
serviceType
)

Load a service loader from this module, without looking at dependencies.

public static <
the the service type
S
>
ServiceLoader<S>

Returns:

the loaded service from the caller's module
loadServiceFromCallerModuleLoader
(ModuleIdentifier
the module identifier containing the service loader
identifier
,
Class<S>
the service type class
serviceType
)

Load a service loader from a module in the caller's module loader.
public static <
the the service type
S
>
ServiceLoader<S>

Returns:

the loaded service from the caller's module
loadServiceFromCallerModuleLoader
(String
the module name containing the service loader
name
,
Class<S>
the service type class
serviceType
)

Load a service loader from a module in the caller's module loader.

private static PermissionCollection
pack-priv static String

Returns:

the parent path
pathOf
(final String
the resource name
resourceName
)

Get the path name of a resource.

pack-priv static String

Returns:

the parent path
pathOfClass
(final String
the binary name of the class
className
)

Get the path name of a class.

public static void
registerContentHandlerFactoryModule(Module
the module to add
module
)

Register an additional module which contains content handlers.

public static void
registerURLStreamHandlerFactoryModule(Module
the module to add
module
)

Register an additional module which contains URL handlers.

pack-priv void
public void
run(final String[]
the arguments to pass
args
)

Run a module's main class, if any.

public void
run(final String
the class name to run (must not be null)
className
,
final String[]
the arguments to pass
args
)

Run the given main class in this module.

pack-priv void
setDependencies(final List<DependencySpec> dependencySpecs)

pack-priv void
setDependencies(final DependencySpec[] dependencySpecs)

public static void
setModuleLogger(final ModuleLogger
the new logger, must not be null
logger
)

Change the logger used by the module system.

public String

Returns:

the string representation
toString
()

Overrides java.lang.Object.toString.

Get the string representation of this module.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait