geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r926676 - in /geronimo/components/txmanager/trunk/geronimo-connector/src: main/java/org/apache/geronimo/connector/outbound/ test/java/org/apache/geronimo/connector/outbound/
Date Tue, 23 Mar 2010 17:29:32 GMT
Author: djencks
Date: Tue Mar 23 17:29:32 2010
New Revision: 926676

URL: http://svn.apache.org/viewvc?rev=926676&view=rev
Log:
GERONIMO-4360 connector 1.6 TransactionSupport runtime support needs us to reverse the connectionmanager-mcf
dependency direction.

Modified:
    geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/AbstractConnectionManager.java
    geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/ConnectionManagerContainer.java
    geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/GenericConnectionManager.java
    geronimo/components/txmanager/trunk/geronimo-connector/src/test/java/org/apache/geronimo/connector/outbound/ConnectionManagerTestUtils.java

Modified: geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/AbstractConnectionManager.java
URL: http://svn.apache.org/viewvc/geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/AbstractConnectionManager.java?rev=926676&r1=926675&r2=926676&view=diff
==============================================================================
--- geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/AbstractConnectionManager.java
(original)
+++ geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/AbstractConnectionManager.java
Tue Mar 23 17:29:32 2010
@@ -22,43 +22,47 @@ import javax.resource.spi.ConnectionMana
 import javax.resource.spi.ConnectionRequestInfo;
 import javax.resource.spi.LazyAssociatableConnectionManager;
 import javax.resource.spi.ManagedConnectionFactory;
-import javax.transaction.SystemException;
 
 import org.apache.geronimo.connector.outbound.connectionmanagerconfig.PoolingSupport;
-import org.apache.geronimo.transaction.manager.NamedXAResource;
-import org.apache.geronimo.transaction.manager.NamedXAResourceFactory;
 import org.apache.geronimo.transaction.manager.RecoverableTransactionManager;
 
 /**
  * @version $Rev$ $Date$
  */
 public abstract class AbstractConnectionManager implements ConnectionManagerContainer, ConnectionManager,
LazyAssociatableConnectionManager, PoolingAttributes {
-    protected final Interceptors interceptors;
-    private final RecoverableTransactionManager transactionManager;
+    protected transient final Interceptors interceptors;
+    private transient final RecoverableTransactionManager transactionManager;
+    private transient final ManagedConnectionFactory managedConnectionFactory;
     private final String name;
 
     //default constructor to support externalizable subclasses
     public AbstractConnectionManager() {
         interceptors = null;
         transactionManager = null;
+        managedConnectionFactory = null;
         this.name = null;
     }
 
-    public AbstractConnectionManager(Interceptors interceptors, RecoverableTransactionManager
transactionManager, String name) {
+    public AbstractConnectionManager(Interceptors interceptors, RecoverableTransactionManager
transactionManager, ManagedConnectionFactory mcf, String name) {
         this.interceptors = interceptors;
         this.transactionManager = transactionManager;
+        this.managedConnectionFactory = mcf;
         this.name = name;
     }
 
-    public Object createConnectionFactory(ManagedConnectionFactory mcf) throws ResourceException
{
-        return mcf.createConnectionFactory(this);
+    public Object createConnectionFactory() throws ResourceException {
+        return managedConnectionFactory.createConnectionFactory(this);
     }
 
     protected ConnectionManager getConnectionManager() {
         return this;
     }
 
-    public void doRecovery(ManagedConnectionFactory managedConnectionFactory) {
+    public ManagedConnectionFactory getManagedConnectionFactory() {
+        return managedConnectionFactory;
+    }
+
+    public void doRecovery() {
         if (!getIsRecoverable()) {
             return;
         }
@@ -186,12 +190,16 @@ public abstract class AbstractConnection
     }
 
     public void doStop() throws Exception {
-        transactionManager.unregisterNamedXAResourceFactory(name);
+        if (transactionManager != null) {
+            transactionManager.unregisterNamedXAResourceFactory(name);
+        }
         interceptors.getStack().destroy();
     }
 
     public void doFail() {
-        transactionManager.unregisterNamedXAResourceFactory(name);
+        if (transactionManager != null) {
+            transactionManager.unregisterNamedXAResourceFactory(name);
+        }
         interceptors.getStack().destroy();
     }
 }

Modified: geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/ConnectionManagerContainer.java
URL: http://svn.apache.org/viewvc/geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/ConnectionManagerContainer.java?rev=926676&r1=926675&r2=926676&view=diff
==============================================================================
--- geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/ConnectionManagerContainer.java
(original)
+++ geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/ConnectionManagerContainer.java
Tue Mar 23 17:29:32 2010
@@ -27,8 +27,8 @@ import javax.resource.spi.ManagedConnect
  */
 public interface ConnectionManagerContainer {
 
-    Object createConnectionFactory(ManagedConnectionFactory mcf) throws ResourceException;
+    Object createConnectionFactory() throws ResourceException;
 
-    void doRecovery(ManagedConnectionFactory managedConnectionFactory);
+    void doRecovery();
 
 }

Modified: geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/GenericConnectionManager.java
URL: http://svn.apache.org/viewvc/geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/GenericConnectionManager.java?rev=926676&r1=926675&r2=926676&view=diff
==============================================================================
--- geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/GenericConnectionManager.java
(original)
+++ geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/GenericConnectionManager.java
Tue Mar 23 17:29:32 2010
@@ -17,11 +17,15 @@
 
 package org.apache.geronimo.connector.outbound;
 
+import javax.resource.spi.ManagedConnectionFactory;
 import javax.transaction.TransactionManager;
 
+import org.apache.geronimo.connector.outbound.connectionmanagerconfig.LocalTransactions;
+import org.apache.geronimo.connector.outbound.connectionmanagerconfig.NoTransactions;
 import org.apache.geronimo.connector.outbound.connectionmanagerconfig.PartitionedPool;
 import org.apache.geronimo.connector.outbound.connectionmanagerconfig.PoolingSupport;
 import org.apache.geronimo.connector.outbound.connectionmanagerconfig.TransactionSupport;
+import org.apache.geronimo.connector.outbound.connectionmanagerconfig.XATransactions;
 import org.apache.geronimo.connector.outbound.connectiontracking.ConnectionTracker;
 import org.apache.geronimo.transaction.manager.RecoverableTransactionManager;
 import org.slf4j.Logger;
@@ -48,6 +52,7 @@ public class GenericConnectionManager ex
      * @param subjectSource If not null, use container managed security, getting the Subject
from the SubjectSource
      * @param connectionTracker tracks connections between calls as needed
      * @param transactionManager transaction manager
+     * @param mcf
      * @param name name
      * @param classLoader classloader this component is running in.
      */
@@ -56,9 +61,10 @@ public class GenericConnectionManager ex
                                     SubjectSource subjectSource,
                                     ConnectionTracker connectionTracker,
                                     RecoverableTransactionManager transactionManager,
+                                    ManagedConnectionFactory mcf,
                                     String name,
                                     ClassLoader classLoader) {
-        super(new InterceptorsImpl(transactionSupport, pooling, subjectSource, name, connectionTracker,
transactionManager, classLoader), transactionManager, name);
+        super(new InterceptorsImpl(transactionSupport, pooling, subjectSource, name, connectionTracker,
transactionManager, mcf, classLoader), transactionManager, mcf, name);
     }
 
     private static class InterceptorsImpl implements AbstractConnectionManager.Interceptors
{
@@ -86,12 +92,36 @@ public class GenericConnectionManager ex
                                 String name,
                                 ConnectionTracker connectionTracker,
                                 TransactionManager transactionManager,
-                                ClassLoader classLoader) {
+                                ManagedConnectionFactory mcf, ClassLoader classLoader) {
             //check for consistency between attributes
             if (subjectSource == null && pooling instanceof PartitionedPool &&
((PartitionedPool) pooling).isPartitionBySubject()) {
                 throw new IllegalStateException("To use Subject in pooling, you need a SecurityDomain");
             }
 
+            if (mcf == null) {
+                throw new NullPointerException("No ManagedConnectionFactory supplied for
" + name);
+            }
+            if (mcf instanceof javax.resource.spi.TransactionSupport) {
+                javax.resource.spi.TransactionSupport txSupport = (javax.resource.spi.TransactionSupport)mcf;
+                javax.resource.spi.TransactionSupport.TransactionSupportLevel txSupportLevel
= txSupport.getTransactionSupport();
+                log.info("Runtime TransactionSupport level: " + txSupportLevel);
+                if (txSupportLevel != null) {
+                    if (txSupportLevel == javax.resource.spi.TransactionSupport.TransactionSupportLevel.NoTransaction)
{
+                        transactionSupport = NoTransactions.INSTANCE;
+                    } else if (txSupportLevel == javax.resource.spi.TransactionSupport.TransactionSupportLevel.LocalTransaction)
{
+                        if (transactionSupport != NoTransactions.INSTANCE) {
+                            transactionSupport = LocalTransactions.INSTANCE;
+                        }
+                    } else {
+                        if (transactionSupport != NoTransactions.INSTANCE && transactionSupport
!= LocalTransactions.INSTANCE) {
+                            transactionSupport = new XATransactions(true, false);
+                        }
+                    }
+                }
+            } else {
+                log.info("No runtime TransactionSupport");
+            }
+
             //Set up the interceptor stack
             MCFConnectionInterceptor tail = new MCFConnectionInterceptor();
             ConnectionInterceptor stack = tail;

Modified: geronimo/components/txmanager/trunk/geronimo-connector/src/test/java/org/apache/geronimo/connector/outbound/ConnectionManagerTestUtils.java
URL: http://svn.apache.org/viewvc/geronimo/components/txmanager/trunk/geronimo-connector/src/test/java/org/apache/geronimo/connector/outbound/ConnectionManagerTestUtils.java?rev=926676&r1=926675&r2=926676&view=diff
==============================================================================
--- geronimo/components/txmanager/trunk/geronimo-connector/src/test/java/org/apache/geronimo/connector/outbound/ConnectionManagerTestUtils.java
(original)
+++ geronimo/components/txmanager/trunk/geronimo-connector/src/test/java/org/apache/geronimo/connector/outbound/ConnectionManagerTestUtils.java
Tue Mar 23 17:29:32 2010
@@ -113,9 +113,10 @@ public class ConnectionManagerTestUtils 
                 poolingSupport,
                 subjectSource, connectionTrackingCoordinator,
                 this.transactionManager,
+                mockManagedConnectionFactory,
                 name,
                 classLoader);
-        connectionFactory = (MockConnectionFactory) connectionManagerDeployment.createConnectionFactory(mockManagedConnectionFactory);
+        connectionFactory = (MockConnectionFactory) connectionManagerDeployment.createConnectionFactory();
         connectorInstanceContext = new ConnectorInstanceContextImpl(unshareableResources,
applicationManagedSecurityResources);
         defaultComponentInterceptor = new DefaultComponentInterceptor(this, connectionTrackingCoordinator);
     }



Mime
View raw message