geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r937007 - in /geronimo/server/trunk/plugins/openjpa2/geronimo-persistence-jpa20/src/main/java/org/apache/geronimo/persistence: PersistenceUnitGBean.java TransformerWrapper.java
Date Thu, 22 Apr 2010 18:54:39 GMT
Author: djencks
Date: Thu Apr 22 18:54:39 2010
New Revision: 937007

URL: http://svn.apache.org/viewvc?rev=937007&view=rev
Log:
GERONIMO-4680 only transform stuff from the specified bundle

Modified:
    geronimo/server/trunk/plugins/openjpa2/geronimo-persistence-jpa20/src/main/java/org/apache/geronimo/persistence/PersistenceUnitGBean.java
    geronimo/server/trunk/plugins/openjpa2/geronimo-persistence-jpa20/src/main/java/org/apache/geronimo/persistence/TransformerWrapper.java

Modified: geronimo/server/trunk/plugins/openjpa2/geronimo-persistence-jpa20/src/main/java/org/apache/geronimo/persistence/PersistenceUnitGBean.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/openjpa2/geronimo-persistence-jpa20/src/main/java/org/apache/geronimo/persistence/PersistenceUnitGBean.java?rev=937007&r1=937006&r2=937007&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/openjpa2/geronimo-persistence-jpa20/src/main/java/org/apache/geronimo/persistence/PersistenceUnitGBean.java
(original)
+++ geronimo/server/trunk/plugins/openjpa2/geronimo-persistence-jpa20/src/main/java/org/apache/geronimo/persistence/PersistenceUnitGBean.java
Thu Apr 22 18:54:39 2010
@@ -39,7 +39,6 @@ import javax.persistence.spi.Persistence
 import javax.persistence.spi.PersistenceUnitTransactionType;
 import javax.resource.ResourceException;
 import javax.sql.DataSource;
-import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
 import org.apache.geronimo.gbean.GBeanLifecycle;
 import org.apache.geronimo.gbean.SingleElementCollection;
@@ -131,7 +130,7 @@ public class PersistenceUnitGBean implem
                 persistenceXMLSchemaVersion,
                 sharedCacheMode,
                 validationMode,
-                classLoader);
+                classLoader, bundle);
         try {
             Class clazz = classLoader.loadClass(persistenceProviderClassName);
             PersistenceProvider persistenceProvider = (PersistenceProvider) clazz.newInstance();
@@ -257,6 +256,7 @@ public class PersistenceUnitGBean implem
         private final String persistenceXMLSchemaVersion;
         private final SharedCacheMode sharedCacheMode;
         private final ValidationMode validationMode;
+        private final Bundle bundle;
 
 
         public PersistenceUnitInfoImpl(String persistenceUnitName,
@@ -273,7 +273,8 @@ public class PersistenceUnitGBean implem
                                        String persistenceXMLSchemaVersion,
                                        SharedCacheMode sharedCacheMode,
                                        ValidationMode validationMode,
-                                       ClassLoader classLoader) {
+                                       ClassLoader classLoader,
+                                       Bundle bundle) {
 
             this.persistenceUnitName = persistenceUnitName;
             this.persistenceProviderClassName = persistenceProviderClassName;
@@ -296,6 +297,7 @@ public class PersistenceUnitGBean implem
             // This classloader can only be used during PersistenceProvider.createContainerEntityManagerFactory()
calls
             // Possible that it could be cleaned up sooner, but for now it's destroyed when
the PUGBean is stopped
             this.tempClassLoader = new TemporaryClassLoader(classLoader);
+            this.bundle = bundle;
         }
 
         @Override
@@ -360,7 +362,7 @@ public class PersistenceUnitGBean implem
 
         @Override
         public void addTransformer(ClassTransformer classTransformer) {
-            TransformerWrapper transformer = new TransformerWrapper(classTransformer, classLoader);
+            TransformerWrapper transformer = new TransformerWrapper(classTransformer, bundle);
             transformers.add(transformer);
             TransformerAgent.addTransformer(transformer);
         }

Modified: geronimo/server/trunk/plugins/openjpa2/geronimo-persistence-jpa20/src/main/java/org/apache/geronimo/persistence/TransformerWrapper.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/openjpa2/geronimo-persistence-jpa20/src/main/java/org/apache/geronimo/persistence/TransformerWrapper.java?rev=937007&r1=937006&r2=937007&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/openjpa2/geronimo-persistence-jpa20/src/main/java/org/apache/geronimo/persistence/TransformerWrapper.java
(original)
+++ geronimo/server/trunk/plugins/openjpa2/geronimo-persistence-jpa20/src/main/java/org/apache/geronimo/persistence/TransformerWrapper.java
Thu Apr 22 18:54:39 2010
@@ -21,6 +21,8 @@ import java.lang.instrument.IllegalClass
 import java.security.ProtectionDomain;
 
 import javax.persistence.spi.ClassTransformer;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleReference;
 
 /**
  * @version $Rev$ $Date$
@@ -28,23 +30,24 @@ import javax.persistence.spi.ClassTransf
 public class TransformerWrapper implements ClassFileTransformer {
 
     private final ClassTransformer classTransformer;
-    private final ClassLoader classLoader;
+    private final Bundle bundle;
 
-    public TransformerWrapper(ClassTransformer classTransformer, ClassLoader classLoader)
{
+    public TransformerWrapper(ClassTransformer classTransformer, Bundle bundle) {
         this.classTransformer = classTransformer;
-        this.classLoader = classLoader;
+        this.bundle = bundle;
     }
 
     public byte[] transform(ClassLoader loader, String className, Class<?> classBeingRedefined,
ProtectionDomain protectionDomain, byte[] classfileBuffer) throws IllegalClassFormatException
{
-//        if (loader != classLoader) {
-//            return null;
-//        }
-        try {
-            return classTransformer.transform(loader, className, classBeingRedefined,  protectionDomain,
classfileBuffer);
-        } catch (IllegalClassFormatException e) {
-            throw e;
-        } catch (RuntimeException e) {
-            return null;
+        if (loader instanceof BundleReference && ((BundleReference) loader).getBundle()
== bundle) {
+            try {
+                return classTransformer.transform(loader, className, classBeingRedefined,
protectionDomain, classfileBuffer);
+            } catch (IllegalClassFormatException e) {
+                throw e;
+            } catch (RuntimeException e) {
+                return null;
+            }
         }
+        return null;
+
     }
 }



Mime
View raw message