public BytecodeTransformer getBytecodeTransformer() { if (configurators.isEmpty()) return super.getBytecodeTransformer(); else return new BytecodeTransformer() { public byte[] transform(String className, byte[] bytecode) { byte[] transformedBytecode= bytecode; for (InstrumentationDragomeConfigurator configurator : configurators) if (configurator.isEnabled()) transformedBytecode= configurator.getBytecodeTransformer().transform(className, transformedBytecode); return transformedBytecode; } public boolean requiresTransformation(String className) { boolean transform= false; for (InstrumentationDragomeConfigurator configurator : configurators) if (configurator.isEnabled()) transform|= configurator.getBytecodeTransformer().requiresTransformation(className); return transform; } }; }
public byte[] transform(String className, byte[] bytecode) { byte[] transformedBytecode= bytecode; for (InstrumentationDragomeConfigurator configurator : configurators) if (configurator.isEnabled()) transformedBytecode= configurator.getBytecodeTransformer().transform(className, transformedBytecode); return transformedBytecode; }
public boolean requiresTransformation(String className) { boolean transform= false; for (InstrumentationDragomeConfigurator configurator : configurators) if (configurator.isEnabled()) transform|= configurator.getBytecodeTransformer().requiresTransformation(className); return transform; } };
public ClassLoader getNewClassloaderInstance(ClassLoader parent, ClassLoader current) { instrumentationClassLoader= new DragomeInstrumentationClassLoader(new URL[0], parent, current, getBytecodeTransformer(), getLoadedFromParent()); instrumentationClassLoader.setBytecodes(bytecodes); return instrumentationClassLoader; }