com.ibm.ws.classloading
Interface ClassLoadingService
- public interface ClassLoadingService
Method Summary
Modifier and Type | Method and Description |
---|---|
|
createBundleAddOnClassLoader(java.util.List<java.io.File> classPath,java.lang.ClassLoader gwClassLoader,ClassLoaderConfiguration config)
This method creates a classloader for use from within a bundle.
|
|
createChildClassLoader(java.util.List<Container> classpath,ClassLoaderConfiguration config)
This method creates a lower level class loader, such as a module class loader.
|
createClassLoaderConfiguration()
|
|
createGatewayConfiguration()
|
|
createIdentity(java.lang.String domain,java.lang.String id)
This creates an immutable ClassLoaderIdentity.
|
|
|
createThreadContextClassLoader(java.lang.ClassLoader applicationClassLoader)
This will augment the application class loader with the ability to see more internal packages.
|
|
createTopLevelClassLoader(java.util.List<Container> classPath,GatewayConfiguration gwConfig,ClassLoaderConfiguration config)
This method creates a top level class loader.
|
|
destroyThreadContextClassLoader(java.lang.ClassLoader unifiedClassLoader)
This will destroy the thread context class loader.
|
|
getShadowClassLoader(java.lang.ClassLoader loader)
Attempt to create a
ClassLoader that can be used to introspect
the classes on the class path of the provided ClassLoader without
loading them directly.
|
|
getSharedLibraryClassLoader(SharedLibrary lib)
Create or retrieve the shared class loader for a shared library.
|
|
registerTransformer(ClassTransformer transformer,java.lang.ClassLoader loader)
Attempt to register a
ClassTransformer with a ClassLoader .
|
|
unify(java.lang.ClassLoader parent,java.lang.ClassLoader... classloaders)
This method builds a classloader that delegates to the provided classloaders in order.
|
|
unregisterTransformer(ClassTransformer transformer,java.lang.ClassLoader loader)
Attempt to unregister a
ClassTransformer from a ClassLoader .
|
Method Detail
createTopLevelClassLoader
- java.lang.ClassLoader createTopLevelClassLoader( java.util.List<Container> classPath,
- GatewayConfiguration gwConfig,
- ClassLoaderConfiguration config)
Parameters:
classPath
- A list of URLs that should be used to load classes gwConfig
- The desired configuration for the gateway. config
- The desired configuration of the ClassLoader. Returns:
The created class loader.
createBundleAddOnClassLoader
- java.lang.ClassLoader createBundleAddOnClassLoader( java.util.List<java.io.File> classPath,
- java.lang.ClassLoader gwClassLoader,
- ClassLoaderConfiguration config)
This method creates a classloader for use from within a bundle. If a bundle needs to
invoke shared libraries specified in config, for example, it can use this method to
create a loader for the shared libraries which will also provide access to the classes
within the bundle.
Once the configuration objects are passed in, they belong to the ClassLoadingService. They should not be modified or re-used for other invocations.
Parameters:
classPath
- A list of URLs that should be used to load classes gwClassLoader
- The gateway ClassLoader. config
- The desired configuration of the ClassLoader. Returns:
The created class loader.
createChildClassLoader
- java.lang.ClassLoader createChildClassLoader( java.util.List<Container> classpath,
- ClassLoaderConfiguration config)
This method creates a lower level class loader, such as a module class loader. It has a parent
which could be a class loader created by a call to createTopLevelClassLoader, or createChildClassLoader.
The ClassLoaderConfiguration must have a parent set in this case.
Once the configuration objects are passed in, they belong to the ClassLoadingService. They should not be modified or re-used for other invocations.
Parameters:
classpath
- A list of URLs that should be used to load classes config
- The desired configuration of the ClassLoader. Returns:
the created class loader.
createGatewayConfiguration
- GatewayConfiguration createGatewayConfiguration( )
Returns:
A clean gateway configuration
createClassLoaderConfiguration
- ClassLoaderConfiguration createClassLoaderConfiguration( )
Returns:
A clean class loader configuration.
createIdentity
- ClassLoaderIdentity createIdentity( java.lang.String domain,
- java.lang.String id)
This creates an immutable ClassLoaderIdentity. Multiple calls to
createIdentity with the same parameters may result in the same object.
Parameters:
domain
- a unique name indicating the domain (i.e. the user) of the class loader id
- an id unique within the domain Returns:
a new ClassLoaderIdentity composed of the domain and the id
getShadowClassLoader
- java.lang.ClassLoader getShadowClassLoader( java.lang.ClassLoader loader)
Attempt to create a
ClassLoader
that can be used to introspect
the classes on the class path of the provided ClassLoader
without
loading them directly. The returned ClassLoader
should be
discarded as early as possible to allow it and all its classes to be
garbage-collected.
Parameters:
loader
- the class loader to clone Returns:
a new
ClassLoader
or null
if loader
was not created by this service See Also:
javax.persistence.spi.PersistenceUnitInfo#getNewTempClassLoader()
registerTransformer
- boolean registerTransformer(ClassTransformer transformer,
- java.lang.ClassLoader loader)
Attempt to register a
ClassTransformer
with a ClassLoader
.
Parameters:
transformer
- the ClassTransformer
to be registered loader
- the ClassLoader
to be modified Returns:
true
if the operation succeeded, false
if the ClassLoader
was not created by this ClassLoadingService
. unregisterTransformer
- boolean unregisterTransformer(ClassTransformer transformer,
- java.lang.ClassLoader loader)
Attempt to unregister a
ClassTransformer
from a ClassLoader
.
Parameters:
transformer
- the ClassTransformer
to be unregistered loader
- the ClassLoader
to be modified Returns:
true
if loader
was modified,
false
if it was not a classloader created by this service
or if transformer
was never registered with it. unify
- java.lang.ClassLoader unify(java.lang.ClassLoader parent,
- java.lang.ClassLoader... classloaders)
This method builds a classloader that delegates to the provided classloaders in order. It
adds the parent classloader as the parent so it is consulted first and then consults the
follow on ones when a class load fails.
Parameters:
parent
- the first classloader to query classloaders
- the class loaders to unify, Returns:
a unified classloader
getSharedLibraryClassLoader
- java.lang.ClassLoader getSharedLibraryClassLoader( SharedLibrary lib)
Create or retrieve the shared class loader for a shared library.
Parameters:
lib
- the shared library to create a class loader for Returns:
the unique clas loader for the provided library
createThreadContextClassLoader
- java.lang.ClassLoader createThreadContextClassLoader( java.lang.ClassLoader applicationClassLoader)
This will augment the application class loader with the ability to see more internal packages. These packages are ones that contain classes that are loaded from the context
class loader so are needed to be visible but shouldn't be available through the main application class loader.
Parameters:
applicationClassLoader
- The application class loader to augment Returns:
The new class loader that can be set as the thread context class loader
destroyThreadContextClassLoader
- void destroyThreadContextClassLoader( java.lang.ClassLoader unifiedClassLoader)
This will destroy the thread context class loader. If the thread
context class loader contains URLClassLoader, it may hold the jar
file lock when the caching is enabled on Windows platform.
So we need guarantee the resources could be released here.
Parameters:
unifiedClassLoader
- The thread context class loader
Once the configuration objects are passed in, they belong to the ClassLoadingService. They should not be modified or re-used for other invocations.