}
}
private static void registerClassLoadEnhancer(Instrumentation inst,
Options opts) {
OpenJPAConfiguration conf = new OpenJPAConfigurationImpl();
Configurations.populateConfiguration(conf, opts);
// don't allow connections
conf.setConnectionUserName(null);
conf.setConnectionPassword(null);
conf.setConnectionURL(null);
conf.setConnectionDriverName(null);
conf.setConnectionFactoryName(null);
// set single class resolver
final ClassLoader tmpLoader = (ClassLoader) AccessController
.doPrivileged(J2DoPrivHelper
.newTemporaryClassLoaderAction((ClassLoader) AccessController
.doPrivileged(J2DoPrivHelper.getContextClassLoaderAction())
));
conf.setClassResolver(new ClassResolver() {
public ClassLoader getClassLoader(Class context, ClassLoader env) {
return tmpLoader;
}
});
conf.setReadOnly(true);
conf.instantiateAll(); // avoid threading issues
PCClassFileTransformer transformer = new PCClassFileTransformer
(conf.newMetaDataRepositoryInstance(), opts, tmpLoader);
inst.addTransformer(transformer);
}