public interface Integration
Provides hooks for integrating JRebel with custom containers, frameworks and classloaders.
To use it acquire an instance from IntegrationFactory
A typical (classloader) integration will look like this:
class MyClassLoader extends URLClassLoader {
public MyClassLoader() {
...
IntegrationFactory.getInstance().registerClassLoader(
this,
new FindResourceClassResourceSource(this)));
}
...
public Class findClass(String classname) {
synchronized(classloader) {
Class result =
classloader.findLoadedClass(classname);
if (result != null)
return result;
result =
IntegrationFactory.getInstance()
.findReloadableClass(this, classname);
if (result != null)
return result;
}
...
}
}
You can use the addIntegrationProcessor(String, ClassBytecodeProcessor) and
addIntegrationProcessor(String[], ClassBytecodeProcessor)
and makeTransparent(String) instrument specific classes to enhance their behaviour
with JRebel.
You can use #addManagedPreProcessor(ClassBytecodeProcessor) to register a preprocessor for
all classes managed by JRebel e.g. to enable container-specific AOP
IntegrationFactory,
ServletIntegration,
Configuration,
Reloader,
Logger,
Plugin| Modifier and Type | Method and Description |
|---|---|
void |
addAfterMainCallback(AfterMainCallback callback)
Registers a callback that will be invoked after the main method is called.
|
void |
addBootClassProcessor(String className,
ClassBytecodeProcessor processor)
Adds a bytecode processor for the given class in boot classloader.
|
void |
addClassLoaderDestructionListener(ClassLoader cl,
ClassLoaderDestructionListener listener)
Registers a call back invoked when a given class loader is being destroyed.
|
void |
addIntegrationProcessor(ClassBytecodeProcessor processor,
boolean managedOnly)
Adds a bytecode processor for all classes.
|
void |
addIntegrationProcessor(ClassLoader cl,
ClassBytecodeProcessor processor)
Adds a bytecode processor for the given classloader.
|
void |
addIntegrationProcessor(ClassLoader cl,
ClassBytecodeProcessor processor,
boolean managedOnly)
AAdds a bytecode processor for the given classloader.
|
void |
addIntegrationProcessor(ClassLoader cl,
String[] classNames,
ClassBytecodeProcessor processor)
Adds a bytecode processor for the set of given classes in the given classloader.
|
void |
addIntegrationProcessor(ClassLoader cl,
String className,
ClassBytecodeProcessor processor)
Adds a bytecode processor for the given class in the given classloader.
|
void |
addIntegrationProcessor(String[] classNames,
ClassBytecodeProcessor processor)
Adds a bytecode processor for the set of given classes.
|
void |
addIntegrationProcessor(String className,
ClassBytecodeProcessor processor)
Adds a bytecode processor for the given class.
|
Class<?> |
defineReloadableClass(ClassLoader cl,
String className,
byte[] bytecode,
ProtectionDomain protectionDomain)
(Re)defines a class managed by JRebel.
|
void |
disablePlugins(ClassLoader cl)
Disable running plugins in given class loader.
|
void |
disableReloadDetection(ClassLoader cl)
Disable class reload check in given class loader.
|
void |
disableReloading(ClassLoader cl)
Disable class reloading in given class loader.
|
void |
disableSecurityManager()
Disables the SecurityManager in the current thread.
|
void |
enableSecurityManager()
Re-enables the disabled SecurityManager in the current thread.
|
URL |
findRebelResource(ClassLoader cl,
String name)
Resolves resources only managed by JRebel.
|
Enumeration<URL> |
findRebelResources(ClassLoader cl,
String name)
Resolves resources only managed by JRebel.
|
Class<?> |
findReloadableClass(ClassLoader cl,
String className)
Resolves classes managed by JRebel.
|
URL |
findResource(ClassLoader cl,
String name)
Resolves resources managed by JRebel.
|
Enumeration<URL> |
findResources(ClassLoader cl,
String name)
Resolves resources managed by JRebel.
|
RebelSource[] |
getRebelSources(ClassLoader cl)
Returns the additional class path of the given
ClassLoader
managed by JRebel. |
URL[] |
getRebelURLs(ClassLoader cl)
Returns the additional class path of the given
ClassLoader
managed by JRebel. |
URL[] |
getRebelURLs(ClassLoader cl,
boolean onlyFullMatch)
Returns the additional class path of the given
ClassLoader
managed by JRebel. |
ScanHelper |
getScanHelper(ClassLoader cl,
String name)
Returns helper object to perform class path scanning in the given
ClassLoader. |
URL |
getTransparentResource(ClassLoader cl,
String name)
Returns the original resource with given name.
|
Enumeration<URL> |
getTransparentResources(ClassLoader cl,
String name)
Returns the original resources with given name.
|
boolean |
isCheckingPluginDependencies(ClassLoader cl)
Returns
true if
Plugin.checkDependencies(ClassLoader, ClassResourceSource)
is being called for the given class loader. |
boolean |
isFilteringMissingMethods()
Returns
true if we are filtering out parent class methods for OSGI, that the class itself can not see. |
boolean |
isPartnerPlatform()
Validates if JRebel is enabled on a partner's platform
|
boolean |
isResourceReplaced(ClassLoader cl,
String name)
Returns
true if the given resource is managed by JRebel. |
void |
makeTransparent(String className)
Deprecated.
|
void |
recordClassResource(ClassLoader cl,
String className,
URL url)
Record location of found class.
|
void |
redefineClasses(ClassDefinition... classDefinitions)
Redefine a set of classes managed by JRebel.
|
boolean |
redefineReloadableClass(Class<?> klass,
byte[] bytecode)
Redefines a class managed by JRebel.
|
void |
registerClassLoader(ClassLoader cl,
ClassResourceSource cfs)
Registers a
ClassLoader with JRebel associating with it
the class-to-file resolution strategy provided by ClassFileSource. |
void |
registerModularClassLoader(ClassLoader cl)
Enable special handling for
ClassLoader systems with non-transitive class loading e.g. |
void |
reinitializeClassLoader(ClassLoader cl)
Reinitializes the
ClassLoader with JRebel. |
void |
removeClassLoaderDestructionListener(ClassLoaderDestructionListener listener)
Removes a call back invoked when a given class loader is being destroyed.
|
void |
removeIntegrationProcessor(ClassBytecodeProcessor processor)
Remove bytecode processor.
|
void |
removeIntegrationProcessors(ClassLoader cl)
Remove bytecode processors that are loaded by the ClassLoader
|
void |
setPartnerPlatform(boolean flag)
Indicate that JRebel is running on a partner's platform
|
void |
unregisterClassLoader(ClassLoader cl)
Unregisters the
ClassLoader from JRebel. |
void |
useSeparateCacheForClassesAndResources(ClassLoader cl)
Cache results for class and resource request separately.
|
void registerClassLoader(ClassLoader cl, ClassResourceSource cfs)
ClassLoader with JRebel associating with it
the class-to-file resolution strategy provided by ClassFileSource. It
is necessary to do this before any calls to findReloadableClass(ClassLoader, String),
the best place is usually the constructor.cl - The custom class loader being integrated.cfs - The class-to-file resolution strategy source.ClassResourceSourcevoid reinitializeClassLoader(ClassLoader cl)
ClassLoader with JRebel.
This should be called if the class path of the given ClassLoader was updated.
cl - The custom class loader being integrated.void unregisterClassLoader(ClassLoader cl)
ClassLoader from JRebel.
It is recommended to do this in case the corresponding ClassLoader is destroyed
(e.g. the web application is undeployed).cl - The custom class loader being integrated.void registerModularClassLoader(ClassLoader cl)
ClassLoader systems with non-transitive class loading e.g. OSGI, NetBeans.
This method does not replace registerClassLoader(ClassLoader, ClassResourceSource).cl - The custom class loader being integrated.URL[] getRebelURLs(ClassLoader cl)
ClassLoader
managed by JRebel.
Same as getRebelURLs(cl, false).
cl - The custom class loader being integrated.ClassLoader
or null if nothing found.URL[] getRebelURLs(ClassLoader cl, boolean onlyFullMatch)
ClassLoader
managed by JRebel.cl - The custom class loader being integrated.onlyFullMatch - whether to only return locations with no custom patterns.ClassLoader
or null if nothing found.RebelSource[] getRebelSources(ClassLoader cl)
ClassLoader
managed by JRebel.cl - The custom class loader being integrated.ClassLoader
or null if nothing found.ScanHelper getScanHelper(ClassLoader cl, String name)
ClassLoader.
NOTE: this api is experimental and may be removed or changed in future
versions.cl - The class loader used to find resources to scan.name - name of resource to start scanning from.null if not available.Class<?> findReloadableClass(ClassLoader cl, String className) throws ClassNotFoundException
ClassNotFoundException if class does not exist
and the non-JRebel class loading should be skipped.cl - The custom class loader being integrated.classname - The public class name.ClassNotFoundException - if class does not exist.#defineReloadableClass(ClassLoader, String, byte[])Class<?> defineReloadableClass(ClassLoader cl, String className, byte[] bytecode, ProtectionDomain protectionDomain)
This method may be called for loading as well as reloading the class.
The defined class will only be reloaded if this method is called again.
Even if the class was first loaded by findReloadableClass(ClassLoader, String)
the resolved class resource will not be checked for updates.
cl - The custom class loader being integrated.className - The public class name.bytecode - class bytes.protectionDomain - The ProtectionDomain of the class (may be null).boolean redefineReloadableClass(Class<?> klass, byte[] bytecode)
klass - Class managed by JRebel.bytecode - class bytes.true if the class was managed by JRebel and redefined.void redefineClasses(ClassDefinition... classDefinitions)
classDefinitions - Array of ClassDefinition objects containing the Class and new class-bytesboolean isResourceReplaced(ClassLoader cl, String name)
true if the given resource is managed by JRebel.
In that case resources can be resolved using the corresponding methods of the Integration.
If any of these methods returns a null it must be returned by the ClassLoader as well.
cl - The custom class loader being integrated.name - The public resource name.true if the given resource is managed by JRebel.URL findResource(ClassLoader cl, String name)
cl - The custom class loader being integrated.name - The public resource name.URL findRebelResource(ClassLoader cl, String name)
cl - The custom class loader being integrated.name - The public resource name.Enumeration<URL> findResources(ClassLoader cl, String name)
cl - The custom class loader being integrated.name - The public resource name.Enumeration<URL> findRebelResources(ClassLoader cl, String name)
cl - The custom class loader being integrated.name - The public resource name.Enumeration<URL> getTransparentResources(ClassLoader cl, String name)
cl - The custom class loader being integrated.name - The resource name.URL getTransparentResource(ClassLoader cl, String name)
cl - The custom class loader being integrated.name - The resource name.void recordClassResource(ClassLoader cl, String className, URL url)
cl - The custom class loader being integrated.name - The public class name.url - URL of class resource.void useSeparateCacheForClassesAndResources(ClassLoader cl)
cl - The custom class loader being integrated.void makeTransparent(String className)
void addIntegrationProcessor(ClassLoader cl, String className, ClassBytecodeProcessor processor)
void addIntegrationProcessor(String className, ClassBytecodeProcessor processor)
void addIntegrationProcessor(ClassLoader cl, ClassBytecodeProcessor processor)
void addIntegrationProcessor(ClassBytecodeProcessor processor, boolean managedOnly)
If managedOnly is true the processor will only be run for the
classes managed by JRebel. This is useful to enable processing usually done in the
class loader findClass() method, e.g. the JBoss AOP.
void addIntegrationProcessor(ClassLoader cl, ClassBytecodeProcessor processor, boolean managedOnly)
If managedOnly is true the processor will only be run for the
classes managed by JRebel. This is useful to enable processing usually done in the
class loader findClass() method, e.g. the JBoss AOP.
void addIntegrationProcessor(String[] classNames, ClassBytecodeProcessor processor)
void addIntegrationProcessor(ClassLoader cl, String[] classNames, ClassBytecodeProcessor processor)
void removeIntegrationProcessor(ClassBytecodeProcessor processor)
void removeIntegrationProcessors(ClassLoader cl)
void addBootClassProcessor(String className, ClassBytecodeProcessor processor)
void addClassLoaderDestructionListener(ClassLoader cl, ClassLoaderDestructionListener listener)
cl - The custom class loader being integrated.listener - class loader destruction listener.void removeClassLoaderDestructionListener(ClassLoaderDestructionListener listener)
listener - class loader destruction listener.boolean isCheckingPluginDependencies(ClassLoader cl)
true if
Plugin.checkDependencies(ClassLoader, ClassResourceSource)
is being called for the given class loader.
During the given process no class path entries should be altered.
boolean isFilteringMissingMethods()
true if we are filtering out parent class methods for OSGI, that the class itself can not see.
Used to disable class resource finding in a classloader if it can find the class as Resource but can not load that class.void setPartnerPlatform(boolean flag)
flag - boolean isPartnerPlatform()
void disablePlugins(ClassLoader cl)
void disableReloading(ClassLoader cl)
void disableReloadDetection(ClassLoader cl)
void addAfterMainCallback(AfterMainCallback callback)
void disableSecurityManager()
void enableSecurityManager()
Copyright © 2015. All rights reserved.