}
@Override
public byte[] transform(final ClassLoader loader, final String className, final Class<?> classBeingRedefined, final ProtectionDomain protectionDomain, final byte[] classfileBuffer) throws IllegalClassFormatException {
final Environment environment = CurrentEnvironment.getEnvironment();
if (integrationClassTriggers.containsKey(className)) {
integrationClassloader.add(loader);
// we need to load the class in another thread
// otherwise it will not go through the javaagent
final Extension extension = integrationClassTriggers.get(className);
if (!loadedClassChangeAwares.contains(extension.getClassChangeAwareName())) {
loadedClassChangeAwares.add(extension.getClassChangeAwareName());
try {
Class<?> clazz = Class.forName(extension.getClassChangeAwareName(), true, loader);
final Object intance = clazz.newInstance();
if (intance instanceof ClassChangeAware) {
ClassChangeNotifier.instance().add((ClassChangeAware) intance);
}
final String newEnv = extension.getEnvironment();
if (newEnv != null) {
final Class<?> envClass = Class.forName(newEnv, true, loader);
final Environment newEnvironment = (Environment) envClass.newInstance();
if (environment instanceof DefaultEnvironment) {
CurrentEnvironment.setEnvironment(newEnvironment);
} else {
Logger.getLogger(MainTransformer.class).error("Could not set environment to " + newEnvironment + " it has already been changed to " + environment);
}