mirror of https://github.com/apache/openjpa.git
OPENJPA-674 javaagent enhancer (PCEnhancerAgent) ignores persistence units after the first in persistence.xml
committing PCEnhancerAgent.patch provided by Dinkar Rao git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@683075 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a6216d10db
commit
e97d6d1598
|
@ -20,6 +20,8 @@ package org.apache.openjpa.enhance;
|
|||
|
||||
import java.lang.instrument.Instrumentation;
|
||||
import java.security.AccessController;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.openjpa.conf.OpenJPAConfiguration;
|
||||
import org.apache.openjpa.conf.OpenJPAConfigurationImpl;
|
||||
|
@ -90,8 +92,13 @@ public class PCEnhancerAgent {
|
|||
|
||||
private static void registerClassLoadEnhancer(Instrumentation inst,
|
||||
Options opts) {
|
||||
List<String> anchors = Configurations.
|
||||
getFullyQualifiedAnchorsInPropertiesLocation(opts);
|
||||
for (String a : anchors) {
|
||||
Options clonedOptions = (Options) opts.clone();
|
||||
clonedOptions.setProperty("properties", a);
|
||||
OpenJPAConfiguration conf = new OpenJPAConfigurationImpl();
|
||||
Configurations.populateConfiguration(conf, opts);
|
||||
Configurations.populateConfiguration(conf, clonedOptions);
|
||||
// don't allow connections
|
||||
conf.setConnectionUserName(null);
|
||||
conf.setConnectionPassword(null);
|
||||
|
@ -105,7 +112,8 @@ public class PCEnhancerAgent {
|
|||
.doPrivileged(J2DoPrivHelper.getContextClassLoaderAction())
|
||||
));
|
||||
conf.setClassResolver(new ClassResolver() {
|
||||
public ClassLoader getClassLoader(Class context, ClassLoader env) {
|
||||
public ClassLoader getClassLoader(Class context,
|
||||
ClassLoader env) {
|
||||
return tmpLoader;
|
||||
}
|
||||
});
|
||||
|
@ -113,7 +121,10 @@ public class PCEnhancerAgent {
|
|||
conf.instantiateAll(); // avoid threading issues
|
||||
|
||||
PCClassFileTransformer transformer = new PCClassFileTransformer
|
||||
(conf.newMetaDataRepositoryInstance(), opts, tmpLoader);
|
||||
(conf.newMetaDataRepositoryInstance(), clonedOptions,
|
||||
tmpLoader);
|
||||
inst.addTransformer(transformer);
|
||||
conf.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue