geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject cvs commit: incubator-geronimo/modules/core/src/test/org/apache/geronimo/connector/outbound/connectiontracking ConnectionTrackingCoordinatorTest.java
Date Wed, 10 Dec 2003 09:39:46 GMT
djencks     2003/12/10 01:39:46

  Modified:    modules/core/src/java/org/apache/geronimo/connector/outbound/connectiontracking
                        ConnectionTrackingCoordinator.java
                        TrackedConnectionAssociator.java
               modules/core/src/java/org/apache/geronimo/connector/outbound/connectiontracking/defaultimpl
                        DefaultComponentInterceptor.java
               modules/core/src/test/org/apache/geronimo/connector/outbound/connectiontracking
                        ConnectionTrackingCoordinatorTest.java
  Log:
  Enroll existing connection handles in new transactions and new UserTransactions
  
  Revision  Changes    Path
  1.2       +25 -14    incubator-geronimo/modules/core/src/java/org/apache/geronimo/connector/outbound/connectiontracking/ConnectionTrackingCoordinator.java
  
  Index: ConnectionTrackingCoordinator.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/connector/outbound/connectiontracking/ConnectionTrackingCoordinator.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ConnectionTrackingCoordinator.java	9 Dec 2003 04:13:20 -0000	1.1
  +++ ConnectionTrackingCoordinator.java	10 Dec 2003 09:39:46 -0000	1.2
  @@ -83,8 +83,6 @@
    * ConnectionManager stacks so the existing ManagedConnections can be
    * enrolled properly.
    *
  - * TODO make sure tx enlistment on method entry works
  - * TODO implement UserTransaction notifications and tx enlistment.
    *
    * @version $Revision$ $Date$
    *
  @@ -93,20 +91,13 @@
   
       private final ThreadLocal currentConnectorComponentContexts = new ThreadLocal();
       private final ThreadLocal currentConnectorTransactionContexts = new ThreadLocal();
  +    private final ThreadLocal currentUnshareableResources = new ThreadLocal();
   
  -    public ConnectorComponentContext enter(ConnectorComponentContext newConnectorComponentContext,
  -                                           Set unshareableResources)
  +    public ConnectorComponentContext enter(ConnectorComponentContext newConnectorComponentContext
  +                                           )
               throws ResourceException {
           ConnectorComponentContext oldConnectorComponentContext = (ConnectorComponentContext)
currentConnectorComponentContexts.get();
           currentConnectorComponentContexts.set(newConnectorComponentContext);
  -        Map connectionManagerToManagedConnectionInfoMap = newConnectorComponentContext.getConnectionManagerMap();
  -        for (Iterator i = connectionManagerToManagedConnectionInfoMap.entrySet().iterator();
i.hasNext();) {
  -            Map.Entry entry = (Map.Entry) i.next();
  -            ConnectionTrackingInterceptor mcci =
  -                    (ConnectionTrackingInterceptor) entry.getKey();
  -            Set connections = (Set) entry.getValue();
  -            mcci.enter(connections, unshareableResources);
  -        }
           return oldConnectorComponentContext;
       }
   
  @@ -128,10 +119,30 @@
           currentConnectorComponentContexts.set(reenteringConnectorComponentContext);
       }
   
  -    public ConnectorTransactionContext setConnectorTransactionContext(ConnectorTransactionContext
newConnectorTransactionContext) {
  +    public Set setUnshareableResources(Set unshareableResources) {
  +        Set oldUnshareableResources = (Set) currentUnshareableResources.get();
  +        currentUnshareableResources.set(unshareableResources);
  +        return oldUnshareableResources;
  +    }
  +
  +    public ConnectorTransactionContext setConnectorTransactionContext(ConnectorTransactionContext
newConnectorTransactionContext) throws ResourceException {
           ConnectorTransactionContext oldConnectorTransactionContext = (ConnectorTransactionContext)
currentConnectorTransactionContexts.get();
           currentConnectorTransactionContexts.set(newConnectorTransactionContext);
  +        ConnectorComponentContext connectorComponentContext = (ConnectorComponentContext)
currentConnectorComponentContexts.get();
  +        Set unshareableResources = (Set) currentUnshareableResources.get();
  +        Map connectionManagerToManagedConnectionInfoMap = connectorComponentContext.getConnectionManagerMap();
  +        for (Iterator i = connectionManagerToManagedConnectionInfoMap.entrySet().iterator();
i.hasNext();) {
  +            Map.Entry entry = (Map.Entry) i.next();
  +            ConnectionTrackingInterceptor mcci =
  +                    (ConnectionTrackingInterceptor) entry.getKey();
  +            Set connections = (Set) entry.getValue();
  +            mcci.enter(connections, unshareableResources);
  +        }
           return oldConnectorTransactionContext;
  +    }
  +
  +    public void resetConnectorTransactionContext(ConnectorTransactionContext connectorTransactionContext)
{
  +        currentConnectorTransactionContexts.set(connectorTransactionContext);
       }
   
       public void handleObtained(
  
  
  
  1.2       +8 -4      incubator-geronimo/modules/core/src/java/org/apache/geronimo/connector/outbound/connectiontracking/TrackedConnectionAssociator.java
  
  Index: TrackedConnectionAssociator.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/connector/outbound/connectiontracking/TrackedConnectionAssociator.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TrackedConnectionAssociator.java	9 Dec 2003 04:13:20 -0000	1.1
  +++ TrackedConnectionAssociator.java	10 Dec 2003 09:39:46 -0000	1.2
  @@ -14,13 +14,17 @@
    *
    * */
   public interface TrackedConnectionAssociator {
  -    ConnectorComponentContext enter(ConnectorComponentContext newConnectorComponentContext,
  -                                    Set unshareableResources)
  +    ConnectorComponentContext enter(ConnectorComponentContext newConnectorComponentContext
  +                                    )
               throws ResourceException;
   
       void exit(ConnectorComponentContext reenteringConnectorComponentContext,
                 Set unshareableResources)
               throws ResourceException;
   
  -    ConnectorTransactionContext setConnectorTransactionContext(ConnectorTransactionContext
newConnectorTransactionContext);
  +    ConnectorTransactionContext setConnectorTransactionContext(ConnectorTransactionContext
newConnectorTransactionContext) throws ResourceException;
  +
  +    Set setUnshareableResources(Set unshareableResources);
  +
  +    void resetConnectorTransactionContext(ConnectorTransactionContext connectorTransactionContext);
   }
  
  
  
  1.2       +5 -3      incubator-geronimo/modules/core/src/java/org/apache/geronimo/connector/outbound/connectiontracking/defaultimpl/DefaultComponentInterceptor.java
  
  Index: DefaultComponentInterceptor.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/connector/outbound/connectiontracking/defaultimpl/DefaultComponentInterceptor.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DefaultComponentInterceptor.java	9 Dec 2003 04:13:20 -0000	1.1
  +++ DefaultComponentInterceptor.java	10 Dec 2003 09:39:46 -0000	1.2
  @@ -103,13 +103,15 @@
                   newConnectorTransactionContext = new DefaultTransactionContext(transaction);
               }
           }
  -        ConnectorComponentContext oldConnectorComponentContext = cachedConnectionAssociator.enter(newConnectorComponentContext,
unshareableResources);
  +        Set oldUnshareableResources = cachedConnectionAssociator.setUnshareableResources(unshareableResources);
  +        ConnectorComponentContext oldConnectorComponentContext = cachedConnectionAssociator.enter(newConnectorComponentContext);
           ConnectorTransactionContext oldConnectorTransactionContext = cachedConnectionAssociator.setConnectorTransactionContext(newConnectorTransactionContext);
           try {
               return next.invoke(newConnectorComponentContext);
           } finally {
               cachedConnectionAssociator.exit(oldConnectorComponentContext, unshareableResources);
  -            cachedConnectionAssociator.setConnectorTransactionContext(oldConnectorTransactionContext);
  +            cachedConnectionAssociator.resetConnectorTransactionContext(oldConnectorTransactionContext);
  +            cachedConnectionAssociator.setUnshareableResources(oldUnshareableResources);
           }
       }
   }
  
  
  
  1.2       +9 -6      incubator-geronimo/modules/core/src/test/org/apache/geronimo/connector/outbound/connectiontracking/ConnectionTrackingCoordinatorTest.java
  
  Index: ConnectionTrackingCoordinatorTest.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/test/org/apache/geronimo/connector/outbound/connectiontracking/ConnectionTrackingCoordinatorTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ConnectionTrackingCoordinatorTest.java	9 Dec 2003 04:17:39 -0000	1.1
  +++ ConnectionTrackingCoordinatorTest.java	10 Dec 2003 09:39:46 -0000	1.2
  @@ -99,6 +99,7 @@
           key1 = new ConnectionTrackingInterceptor(null, name1, connectionTrackingCoordinator,
this);
           key2 = new ConnectionTrackingInterceptor(null, name2, connectionTrackingCoordinator,
this);
           unshareableResources = new HashSet();
  +        connectionTrackingCoordinator.setUnshareableResources(unshareableResources);
           transactionManager = new TransactionManagerImpl();
       }
   
  @@ -111,7 +112,7 @@
   
       public void testSimpleComponentContextLifecyle() throws Exception {
           DefaultComponentContext componentContext = new DefaultComponentContext();
  -        ConnectorComponentContext oldComponentContext = connectionTrackingCoordinator.enter(componentContext,
unshareableResources);
  +        ConnectorComponentContext oldComponentContext = connectionTrackingCoordinator.enter(componentContext);
           assertNull("Expected old component context to be null", oldComponentContext);
           //give the context a ConnectionInfo
           ManagedConnectionInfo managedConnectionInfo = new ManagedConnectionInfo(null, null);
  @@ -124,7 +125,7 @@
           assertTrue("Expected to get supplied ConnectionInfo from infos", connectionInfo
== infos.iterator().next());
   
           //Enter again, and close the handle
  -        oldComponentContext = connectionTrackingCoordinator.enter(componentContext, unshareableResources);
  +        oldComponentContext = connectionTrackingCoordinator.enter(componentContext);
           assertNull("Expected old component context to be null", oldComponentContext);
           connectionTrackingCoordinator.handleReleased(key1, connectionInfo);
           connectionTrackingCoordinator.exit(oldComponentContext, unshareableResources);
  @@ -135,7 +136,7 @@
   
       public void testNestedComponentContextLifecyle() throws Exception {
           DefaultComponentContext componentContext1 = new DefaultComponentContext();
  -        ConnectorComponentContext oldComponentContext1 = connectionTrackingCoordinator.enter(componentContext1,
unshareableResources);
  +        ConnectorComponentContext oldComponentContext1 = connectionTrackingCoordinator.enter(componentContext1);
           assertNull("Expected old component context to be null", oldComponentContext1);
           //give the context a ConnectionInfo
           ManagedConnectionInfo managedConnectionInfo1 = new ManagedConnectionInfo(null,
null);
  @@ -144,7 +145,7 @@
   
           //Simulate calling another component
           DefaultComponentContext componentContext2 = new DefaultComponentContext();
  -        ConnectorComponentContext oldComponentContext2 = connectionTrackingCoordinator.enter(componentContext2,
unshareableResources);
  +        ConnectorComponentContext oldComponentContext2 = connectionTrackingCoordinator.enter(componentContext2);
           assertTrue("Expected returned component context to be componentContext1", oldComponentContext2
== componentContext1);
           //give the context a ConnectionInfo
           ManagedConnectionInfo managedConnectionInfo2 = new ManagedConnectionInfo(null,
null);
  @@ -167,7 +168,7 @@
           assertEquals("Expected no connection for key2", null, connectionManagerMap1.get(key2));
   
           //Enter again, and close the handle
  -        oldComponentContext1 = connectionTrackingCoordinator.enter(componentContext1, unshareableResources);
  +        oldComponentContext1 = connectionTrackingCoordinator.enter(componentContext1);
           assertNull("Expected old component context to be null", oldComponentContext1);
           connectionTrackingCoordinator.handleReleased(key1, connectionInfo1);
           connectionTrackingCoordinator.exit(oldComponentContext1, unshareableResources);
  @@ -177,6 +178,8 @@
       }
   
       public void testSimpleTransactionContextLifecycle() throws Exception {
  +        DefaultComponentContext componentContext = new DefaultComponentContext();
  +        ConnectorComponentContext oldComponentContext = connectionTrackingCoordinator.enter(componentContext);
           transactionManager.begin();
           Transaction transaction = transactionManager.getTransaction();
           DefaultTransactionContext transactionContext = new DefaultTransactionContext(transaction);
  
  
  

Mime
View raw message