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/connector/src/java/org/apache/geronimo/connector/outbound/connectiontracking ConnectionTrackingCoordinator.java
Date Mon, 31 May 2004 23:37:06 GMT
djencks     2004/05/31 16:37:06

  Modified:    modules/transaction/src/java/org/apache/geronimo/transaction
                        InstanceContext.java TransactionContext.java
                        UnspecifiedTransactionContext.java
               modules/jetty/src/java/org/apache/geronimo/jetty
                        JettyWebApplicationContext.java
               modules/connector/src/test/org/apache/geronimo/connector/outbound
                        ConnectionManagerStressTest.java
                        ConnectionManagerTestUtils.java
               modules/connector/src/test/org/apache/geronimo/connector/outbound/connectiontracking
                        ConnectionTrackingCoordinatorTest.java
               modules/connector/src/java/org/apache/geronimo/connector/outbound/connectiontracking
                        ConnectionTrackingCoordinator.java
  Added:       modules/transaction/src/java/org/apache/geronimo/transaction
                        DefaultInstanceContext.java
  Removed:     modules/connector/src/java/org/apache/geronimo/connector/outbound/connectiontracking/defaultimpl
                        DefaultComponentContext.java
  Log:
  Move DefaultInstanceContext to a more public place. Change Exception to Throwable to match
Interceptor signature.
  
  Revision  Changes    Path
  1.6       +3 -3      incubator-geronimo/modules/transaction/src/java/org/apache/geronimo/transaction/InstanceContext.java
  
  Index: InstanceContext.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/transaction/src/java/org/apache/geronimo/transaction/InstanceContext.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- InstanceContext.java	31 May 2004 16:27:44 -0000	1.5
  +++ InstanceContext.java	31 May 2004 23:37:05 -0000	1.6
  @@ -33,9 +33,9 @@
   
       Object getContainerId();
   
  -    void associate() throws Exception;
  +    void associate() throws Throwable;
   
  -    void flush() throws Exception;
  +    void flush() throws Throwable;
   
       void beforeCommit() throws Exception;
   
  
  
  
  1.7       +4 -4      incubator-geronimo/modules/transaction/src/java/org/apache/geronimo/transaction/TransactionContext.java
  
  Index: TransactionContext.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/transaction/src/java/org/apache/geronimo/transaction/TransactionContext.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- TransactionContext.java	11 Apr 2004 17:00:05 -0000	1.6
  +++ TransactionContext.java	31 May 2004 23:37:05 -0000	1.7
  @@ -21,6 +21,7 @@
   import java.util.HashMap;
   import java.util.Iterator;
   import java.util.Map;
  +
   import javax.transaction.HeuristicMixedException;
   import javax.transaction.HeuristicRollbackException;
   import javax.transaction.InvalidTransactionException;
  @@ -31,7 +32,6 @@
   
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
  -
   import org.tranql.cache.InTxCache;
   import org.tranql.cache.SimpleFlushStrategy;
   
  @@ -69,7 +69,7 @@
   
       public abstract void rollback() throws SystemException;
   
  -    public final void associate(InstanceContext context) throws Exception {
  +    public final void associate(InstanceContext context) throws Throwable {
           if (associatedContexts.put(context.getContainerId(), context.getId(), context)
== null) {
               context.associate();
           }
  @@ -93,7 +93,7 @@
           currentContext = caller;
       }
   
  -    public final void flushState() throws Exception {
  +    public final void flushState() throws Throwable {
           while (dirtyContexts.isEmpty() == false) {
               ArrayList toFlush = new ArrayList(dirtyContexts.values());
               dirtyContexts.clear();
  
  
  
  1.4       +6 -2      incubator-geronimo/modules/transaction/src/java/org/apache/geronimo/transaction/UnspecifiedTransactionContext.java
  
  Index: UnspecifiedTransactionContext.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/transaction/src/java/org/apache/geronimo/transaction/UnspecifiedTransactionContext.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- UnspecifiedTransactionContext.java	10 Mar 2004 09:59:36 -0000	1.3
  +++ UnspecifiedTransactionContext.java	31 May 2004 23:37:05 -0000	1.4
  @@ -41,7 +41,11 @@
       public void commit() {
           try {
               flushState();
  -        } catch (Exception e) {
  +        } catch (Error e) {
  +            throw e;
  +        } catch (RuntimeException re) {
  +            throw re;
  +        } catch (Throwable e) {
               log.error("Unable to flush state, continuing", e);
           }
       }
  
  
  
  1.1                  incubator-geronimo/modules/transaction/src/java/org/apache/geronimo/transaction/DefaultInstanceContext.java
  
  Index: DefaultInstanceContext.java
  ===================================================================
  /**
   *
   * Copyright 2003-2004 The Apache Software Foundation
   *
   *  Licensed 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.geronimo.transaction;
  
  import java.util.HashMap;
  import java.util.Map;
  import java.util.Set;
  
  import org.apache.geronimo.transaction.InstanceContext;
  
  
  /**
   * Simple implementation of ComponentContext satisfying invariant.
   *
   * @version $Revision: 1.1 $ $Date: 2004/05/31 23:37:05 $
   *
   * */
  public class DefaultInstanceContext implements InstanceContext {
  
      private final Map connectionManagerMap = new HashMap();
      private final Set unshareableResources;
      private final Set applicationManagedSecurityResources;
  
      public DefaultInstanceContext(Set unshareableResources, Set applicationManagedSecurityResources)
{
          this.unshareableResources = unshareableResources;
          this.applicationManagedSecurityResources = applicationManagedSecurityResources;
      }
  
      public Object getId() {
          return null;
      }
  
      public void setId(Object id) {
      }
  
      public Object getContainerId() {
          return null;
      }
  
      public void associate() throws Exception {
      }
  
      public void flush() throws Exception {
      }
  
      public void beforeCommit() throws Exception {
      }
  
      public void afterCommit(boolean status) throws Exception {
      }
  
      public Map getConnectionManagerMap() {
          return connectionManagerMap;
      }
  
      public Set getUnshareableResources() {
          return unshareableResources;
      }
  
      public Set getApplicationManagedSecurityResources() {
          return applicationManagedSecurityResources;
      }
  
  }
  
  
  
  1.17      +3 -3      incubator-geronimo/modules/jetty/src/java/org/apache/geronimo/jetty/JettyWebApplicationContext.java
  
  Index: JettyWebApplicationContext.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/jetty/src/java/org/apache/geronimo/jetty/JettyWebApplicationContext.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- JettyWebApplicationContext.java	31 May 2004 16:27:44 -0000	1.16
  +++ JettyWebApplicationContext.java	31 May 2004 23:37:05 -0000	1.17
  @@ -33,7 +33,7 @@
   
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
  -import org.apache.geronimo.connector.outbound.connectiontracking.defaultimpl.DefaultComponentContext;
  +import org.apache.geronimo.transaction.DefaultInstanceContext;
   import org.apache.geronimo.gbean.GBean;
   import org.apache.geronimo.gbean.GBeanContext;
   import org.apache.geronimo.gbean.GBeanInfo;
  @@ -188,7 +188,7 @@
                   TransactionContext.setContext(new UnspecifiedTransactionContext());
               }
               try {
  -                oldInstanceContext = associator.enter(new DefaultComponentContext(unshareableResources,
applicationManagedSecurityResources));
  +                oldInstanceContext = associator.enter(new DefaultInstanceContext(unshareableResources,
applicationManagedSecurityResources));
               } catch (ResourceException e) {
                   throw new RuntimeException(e);
               }
  
  
  
  1.4       +3 -3      incubator-geronimo/modules/connector/src/test/org/apache/geronimo/connector/outbound/ConnectionManagerStressTest.java
  
  Index: ConnectionManagerStressTest.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/connector/src/test/org/apache/geronimo/connector/outbound/ConnectionManagerStressTest.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ConnectionManagerStressTest.java	31 May 2004 16:27:44 -0000	1.3
  +++ ConnectionManagerStressTest.java	31 May 2004 23:37:05 -0000	1.4
  @@ -21,7 +21,7 @@
   
   import org.apache.geronimo.transaction.TransactionContext;
   import org.apache.geronimo.transaction.UnspecifiedTransactionContext;
  -import org.apache.geronimo.connector.outbound.connectiontracking.defaultimpl.DefaultComponentContext;
  +import org.apache.geronimo.transaction.DefaultInstanceContext;
   import org.apache.commons.logging.LogFactory;
   import org.apache.commons.logging.Log;
   
  @@ -75,7 +75,7 @@
                           for (int i = 0; i < repeatCount; i++) {
                               try {
                                   long start = System.currentTimeMillis();
  -                                defaultComponentInterceptor.invoke(new DefaultComponentContext(new
HashSet(), new HashSet()));
  +                                defaultComponentInterceptor.invoke(new DefaultInstanceContext(new
HashSet(), new HashSet()));
                                   long duration = System.currentTimeMillis() - start;
                                   if (duration > 100) {
                                       localSlowCount++;
  
  
  
  1.12      +4 -4      incubator-geronimo/modules/connector/src/test/org/apache/geronimo/connector/outbound/ConnectionManagerTestUtils.java
  
  Index: ConnectionManagerTestUtils.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/connector/src/test/org/apache/geronimo/connector/outbound/ConnectionManagerTestUtils.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- ConnectionManagerTestUtils.java	31 May 2004 16:27:44 -0000	1.11
  +++ ConnectionManagerTestUtils.java	31 May 2004 23:37:05 -0000	1.12
  @@ -35,7 +35,7 @@
   import org.apache.geronimo.connector.outbound.connectiontracking.ConnectionTrackingCoordinator;
   import org.apache.geronimo.connector.outbound.connectiontracking.DefaultComponentInterceptor;
   import org.apache.geronimo.connector.outbound.connectiontracking.DefaultInterceptor;
  -import org.apache.geronimo.connector.outbound.connectiontracking.defaultimpl.DefaultComponentContext;
  +import org.apache.geronimo.transaction.DefaultInstanceContext;
   import org.apache.geronimo.security.ContextManager;
   import org.apache.geronimo.security.bridge.RealmBridge;
   import org.apache.geronimo.transaction.InstanceContext;
  @@ -68,7 +68,7 @@
       protected AbstractConnectionManager connectionManagerDeployment;
       protected MockConnectionFactory connectionFactory;
       protected MockManagedConnectionFactory mockManagedConnectionFactory;
  -    protected DefaultComponentContext defaultComponentContext;
  +    protected DefaultInstanceContext defaultComponentContext;
       protected DefaultComponentInterceptor defaultComponentInterceptor;
       protected Set unshareableResources = new HashSet();
       protected Set applicationManagedSecurityResources = new HashSet();
  @@ -101,7 +101,7 @@
                   connectionTrackingCoordinator);
           connectionManagerDeployment.doStart();
           connectionFactory = (MockConnectionFactory) connectionManagerDeployment.createConnectionFactory(mockManagedConnectionFactory);
  -        defaultComponentContext = new DefaultComponentContext(unshareableResources, applicationManagedSecurityResources);
  +        defaultComponentContext = new DefaultInstanceContext(unshareableResources, applicationManagedSecurityResources);
           defaultComponentInterceptor = new DefaultComponentInterceptor(this, connectionTrackingCoordinator);
       }
   
  
  
  
  1.8       +5 -5      incubator-geronimo/modules/connector/src/test/org/apache/geronimo/connector/outbound/connectiontracking/ConnectionTrackingCoordinatorTest.java
  
  Index: ConnectionTrackingCoordinatorTest.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/connector/src/test/org/apache/geronimo/connector/outbound/connectiontracking/ConnectionTrackingCoordinatorTest.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- ConnectionTrackingCoordinatorTest.java	31 May 2004 16:27:44 -0000	1.7
  +++ ConnectionTrackingCoordinatorTest.java	31 May 2004 23:37:05 -0000	1.8
  @@ -30,7 +30,7 @@
   import org.apache.geronimo.connector.outbound.ConnectionReturnAction;
   import org.apache.geronimo.connector.outbound.ConnectionTrackingInterceptor;
   import org.apache.geronimo.connector.outbound.ManagedConnectionInfo;
  -import org.apache.geronimo.connector.outbound.connectiontracking.defaultimpl.DefaultComponentContext;
  +import org.apache.geronimo.transaction.DefaultInstanceContext;
   import org.apache.geronimo.transaction.InstanceContext;
   
   /**
  @@ -66,7 +66,7 @@
       }
   
       public void testSimpleComponentContextLifecyle() throws Exception {
  -        DefaultComponentContext componentContext = new DefaultComponentContext(unshareableResources,
applicationManagedSecurityResources);
  +        DefaultInstanceContext componentContext = new DefaultInstanceContext(unshareableResources,
applicationManagedSecurityResources);
           InstanceContext oldInstanceContext = connectionTrackingCoordinator.enter(componentContext);
           assertNull("Expected old instance context to be null", oldInstanceContext);
           //give the context a ConnectionInfo
  @@ -90,7 +90,7 @@
       }
   
       public void testNestedComponentContextLifecyle() throws Exception {
  -        DefaultComponentContext componentContext1 = new DefaultComponentContext(unshareableResources,
applicationManagedSecurityResources);
  +        DefaultInstanceContext componentContext1 = new DefaultInstanceContext(unshareableResources,
applicationManagedSecurityResources);
           InstanceContext oldInstanceContext1 = connectionTrackingCoordinator.enter(componentContext1);
           assertNull("Expected old component context to be null", oldInstanceContext1);
           //give the context a ConnectionInfo
  @@ -99,7 +99,7 @@
           connectionTrackingCoordinator.handleObtained(key1, connectionInfo1);
   
           //Simulate calling another component
  -        DefaultComponentContext componentContext2 = new DefaultComponentContext(unshareableResources,
applicationManagedSecurityResources);
  +        DefaultInstanceContext componentContext2 = new DefaultInstanceContext(unshareableResources,
applicationManagedSecurityResources);
           InstanceContext oldInstanceContext2 = connectionTrackingCoordinator.enter(componentContext2);
           assertTrue("Expected returned component context to be componentContext1", oldInstanceContext2
== componentContext1);
           //give the context a ConnectionInfo
  
  
  
  1.10      +9 -7      incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/outbound/connectiontracking/ConnectionTrackingCoordinator.java
  
  Index: ConnectionTrackingCoordinator.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/outbound/connectiontracking/ConnectionTrackingCoordinator.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- ConnectionTrackingCoordinator.java	31 May 2004 16:27:43 -0000	1.9
  +++ ConnectionTrackingCoordinator.java	31 May 2004 23:37:06 -0000	1.10
  @@ -126,12 +126,14 @@
   
       public void setEnvironment(ConnectionInfo connectionInfo, String key) {
           InstanceContext currentInstanceContext = (InstanceContext) currentInstanceContexts.get();
  -        Set unshareableResources = currentInstanceContext.getUnshareableResources();
  -        boolean unshareable = unshareableResources.contains(key);
  -        connectionInfo.setUnshareable(unshareable);
  -        Set applicationManagedSecurityResources = currentInstanceContext.getApplicationManagedSecurityResources();
  -        boolean applicationManagedSecurity = applicationManagedSecurityResources.contains(key);
  -        connectionInfo.setApplicationManagedSecurity(applicationManagedSecurity);
  +        if (currentInstanceContext != null) {
  +            Set unshareableResources = currentInstanceContext.getUnshareableResources();
  +            boolean unshareable = unshareableResources.contains(key);
  +            connectionInfo.setUnshareable(unshareable);
  +            Set applicationManagedSecurityResources = currentInstanceContext.getApplicationManagedSecurityResources();
  +            boolean applicationManagedSecurity = applicationManagedSecurityResources.contains(key);
  +            connectionInfo.setApplicationManagedSecurity(applicationManagedSecurity);
  +        }
       }
   
       static {
  
  
  

Mime
View raw message