类 WeavingTransformer
- java.lang.Object
- org.springframework.instrument.classloading.WeavingTransformer
public class WeavingTransformer extends Object
ClassFileTransformer-based weaver, allowing for a list of transformers to be applied on a class byte array. Normally used inside class loaders.Note: This class is deliberately implemented for minimal external dependencies, since it is included in weaver jars (to be deployed into application servers).
- 从以下版本开始:
- 2.0
- 作者:
- Rod Johnson, Costin Leau, Juergen Hoeller
构造器概要
构造器 构造器 说明 WeavingTransformer(ClassLoader classLoader)
Create a new WeavingTransformer for the given class loader.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 void
addTransformer(ClassFileTransformer transformer)
Add a class file transformer to be applied by this weaver.byte[]
transformIfNecessary(String className, byte[] bytes)
Apply transformation on a given class byte definition.byte[]
transformIfNecessary(String className, String internalName, byte[] bytes, ProtectionDomain pd)
Apply transformation on a given class byte definition.
构造器详细资料
WeavingTransformer
public WeavingTransformer(ClassLoader classLoader)
Create a new WeavingTransformer for the given class loader.- 参数:
classLoader
- the ClassLoader to build a transformer for
方法详细资料
addTransformer
public void addTransformer(ClassFileTransformer transformer)
Add a class file transformer to be applied by this weaver.- 参数:
transformer
- the class file transformer to register
transformIfNecessary
public byte[] transformIfNecessary(String className, byte[] bytes)
Apply transformation on a given class byte definition. The method will always return a non-null byte array (if no transformation has taken place the array content will be identical to the original one).- 参数:
className
- the full qualified name of the class in dot format (i.e. some.package.SomeClass)bytes
- class byte definition- 返回:
- (possibly transformed) class byte definition
transformIfNecessary
public byte[] transformIfNecessary(String className, String internalName, byte[] bytes, ProtectionDomain pd)
Apply transformation on a given class byte definition. The method will always return a non-null byte array (if no transformation has taken place the array content will be identical to the original one).- 参数:
className
- the full qualified name of the class in dot format (i.e. some.package.SomeClass)internalName
- class name internal name in / format (i.e. some/package/SomeClass)bytes
- class byte definitionpd
- protection domain to be used (can be null)- 返回:
- (possibly transformed) class byte definition