geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ke...@apache.org
Subject svn commit: r510791 - /geronimo/server/branches/2.0-M3/modules/geronimo-persistence-jpa10/src/main/java/org/apache/geronimo/persistence/PersistenceUnitGBean.java
Date Fri, 23 Feb 2007 03:25:33 GMT
Author: kevan
Date: Thu Feb 22 19:25:32 2007
New Revision: 510791

URL: http://svn.apache.org/viewvc?view=rev&rev=510791
Log:
GERONIMO-2873 Fix another persistence-related memory leak. TransformerWrapper's associated
with a PersistentUnitGBean need to be removed when the GBean is stopped. Still some problems,
but things look much better...

Modified:
    geronimo/server/branches/2.0-M3/modules/geronimo-persistence-jpa10/src/main/java/org/apache/geronimo/persistence/PersistenceUnitGBean.java

Modified: geronimo/server/branches/2.0-M3/modules/geronimo-persistence-jpa10/src/main/java/org/apache/geronimo/persistence/PersistenceUnitGBean.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.0-M3/modules/geronimo-persistence-jpa10/src/main/java/org/apache/geronimo/persistence/PersistenceUnitGBean.java?view=diff&rev=510791&r1=510790&r2=510791
==============================================================================
--- geronimo/server/branches/2.0-M3/modules/geronimo-persistence-jpa10/src/main/java/org/apache/geronimo/persistence/PersistenceUnitGBean.java
(original)
+++ geronimo/server/branches/2.0-M3/modules/geronimo-persistence-jpa10/src/main/java/org/apache/geronimo/persistence/PersistenceUnitGBean.java
Thu Feb 22 19:25:32 2007
@@ -93,13 +93,13 @@
             PersistenceProvider persistenceProvider = (PersistenceProvider) clazz.newInstance();
             entityManagerFactory = persistenceProvider.createContainerEntityManagerFactory(persistenceUnitInfo,
properties);
         } catch (ClassNotFoundException e) {
-            persistenceUnitInfo.destroyTempClassLoader();
+            persistenceUnitInfo.destroy();
             throw new PersistenceException("Could not locate PersistenceProvider class: "
+ persistenceProviderClassName + " in classloader " + classLoader, e);
         } catch (InstantiationException e) {
-            persistenceUnitInfo.destroyTempClassLoader();
+            persistenceUnitInfo.destroy();
             throw new PersistenceException("Could not create PersistenceProvider instance:
" + persistenceProviderClassName + " loaded from classloader " + classLoader, e);
         } catch (IllegalAccessException e) {
-            persistenceUnitInfo.destroyTempClassLoader();
+            persistenceUnitInfo.destroy();
             throw new PersistenceException("Could not create PersistenceProvider instance:
" + persistenceProviderClassName + " loaded from classloader " + classLoader, e);
         }
         this.transactionManager = transactionManager;
@@ -179,12 +179,12 @@
     public void doStop() throws Exception {
         //TODO remove any classtransformers added
         entityManagerFactory.close();
-        persistenceUnitInfo.destroyTempClassLoader();
+        persistenceUnitInfo.destroy();
     }
 
     public void doFail() {
         entityManagerFactory.close();
-        persistenceUnitInfo.destroyTempClassLoader();
+        persistenceUnitInfo.destroy();
     }
 
     private static class PersistenceUnitInfoImpl implements PersistenceUnitInfo {
@@ -201,6 +201,7 @@
         private final Properties properties;
         private final ClassLoader classLoader;
         private final JarFileClassLoader tempClassLoader;
+        private final List<TransformerWrapper> transformers;
 
 
         public PersistenceUnitInfoImpl(String persistenceUnitName, String persistenceProviderClassName,
PersistenceUnitTransactionType persistenceUnitTransactionType, DataSource jtaDataSource, DataSource
nonJtaDataSource, List<String> mappingFileNames, List<URL> jarFileUrls, URL persistenceUnitRootUrl,
List<String> managedClassNames, boolean excludeUnlistedClassesValue, Properties properties,
ClassLoader classLoader) {
@@ -216,6 +217,7 @@
             this.excludeUnlistedClassesValue = excludeUnlistedClassesValue;
             this.properties = properties;
             this.classLoader = classLoader;
+            this .transformers = new ArrayList<TransformerWrapper>();
             
             // 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
@@ -271,14 +273,20 @@
         }
 
         public void addTransformer(ClassTransformer classTransformer) {
-            TransformerAgent.addTransformer(new TransformerWrapper(classTransformer, classLoader));
+            TransformerWrapper transformer = new TransformerWrapper(classTransformer, classLoader);
+            transformers.add(transformer);
+            TransformerAgent.addTransformer(transformer);
         }
 
         public ClassLoader getNewTempClassLoader() {
             return tempClassLoader;
         }
 
-        private void destroyTempClassLoader() {
+        private void destroy() {
+            for (TransformerWrapper t : transformers) {
+                TransformerAgent.removeTransformer(t);
+            }
+
             tempClassLoader.destroy();
         }
 



Mime
View raw message