portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rwat...@apache.org
Subject svn commit: r748234 - in /portals/jetspeed-2/portal/branches/JPA_BRANCH: ./ components/jetspeed-capability/src/main/java/org/apache/jetspeed/capabilities/jpa/ components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/page/jpa/ components/jetsp...
Date Thu, 26 Feb 2009 17:54:14 GMT
Author: rwatler
Date: Thu Feb 26 17:54:14 2009
New Revision: 748234

URL: http://svn.apache.org/viewvc?rev=748234&view=rev
Log:
- fixed DB connection pool leak with Atomikos upgrade to 3.5.2
- added simple connection pool diagnostic access to datasource components
- returned mutable lists of names from JPA persistence managers, (JPA query results lists
are immutable)
- cleaned up JPA persistence context entity manager management to explicitly close entity
managers on terminate


Modified:
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-capability/src/main/java/org/apache/jetspeed/capabilities/jpa/CapabilitiesManagerContext.java
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/page/jpa/DatabasePageManagerContext.java
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-profiler/src/main/java/org/apache/jetspeed/profiler/jpa/ProfilerManagerContext.java
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-rdbms/src/main/java/org/apache/jetspeed/components/datasource/AtomikosXADatasourceComponent.java
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-rdbms/src/main/java/org/apache/jetspeed/components/datasource/DBCPDatasourceComponent.java
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-rdbms/src/main/java/org/apache/jetspeed/components/datasource/DatasourceComponent.java
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-rdbms/src/main/java/org/apache/jetspeed/components/jndi/JetspeedTestJNDIComponent.java
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletregistry/jpa/RegistryManagerContext.java
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/jpa/JetspeedSecurityPersistenceManager.java
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/jpa/SecurityManagerContext.java
    portals/jetspeed-2/portal/branches/JPA_BRANCH/pom.xml

Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-capability/src/main/java/org/apache/jetspeed/capabilities/jpa/CapabilitiesManagerContext.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-capability/src/main/java/org/apache/jetspeed/capabilities/jpa/CapabilitiesManagerContext.java?rev=748234&r1=748233&r2=748234&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-capability/src/main/java/org/apache/jetspeed/capabilities/jpa/CapabilitiesManagerContext.java
(original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-capability/src/main/java/org/apache/jetspeed/capabilities/jpa/CapabilitiesManagerContext.java
Thu Feb 26 17:54:14 2009
@@ -20,6 +20,8 @@
 import javax.persistence.PersistenceContext;
 import javax.persistence.PersistenceContextType;
 
+import org.springframework.orm.jpa.EntityManagerProxy;
+
 /**
  * CapabilitiesManagerContext
  * 
@@ -78,5 +80,12 @@
     public void terminate()
     {
         capabilitiesManager.unregisterContext(this);
+        // explicitly close Spring container managed extended entity
+        // managers which are not closed on bean destruction
+        if (extendedEntityManager instanceof EntityManagerProxy)
+        {
+            ((EntityManagerProxy)extendedEntityManager).getTargetEntityManager().close();
+        }
+        extendedEntityManager = null;
     }
 }

Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/page/jpa/DatabasePageManagerContext.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/page/jpa/DatabasePageManagerContext.java?rev=748234&r1=748233&r2=748234&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/page/jpa/DatabasePageManagerContext.java
(original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/page/jpa/DatabasePageManagerContext.java
Thu Feb 26 17:54:14 2009
@@ -20,6 +20,8 @@
 import javax.persistence.PersistenceContext;
 import javax.persistence.PersistenceContextType;
 
+import org.springframework.orm.jpa.EntityManagerProxy;
+
 /**
  * DatabasePageManagerContext
  * 
@@ -78,5 +80,12 @@
     public void terminate()
     {
         databasePageManager.unregisterContext(this);
+        // explicitly close Spring container managed extended entity
+        // managers which are not closed on bean destruction
+        if (extendedEntityManager instanceof EntityManagerProxy)
+        {
+            ((EntityManagerProxy)extendedEntityManager).getTargetEntityManager().close();
+        }
+        extendedEntityManager = null;
     }
 }

Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-profiler/src/main/java/org/apache/jetspeed/profiler/jpa/ProfilerManagerContext.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-profiler/src/main/java/org/apache/jetspeed/profiler/jpa/ProfilerManagerContext.java?rev=748234&r1=748233&r2=748234&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-profiler/src/main/java/org/apache/jetspeed/profiler/jpa/ProfilerManagerContext.java
(original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-profiler/src/main/java/org/apache/jetspeed/profiler/jpa/ProfilerManagerContext.java
Thu Feb 26 17:54:14 2009
@@ -20,6 +20,8 @@
 import javax.persistence.PersistenceContext;
 import javax.persistence.PersistenceContextType;
 
+import org.springframework.orm.jpa.EntityManagerProxy;
+
 /**
  * ProfilerManagerContext
  * 
@@ -78,5 +80,12 @@
     public void terminate()
     {
         profilerManager.unregisterContext(this);
+        // explicitly close Spring container managed extended entity
+        // managers which are not closed on bean destruction
+        if (extendedEntityManager instanceof EntityManagerProxy)
+        {
+            ((EntityManagerProxy)extendedEntityManager).getTargetEntityManager().close();
+        }
+        extendedEntityManager = null;
     }
 }

Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-rdbms/src/main/java/org/apache/jetspeed/components/datasource/AtomikosXADatasourceComponent.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-rdbms/src/main/java/org/apache/jetspeed/components/datasource/AtomikosXADatasourceComponent.java?rev=748234&r1=748233&r2=748234&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-rdbms/src/main/java/org/apache/jetspeed/components/datasource/AtomikosXADatasourceComponent.java
(original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-rdbms/src/main/java/org/apache/jetspeed/components/datasource/AtomikosXADatasourceComponent.java
Thu Feb 26 17:54:14 2009
@@ -214,4 +214,13 @@
         {                
         }
     }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.components.datasource.DatasourceComponent#active()
+     */
+    public int active()
+    {
+        AbstractDataSourceBean datasourceBean = (AbstractDataSourceBean)dataSource;
+        return datasourceBean.poolTotalSize()-datasourceBean.poolAvailableSize();
+    }
 }

Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-rdbms/src/main/java/org/apache/jetspeed/components/datasource/DBCPDatasourceComponent.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-rdbms/src/main/java/org/apache/jetspeed/components/datasource/DBCPDatasourceComponent.java?rev=748234&r1=748233&r2=748234&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-rdbms/src/main/java/org/apache/jetspeed/components/datasource/DBCPDatasourceComponent.java
(original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-rdbms/src/main/java/org/apache/jetspeed/components/datasource/DBCPDatasourceComponent.java
Thu Feb 26 17:54:14 2009
@@ -51,8 +51,7 @@
 
     private static final Log log = LogFactory.getLog(DBCPDatasourceComponent.class);
 
-    protected PoolingDataSource dataSource;
-    //protected DataSource dataSource;
+    protected DataSource dataSource;
     
     private String user;
     
@@ -69,6 +68,7 @@
     private byte whenExhausted;
     
     private PoolableConnectionFactory dsConnectionFactory;
+
     /**
      * 
      * Creates a simple commons DBCP connection pool using the following
@@ -221,4 +221,12 @@
             }
         }
     }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.components.datasource.DatasourceComponent#active()
+     */
+    public int active()
+    {
+        return dsConnectionFactory.getPool().getNumActive();
+    }
 }

Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-rdbms/src/main/java/org/apache/jetspeed/components/datasource/DatasourceComponent.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-rdbms/src/main/java/org/apache/jetspeed/components/datasource/DatasourceComponent.java?rev=748234&r1=748233&r2=748234&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-rdbms/src/main/java/org/apache/jetspeed/components/datasource/DatasourceComponent.java
(original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-rdbms/src/main/java/org/apache/jetspeed/components/datasource/DatasourceComponent.java
Thu Feb 26 17:54:14 2009
@@ -42,4 +42,11 @@
      * Stop and terminate component.
      */
     public abstract void stop();
+    
+    /**
+     * Return number of current active connections in datasource pool.
+     * 
+     * @return number of active connections.
+     */
+    public abstract int active();
 }
\ No newline at end of file

Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-rdbms/src/main/java/org/apache/jetspeed/components/jndi/JetspeedTestJNDIComponent.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-rdbms/src/main/java/org/apache/jetspeed/components/jndi/JetspeedTestJNDIComponent.java?rev=748234&r1=748233&r2=748234&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-rdbms/src/main/java/org/apache/jetspeed/components/jndi/JetspeedTestJNDIComponent.java
(original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-rdbms/src/main/java/org/apache/jetspeed/components/jndi/JetspeedTestJNDIComponent.java
Thu Feb 26 17:54:14 2009
@@ -16,6 +16,7 @@
  */
 package org.apache.jetspeed.components.jndi;
 
+import org.apache.commons.dbcp.PoolingDataSource;
 import org.apache.commons.pool.impl.GenericObjectPool;
 import org.apache.jetspeed.components.datasource.DatasourceComponent;
 import org.apache.jetspeed.components.datasource.BoundDBCPDatasourceComponent;

Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletregistry/jpa/RegistryManagerContext.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletregistry/jpa/RegistryManagerContext.java?rev=748234&r1=748233&r2=748234&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletregistry/jpa/RegistryManagerContext.java
(original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletregistry/jpa/RegistryManagerContext.java
Thu Feb 26 17:54:14 2009
@@ -20,6 +20,8 @@
 import javax.persistence.PersistenceContext;
 import javax.persistence.PersistenceContextType;
 
+import org.springframework.orm.jpa.EntityManagerProxy;
+
 /**
  * RegistryManagerContext
  * 
@@ -78,5 +80,12 @@
     public void terminate()
     {
         registryManager.unregisterContext(this);
+        // explicitly close Spring container managed extended entity
+        // managers which are not closed on bean destruction
+        if (extendedEntityManager instanceof EntityManagerProxy)
+        {
+            ((EntityManagerProxy)extendedEntityManager).getTargetEntityManager().close();
+        }
+        extendedEntityManager = null;
     }
 }

Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/jpa/JetspeedSecurityPersistenceManager.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/jpa/JetspeedSecurityPersistenceManager.java?rev=748234&r1=748233&r2=748234&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/jpa/JetspeedSecurityPersistenceManager.java
(original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/jpa/JetspeedSecurityPersistenceManager.java
Thu Feb 26 17:54:14 2009
@@ -280,7 +280,9 @@
         principalNamesAssociatedFromQuery.setParameter("type", to.getName());
         principalNamesAssociatedFromQuery.setParameter("fromSecurityDomain", fromSecurityDomain);
         principalNamesAssociatedFromQuery.setParameter("toSecurityDomain", toSecurityDomain);
-        return principalNamesAssociatedFromQuery.getResultList();
+        List<String> names = principalNamesAssociatedFromQuery.getResultList();
+        // return mutable names list to allow sorting
+        return new ArrayList<String>(names);
     }
 
     @Transactional (readOnly=true)
@@ -302,7 +304,9 @@
         principalNamesAssociatedFromQuery.setParameter("type", to.getName());
         principalNamesAssociatedFromQuery.setParameter("fromSecurityDomain", fromSecurityDomain);
         principalNamesAssociatedFromQuery.setParameter("toSecurityDomain", toSecurityDomain);
-        return principalNamesAssociatedFromQuery.getResultList();
+        List<String> names = principalNamesAssociatedFromQuery.getResultList();
+        // return mutable names list to allow sorting
+        return new ArrayList<String>(names);
     }
 
     @Transactional (readOnly=true)
@@ -324,7 +328,9 @@
         principalNamesAssociatedToQuery.setParameter("type", from.getName());
         principalNamesAssociatedToQuery.setParameter("fromSecurityDomain", fromSecurityDomain);
         principalNamesAssociatedToQuery.setParameter("toSecurityDomain", toSecurityDomain);
-        return principalNamesAssociatedToQuery.getResultList();
+        List<String> names = principalNamesAssociatedToQuery.getResultList();
+        // return mutable names list to allow sorting
+        return new ArrayList<String>(names);
     }
 
     @Transactional (readOnly=true)
@@ -346,7 +352,9 @@
         principalNamesAssociatedToQuery.setParameter("type", from.getName());
         principalNamesAssociatedToQuery.setParameter("fromSecurityDomain", fromSecurityDomain);
         principalNamesAssociatedToQuery.setParameter("toSecurityDomain", toSecurityDomain);
-        return principalNamesAssociatedToQuery.getResultList();
+        List<String> names = principalNamesAssociatedToQuery.getResultList();
+        // return mutable names list to allow sorting
+        return new ArrayList<String>(names);
     }
 
     @Transactional (readOnly=true)
@@ -407,7 +415,9 @@
         principalNamesQuery.setParameter("nameFilter", ((nameFilter != null) ? nameFilter
: "")+"%");
         principalNamesQuery.setParameter("type", type.getName());
         principalNamesQuery.setParameter("domainId", securityDomain);
-        return principalNamesQuery.getResultList();
+        List<String> names = principalNamesQuery.getResultList();
+        // return mutable names list to allow sorting
+        return new ArrayList<String>(names);
     }
 
     @Transactional (readOnly=true)

Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/jpa/SecurityManagerContext.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/jpa/SecurityManagerContext.java?rev=748234&r1=748233&r2=748234&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/jpa/SecurityManagerContext.java
(original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/jpa/SecurityManagerContext.java
Thu Feb 26 17:54:14 2009
@@ -20,6 +20,8 @@
 import javax.persistence.PersistenceContext;
 import javax.persistence.PersistenceContextType;
 
+import org.springframework.orm.jpa.EntityManagerProxy;
+
 /**
  * SecurityManagerContext
  * 
@@ -78,5 +80,12 @@
     public void terminate()
     {
         securityManager.unregisterContext(this);
+        // explicitly close Spring container managed extended entity
+        // managers which are not closed on bean destruction
+        if (extendedEntityManager instanceof EntityManagerProxy)
+        {
+            ((EntityManagerProxy)extendedEntityManager).getTargetEntityManager().close();
+        }
+        extendedEntityManager = null;
     }
 }

Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/pom.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/pom.xml?rev=748234&r1=748233&r2=748234&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/pom.xml (original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/pom.xml Thu Feb 26 17:54:14 2009
@@ -269,7 +269,7 @@
 
     <!-- Project Dependency Version Properties -->
     <aopalliance.version>1.0</aopalliance.version>
-    <atomikos.version>3.5.0</atomikos.version>
+    <atomikos.version>3.5.2</atomikos.version>
     <castor.version>1.1.1-xml</castor.version>
     <cglib.version>2.1_3</cglib.version>
     <commons-beanutils.version>1.7.0</commons-beanutils.version>



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Mime
View raw message