openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fa...@apache.org
Subject svn commit: r683075 - in /openjpa: branches/1.2.x/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancerAgent.java trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancerAgent.java
Date Wed, 06 Aug 2008 01:28:27 GMT
Author: fancy
Date: Tue Aug  5 18:28:26 2008
New Revision: 683075

URL: http://svn.apache.org/viewvc?rev=683075&view=rev
Log:
OPENJPA-674 javaagent enhancer (PCEnhancerAgent) ignores persistence units after the first
in persistence.xml
committing PCEnhancerAgent.patch provided by Dinkar Rao

Modified:
    openjpa/branches/1.2.x/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancerAgent.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancerAgent.java

Modified: openjpa/branches/1.2.x/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancerAgent.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.2.x/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancerAgent.java?rev=683075&r1=683074&r2=683075&view=diff
==============================================================================
--- openjpa/branches/1.2.x/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancerAgent.java
(original)
+++ openjpa/branches/1.2.x/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancerAgent.java
Tue Aug  5 18:28:26 2008
@@ -20,6 +20,8 @@
 
 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,30 +92,39 @@
 
     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(Configuration.INIT_STATE_FREEZING);
-        conf.instantiateAll(); // avoid threading issues
-
-        PCClassFileTransformer transformer = new PCClassFileTransformer
-            (conf.newMetaDataRepositoryInstance(), opts, tmpLoader);
-        inst.addTransformer(transformer);
+    	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, clonedOptions);
+    		// 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(Configuration.INIT_STATE_FREEZING);
+    		conf.instantiateAll(); // avoid threading issues
+
+    		PCClassFileTransformer transformer = new PCClassFileTransformer
+    		    (conf.newMetaDataRepositoryInstance(), clonedOptions,
+    		    tmpLoader);
+    		inst.addTransformer(transformer);
+    		conf.close();
+    	}
     }
 }

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancerAgent.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancerAgent.java?rev=683075&r1=683074&r2=683075&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancerAgent.java
(original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancerAgent.java
Tue Aug  5 18:28:26 2008
@@ -20,6 +20,8 @@
 
 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,30 +92,39 @@
 
     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(Configuration.INIT_STATE_FREEZING);
-        conf.instantiateAll(); // avoid threading issues
-
-        PCClassFileTransformer transformer = new PCClassFileTransformer
-            (conf.newMetaDataRepositoryInstance(), opts, tmpLoader);
-        inst.addTransformer(transformer);
+    	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, clonedOptions);
+    		// 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(Configuration.INIT_STATE_FREEZING);
+    		conf.instantiateAll(); // avoid threading issues
+
+    		PCClassFileTransformer transformer = new PCClassFileTransformer
+    		    (conf.newMetaDataRepositoryInstance(), clonedOptions,
+    		    tmpLoader);
+    		inst.addTransformer(transformer);
+    		conf.close();
+    	}
     }
 }



Mime
View raw message