Package org.jboss.util.loading
Interface Translator
-
public interface Translator
An interface for transforming byte code before Class creation. This is compatible with the JDK1.5 java.lang.instrument.ClassFileTransformer proposal.- Version:
- $Revision$
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description byte[]
transform(java.lang.ClassLoader loader, java.lang.String className, java.lang.Class<?> classBeingRedefined, java.security.ProtectionDomain protectionDomain, byte[] classfileBuffer)
Optionally transform the supplied class file and return a new replacement class file.void
unregisterClassLoader(java.lang.ClassLoader loader)
Called to indicate that the ClassLoader is being discarded by the server.
-
-
-
Method Detail
-
transform
byte[] transform(java.lang.ClassLoader loader, java.lang.String className, java.lang.Class<?> classBeingRedefined, java.security.ProtectionDomain protectionDomain, byte[] classfileBuffer) throws java.lang.Exception
Optionally transform the supplied class file and return a new replacement class file.If a transformer has been registered with the class loading layer, the transformer will be called for every new class definition. The request for a new class definition is made with defineClass The transformer is called during the processing of the request, before the class file bytes have been verified or applied.
If the implementing method determines that no transformations are needed, it should return
null
. Otherwise, it should create a new byte[] array and copy the inputclassfileBuffer
into it, along with all desired transformations. The inputclassfileBuffer
must not be modified.- Parameters:
loader
- - the defining loader of the class to be transformed, may benull
if the bootstrap loaderclassName
- - the fully-qualified name of the classclassBeingRedefined
- - if this is a redefine, the class being redefined, otherwisenull
protectionDomain
- - the protection domain of the class being defined or redefinedclassfileBuffer
- - the input byte buffer in class file format - must not be modified- Returns:
- a well-formed class file buffer (the result of the transform),
or
null
if no transform is performed. - Throws:
java.lang.Exception
- - if the input does not represent a well-formed class file
-
unregisterClassLoader
void unregisterClassLoader(java.lang.ClassLoader loader)
Called to indicate that the ClassLoader is being discarded by the server.- Parameters:
loader
- - a class loader that has possibly been used previously as an argument to transform.
-
-