* registration of a ClassFileTransformer. In such case, the deployer should either fail
* deployment or revert to a mode without the byteocode enhancement feature.
*/
public void addTransformer(ClassFileTransformer transformer) {
InstrumentableClassLoader icl = InstrumentableClassLoader.class.cast(getFinalClassLoader());
String isComposite = getAppProps().getProperty(ServerTags.IS_COMPOSITE);
if (Boolean.valueOf(isComposite) && icl instanceof URLClassLoader) {
URLClassLoader urlCl = (URLClassLoader)icl;
boolean isAppLevel = (getParentContext() == null);
if (isAppLevel) {
// for ear lib PUs, let's install the
// tranformers with the EarLibClassLoader
icl = InstrumentableClassLoader.class.cast(urlCl.getParent().getParent());
} else {
// for modules inside the ear, let's install the
// transformers with the EarLibClassLoader in
// addition to installing them to module classloader
ClassLoader libCl = urlCl.getParent().getParent();
if (!(libCl instanceof URLClassLoader)) {
// web module
libCl = libCl.getParent();
}
if (libCl instanceof URLClassLoader) {
InstrumentableClassLoader libIcl = InstrumentableClassLoader.class.cast(libCl);
libIcl.addTransformer(transformer);
}
}
}
icl.addTransformer(transformer);