tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1364845 - in /openejb/branches/openejb-pool: container/openejb-core/src/main/java/org/apache/openejb/junit/ container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/managed/local/ container/openejb-core/src/main/java/org/apach...
Date Mon, 23 Jul 2012 23:49:10 GMT
Author: rmannibucau
Date: Mon Jul 23 23:49:10 2012
New Revision: 1364845

URL: http://svn.apache.org/viewvc?rev=1364845&view=rev
Log:
management of close for managed tx

Modified:
    openejb/branches/openejb-pool/container/openejb-core/src/main/java/org/apache/openejb/junit/ApplicationComposer.java
    openejb/branches/openejb-pool/container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/managed/local/ManagedDataSource.java
    openejb/branches/openejb-pool/container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/pool/DbcpDataSourceCreator.java
    openejb/branches/openejb-pool/container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/pool/PoolDataSourceCreator.java
    openejb/branches/openejb-pool/tomee/tomee-dbcp/src/main/java/org/apache/tomee/dbcp/TomEEDataSourceCreator.java
    openejb/branches/openejb-pool/tomee/tomee-dbcp/src/test/java/org/apache/tomee/dbcp/TomcatPoolTest.java

Modified: openejb/branches/openejb-pool/container/openejb-core/src/main/java/org/apache/openejb/junit/ApplicationComposer.java
URL: http://svn.apache.org/viewvc/openejb/branches/openejb-pool/container/openejb-core/src/main/java/org/apache/openejb/junit/ApplicationComposer.java?rev=1364845&r1=1364844&r2=1364845&view=diff
==============================================================================
--- openejb/branches/openejb-pool/container/openejb-core/src/main/java/org/apache/openejb/junit/ApplicationComposer.java
(original)
+++ openejb/branches/openejb-pool/container/openejb-core/src/main/java/org/apache/openejb/junit/ApplicationComposer.java
Mon Jul 23 23:49:10 2012
@@ -19,6 +19,7 @@ package org.apache.openejb.junit;
 import org.apache.openejb.AppContext;
 import org.apache.openejb.BeanContext;
 import org.apache.openejb.InjectionProcessor;
+import org.apache.openejb.OpenEJB;
 import org.apache.openejb.assembler.classic.AppInfo;
 import org.apache.openejb.assembler.classic.Assembler;
 import org.apache.openejb.config.AppModule;
@@ -333,6 +334,7 @@ public class ApplicationComposer extends
                     assembler.destroyApplication(appInfo.path);
                 }
             } finally {
+                OpenEJB.destroy();
                 SystemInstance.reset();
             }
         }

Modified: openejb/branches/openejb-pool/container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/managed/local/ManagedDataSource.java
URL: http://svn.apache.org/viewvc/openejb/branches/openejb-pool/container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/managed/local/ManagedDataSource.java?rev=1364845&r1=1364844&r2=1364845&view=diff
==============================================================================
--- openejb/branches/openejb-pool/container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/managed/local/ManagedDataSource.java
(original)
+++ openejb/branches/openejb-pool/container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/managed/local/ManagedDataSource.java
Mon Jul 23 23:49:10 2012
@@ -70,4 +70,8 @@ public class ManagedDataSource implement
     private Connection managed(final Connection connection) {
         return (Connection) Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(),
CONNECTION_CLASS, new ManagedConnection(connection, transactionManager));
     }
+
+    public DataSource getDelegate() {
+        return delegate;
+    }
 }

Modified: openejb/branches/openejb-pool/container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/pool/DbcpDataSourceCreator.java
URL: http://svn.apache.org/viewvc/openejb/branches/openejb-pool/container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/pool/DbcpDataSourceCreator.java?rev=1364845&r1=1364844&r2=1364845&view=diff
==============================================================================
--- openejb/branches/openejb-pool/container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/pool/DbcpDataSourceCreator.java
(original)
+++ openejb/branches/openejb-pool/container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/pool/DbcpDataSourceCreator.java
Mon Jul 23 23:49:10 2012
@@ -33,12 +33,12 @@ public class DbcpDataSourceCreator exten
     }
 
     @Override
-    public boolean hasCreated(final Object object) {
+    protected boolean hasReallyCreated(Object object) {
         return object instanceof org.apache.commons.dbcp.BasicDataSource;
     }
 
     @Override
-    public void destroy(final Object object) throws Throwable {
-        ((org.apache.commons.dbcp.BasicDataSource) object).close();
+    protected void doDestroy(DataSource dataSource) throws Throwable {
+        ((org.apache.commons.dbcp.BasicDataSource) dataSource).close();
     }
 }

Modified: openejb/branches/openejb-pool/container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/pool/PoolDataSourceCreator.java
URL: http://svn.apache.org/viewvc/openejb/branches/openejb-pool/container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/pool/PoolDataSourceCreator.java?rev=1364845&r1=1364844&r2=1364845&view=diff
==============================================================================
--- openejb/branches/openejb-pool/container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/pool/PoolDataSourceCreator.java
(original)
+++ openejb/branches/openejb-pool/container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/pool/PoolDataSourceCreator.java
Mon Jul 23 23:49:10 2012
@@ -40,4 +40,22 @@ public abstract class PoolDataSourceCrea
     public DataSource poolManaged(final String name, final String driver, final Properties
properties) {
         return managed(name, pool(name, driver, properties));
     }
+
+    @Override
+    public boolean hasCreated(final Object object) {
+        return hasReallyCreated(object) || object instanceof ManagedDataSource;
+    }
+
+    protected abstract boolean hasReallyCreated(final Object object);
+
+    @Override
+    public void destroy(final Object object) throws Throwable {
+        if (object instanceof ManagedDataSource) {
+            doDestroy(((ManagedDataSource) object).getDelegate());
+        } else {
+            doDestroy((DataSource) object);
+        }
+    }
+
+    protected abstract void doDestroy(DataSource dataSource) throws Throwable;
 }

Modified: openejb/branches/openejb-pool/tomee/tomee-dbcp/src/main/java/org/apache/tomee/dbcp/TomEEDataSourceCreator.java
URL: http://svn.apache.org/viewvc/openejb/branches/openejb-pool/tomee/tomee-dbcp/src/main/java/org/apache/tomee/dbcp/TomEEDataSourceCreator.java?rev=1364845&r1=1364844&r2=1364845&view=diff
==============================================================================
--- openejb/branches/openejb-pool/tomee/tomee-dbcp/src/main/java/org/apache/tomee/dbcp/TomEEDataSourceCreator.java
(original)
+++ openejb/branches/openejb-pool/tomee/tomee-dbcp/src/main/java/org/apache/tomee/dbcp/TomEEDataSourceCreator.java
Mon Jul 23 23:49:10 2012
@@ -51,12 +51,13 @@ public class TomEEDataSourceCreator exte
     }
 
     @Override
-    public boolean hasCreated(final Object object) {
-        return object instanceof org.apache.tomcat.jdbc.pool.DataSource || object instanceof
TomcatDbcpDataSource;
+    public boolean hasReallyCreated(final Object object) {
+        return object instanceof org.apache.tomcat.jdbc.pool.DataSource
+                || object instanceof TomcatDbcpDataSource;
     }
 
     @Override
-    public void destroy(final Object object) throws Throwable {
+    public void doDestroy(final DataSource object) throws Throwable {
         if (object instanceof TomcatDbcpDataSource) {
             ((TomcatDbcpDataSource) object).close();
         } else {

Modified: openejb/branches/openejb-pool/tomee/tomee-dbcp/src/test/java/org/apache/tomee/dbcp/TomcatPoolTest.java
URL: http://svn.apache.org/viewvc/openejb/branches/openejb-pool/tomee/tomee-dbcp/src/test/java/org/apache/tomee/dbcp/TomcatPoolTest.java?rev=1364845&r1=1364844&r2=1364845&view=diff
==============================================================================
--- openejb/branches/openejb-pool/tomee/tomee-dbcp/src/test/java/org/apache/tomee/dbcp/TomcatPoolTest.java
(original)
+++ openejb/branches/openejb-pool/tomee/tomee-dbcp/src/test/java/org/apache/tomee/dbcp/TomcatPoolTest.java
Mon Jul 23 23:49:10 2012
@@ -6,7 +6,6 @@ import org.apache.openejb.junit.Applicat
 import org.apache.openejb.junit.Configuration;
 import org.apache.openejb.junit.Module;
 import org.apache.openejb.resource.jdbc.managed.local.ManagedConnection;
-import org.apache.openejb.resource.jdbc.pool.DbcpDataSourceCreator;
 import org.junit.After;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -28,7 +27,6 @@ import java.sql.SQLException;
 import java.sql.Statement;
 import java.util.Map;
 import java.util.Properties;
-import java.util.concurrent.CountDownLatch;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
@@ -144,11 +142,6 @@ public class TomcatPoolTest {
     public void commit() throws SQLException {
         persistManager.save();
         assertTrue(exists(1));
-        try {
-            new CountDownLatch(1).await();
-        } catch (InterruptedException e) {
-            e.printStackTrace();  //To change body of catch statement use File | Settings
| File Templates.
-        }
     }
 
     @Test



Mime
View raw message