Index: container/openejb-core/src/test/java/org/apache/openejb/assembler/classic/JdbcConfigTest.java =================================================================== --- container/openejb-core/src/test/java/org/apache/openejb/assembler/classic/JdbcConfigTest.java (revision 555043) +++ container/openejb-core/src/test/java/org/apache/openejb/assembler/classic/JdbcConfigTest.java (working copy) @@ -23,6 +23,7 @@ import org.apache.openejb.spi.ContainerSystem; import javax.sql.DataSource; +import javax.transaction.TransactionManager; import java.sql.Connection; import java.sql.SQLException; import java.sql.Statement; @@ -59,10 +60,28 @@ DataSource unmanagedDS = (DataSource) containerSystem.getJNDIContext().lookup("java:openejb/Resource/Default Unmanaged JDBC Database"); assertNotNull("unmanagedDS is null", unmanagedDS); + // test without a transaction + // NOTE: without a transaction all connections work as unmanaged + verifyUnmanagedConnections(managedDS); + verifyUnmanagedConnections(unmanagedDS); + + // test in the context of a transaction + TransactionManager transactionManager = SystemInstance.get().getComponent(TransactionManager.class); + transactionManager.begin(); + try { + verifyManagedConnections(managedDS); + verifyUnmanagedConnections(unmanagedDS); + } finally { + // commit the transaction + transactionManager.commit(); + } + } + + private void verifyManagedConnections(DataSource dataSource) throws SQLException { List managedConnections = new ArrayList(); try { for (int i = 0; i < 4; i++) { - Connection connection = managedDS.getConnection(); + Connection connection = dataSource.getConnection(); managedConnections.add(connection); try { @@ -83,11 +102,13 @@ close(connection); } } + } + private void verifyUnmanagedConnections(DataSource dataSource) throws SQLException { List unmanagedConnections = new ArrayList(); try { for (int i = 0; i < 4; i++) { - Connection connection = unmanagedDS.getConnection(); + Connection connection = dataSource.getConnection(); unmanagedConnections.add(connection); assertTrue("Expected connection.getAutoCommit() to be true", connection.getAutoCommit()); connection.setAutoCommit(true); @@ -105,7 +126,6 @@ close(connection); } } - } private static void close(Connection connection) { Index: container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/BasicManagedDataSource.java =================================================================== --- container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/BasicManagedDataSource.java (revision 0) +++ container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/BasicManagedDataSource.java (revision 0) @@ -0,0 +1,36 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.openejb.resource.jdbc; + +public class BasicManagedDataSource extends org.apache.commons.dbcp.managed.BasicManagedDataSource { + public synchronized String getJdbcDriver() { + return super.getDriverClassName(); + } + + public synchronized void setJdbcDriver(String string) { + super.setDriverClassName(string); + } + + public synchronized String getJdbcUrl() { + return super.getUrl(); + } + + public synchronized void setJdbcUrl(String string) { + super.setUrl(string); + } +} Index: container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/BasicDataSource.java =================================================================== --- container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/BasicDataSource.java (revision 0) +++ container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/BasicDataSource.java (revision 0) @@ -0,0 +1,36 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.openejb.resource.jdbc; + +public class BasicDataSource extends org.apache.commons.dbcp.BasicDataSource { + public synchronized String getJdbcDriver() { + return super.getDriverClassName(); + } + + public synchronized void setJdbcDriver(String string) { + super.setDriverClassName(string); + } + + public synchronized String getJdbcUrl() { + return super.getUrl(); + } + + public synchronized void setJdbcUrl(String string) { + super.setUrl(string); + } +} Index: container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java =================================================================== --- container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java (revision 555043) +++ container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java (working copy) @@ -749,6 +749,7 @@ public void createResource(ResourceInfo serviceInfo) throws OpenEJBException { ObjectRecipe serviceRecipe = new ObjectRecipe(serviceInfo.className, serviceInfo.factoryMethod, serviceInfo.constructorArgs.toArray(new String[0]), null); serviceRecipe.setAllProperties(serviceInfo.properties); + serviceRecipe.setProperty("transactionManager", transactionManager); serviceRecipe.allow(Option.IGNORE_MISSING_PROPERTIES); replaceResourceAdapterProperty(serviceRecipe); Index: container/openejb-core/src/main/resources/META-INF/org.apache.openejb/service-jar.xml =================================================================== --- container/openejb-core/src/main/resources/META-INF/org.apache.openejb/service-jar.xml (revision 555043) +++ container/openejb-core/src/main/resources/META-INF/org.apache.openejb/service-jar.xml (working copy) @@ -239,8 +239,7 @@ + class-name="org.apache.openejb.resource.jdbc.BasicManagedDataSource"> # Driver class name @@ -262,16 +261,13 @@ #Password pass Password - Unmanaged false - ConnectionInterface javax.sql.DataSource + class-name="org.apache.openejb.resource.jdbc.BasicDataSource"> # Driver class name @@ -293,8 +289,6 @@ #Password pass Password - Unmanaged true - ConnectionInterface javax.sql.DataSource Index: container/openejb-core/pom.xml =================================================================== --- container/openejb-core/pom.xml (revision 555043) +++ container/openejb-core/pom.xml (working copy) @@ -335,7 +335,6 @@ commons-dbcp commons-dbcp - test Index: pom.xml =================================================================== --- pom.xml (revision 555043) +++ pom.xml (working copy) @@ -928,7 +928,7 @@ commons-dbcp commons-dbcp - 1.2.1 + 1.3-SNAPSHOT commons-collections