站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > JBoss 4.0.1 sp1 common API Documentation 英文版文档

Translator (JBoss/Common API) - JBoss 4.0.1 sp1 common API Documentation 英文版文档


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: 1.4 $
Author:
Scott.Stark@jboss.org

Method Summary
 byte[] transform(ClassLoader loader, String className, Class classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer)
          Optionally transform the supplied class file and return a new replacement class file.
 void unregisterClassLoader(ClassLoader loader)
          Called to indicate that the ClassLoader is being discarded by the server.
 

Method Detail

transform

public byte[] transform(ClassLoader loader,
                        String className,
                        Class classBeingRedefined,
                        ProtectionDomain protectionDomain,
                        byte[] classfileBuffer)
                 throws 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 ClassLoader.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 input classfileBuffer into it, along with all desired transformations. The input classfileBuffer must not be modified.

Parameters:
loader - - the defining loader of the class to be transformed, may be null if the bootstrap loader
className - - the fully-qualified name of the class
classBeingRedefined - - if this is a redefine, the class being redefined, otherwise null
protectionDomain - - the protection domain of the class being defined or redefined
classfileBuffer - - 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:
Exception - - if the input does not represent a well-formed class file

unregisterClassLoader

public void unregisterClassLoader(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.


Copyright © 2002 JBoss Group, LLC. All Rights Reserved.