geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r705104 - in /geronimo/components/txmanager/trunk: ./ geronimo-connector/ geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/ geronimo-connector/src/main/java/org/apache/geronimo/connector/work/ geronimo-connector/src/t...
Date Thu, 16 Oct 2008 00:14:11 GMT
Author: djencks
Date: Wed Oct 15 17:14:10 2008
New Revision: 705104

URL: http://svn.apache.org/viewvc?rev=705104&view=rev
Log:
update to connector 1.6 api jar.  Implement InflowContext handling.  Implementation of new
LazyAssociatableConnectionManager.inactiveConnectionClosed method not done.... I don't see
why its necessary yet

Added:
    geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/work/InflowContextHandler.java
  (with props)
    geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/work/TransactionInflowContextHandler.java
  (with props)
Modified:
    geronimo/components/txmanager/trunk/geronimo-connector/pom.xml
    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/work/GeronimoWorkManager.java
    geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/work/WorkerContext.java
    geronimo/components/txmanager/trunk/geronimo-connector/src/test/java/org/apache/geronimo/connector/BootstrapContextTest.java
    geronimo/components/txmanager/trunk/geronimo-connector/src/test/java/org/apache/geronimo/connector/work/PooledWorkManagerTest.java
    geronimo/components/txmanager/trunk/geronimo-transaction/pom.xml
    geronimo/components/txmanager/trunk/pom.xml

Modified: geronimo/components/txmanager/trunk/geronimo-connector/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/components/txmanager/trunk/geronimo-connector/pom.xml?rev=705104&r1=705103&r2=705104&view=diff
==============================================================================
--- geronimo/components/txmanager/trunk/geronimo-connector/pom.xml (original)
+++ geronimo/components/txmanager/trunk/geronimo-connector/pom.xml Wed Oct 15 17:14:10 2008
@@ -51,9 +51,9 @@
 
         <dependency>
             <groupId>org.apache.geronimo.specs</groupId>
-            <artifactId>geronimo-j2ee-connector_1.5_spec</artifactId>
+            <artifactId>geronimo-j2ee-connector_1.6_spec</artifactId>
         </dependency>
-        
+
         <dependency>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>

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=705104&r1=705103&r2=705104&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
Wed Oct 15 17:14:10 2008
@@ -111,6 +111,11 @@
         getStack().getConnection(ci);
     }
 
+    public void inactiveConnectionClosed(Object connection, ManagedConnectionFactory managedConnectionFactory)
{
+        //TODO If we are tracking connections, we need to stop tracking this one.
+        //I don't see why we don't get a connectionClosed event for it.
+    }
+
     ConnectionInterceptor getConnectionInterceptor() {
         return getStack();
     }

Modified: geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/work/GeronimoWorkManager.java
URL: http://svn.apache.org/viewvc/geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/work/GeronimoWorkManager.java?rev=705104&r1=705103&r2=705104&view=diff
==============================================================================
--- geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/work/GeronimoWorkManager.java
(original)
+++ geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/work/GeronimoWorkManager.java
Wed Oct 15 17:14:10 2008
@@ -18,6 +18,8 @@
 package org.apache.geronimo.connector.work;
 
 import java.util.concurrent.Executor;
+import java.util.List;
+import java.util.Collections;
 
 import javax.resource.spi.work.ExecutionContext;
 import javax.resource.spi.work.Work;
@@ -30,7 +32,6 @@
 import org.apache.geronimo.connector.work.pool.StartWorkExecutor;
 import org.apache.geronimo.connector.work.pool.SyncWorkExecutor;
 import org.apache.geronimo.connector.work.pool.WorkExecutor;
-import org.apache.geronimo.transaction.manager.XAWork;
 
 /**
  * WorkManager implementation which uses under the cover three WorkExecutorPool
@@ -64,7 +65,8 @@
      */
     private Executor scheduledWorkExecutorPool;
 
-    private final XAWork transactionManager;
+    private final List<InflowContextHandler> inflowContextHandlers;
+
 
     private final WorkExecutor scheduleWorkExecutor = new ScheduleWorkExecutor();
     private final WorkExecutor startWorkExecutor = new StartWorkExecutor();
@@ -77,11 +79,11 @@
         this(null, null, null, null);
     }
 
-    public GeronimoWorkManager(Executor sync, Executor start, Executor sched, XAWork xaWork)
{
+    public GeronimoWorkManager(Executor sync, Executor start, Executor sched, List<InflowContextHandler>
inflowContextHandlers) {
         syncWorkExecutorPool = sync;
         startWorkExecutorPool = start;
         scheduledWorkExecutorPool = sched;
-        this.transactionManager = xaWork;
+        this.inflowContextHandlers = inflowContextHandlers == null? Collections.<InflowContextHandler>emptyList():
inflowContextHandlers;
     }
 
     public void doStart() throws Exception {
@@ -114,7 +116,7 @@
     * @see javax.resource.spi.work.WorkManager#doWork(javax.resource.spi.work.Work)
     */
     public void doWork(Work work) throws WorkException {
-        executeWork(new WorkerContext(work, transactionManager), syncWorkExecutor, syncWorkExecutorPool);
+        executeWork(new WorkerContext(work, inflowContextHandlers), syncWorkExecutor, syncWorkExecutorPool);
     }
 
     /* (non-Javadoc)
@@ -127,7 +129,7 @@
             WorkListener workListener)
             throws WorkException {
         WorkerContext workWrapper =
-                new WorkerContext(work, startTimeout, execContext, transactionManager, workListener);
+                new WorkerContext(work, startTimeout, execContext, workListener, inflowContextHandlers);
         workWrapper.setThreadPriority(Thread.currentThread().getPriority());
         executeWork(workWrapper, syncWorkExecutor, syncWorkExecutorPool);
     }
@@ -136,7 +138,7 @@
      * @see javax.resource.spi.work.WorkManager#startWork(javax.resource.spi.work.Work)
      */
     public long startWork(Work work) throws WorkException {
-        WorkerContext workWrapper = new WorkerContext(work, transactionManager);
+        WorkerContext workWrapper = new WorkerContext(work, inflowContextHandlers);
         workWrapper.setThreadPriority(Thread.currentThread().getPriority());
         executeWork(workWrapper, startWorkExecutor, startWorkExecutorPool);
         return System.currentTimeMillis() - workWrapper.getAcceptedTime();
@@ -152,7 +154,7 @@
             WorkListener workListener)
             throws WorkException {
         WorkerContext workWrapper =
-                new WorkerContext(work, startTimeout, execContext, transactionManager, workListener);
+                new WorkerContext(work, startTimeout, execContext, workListener, inflowContextHandlers);
         workWrapper.setThreadPriority(Thread.currentThread().getPriority());
         executeWork(workWrapper, startWorkExecutor, startWorkExecutorPool);
         return System.currentTimeMillis() - workWrapper.getAcceptedTime();
@@ -162,7 +164,7 @@
      * @see javax.resource.spi.work.WorkManager#scheduleWork(javax.resource.spi.work.Work)
      */
     public void scheduleWork(Work work) throws WorkException {
-        WorkerContext workWrapper = new WorkerContext(work, transactionManager);
+        WorkerContext workWrapper = new WorkerContext(work, inflowContextHandlers);
         workWrapper.setThreadPriority(Thread.currentThread().getPriority());
         executeWork(workWrapper, scheduleWorkExecutor, scheduledWorkExecutorPool);
     }
@@ -177,7 +179,7 @@
             WorkListener workListener)
             throws WorkException {
         WorkerContext workWrapper =
-                new WorkerContext(work, startTimeout, execContext, transactionManager, workListener);
+                new WorkerContext(work, startTimeout, execContext, workListener, inflowContextHandlers);
         workWrapper.setThreadPriority(Thread.currentThread().getPriority());
         executeWork(workWrapper, scheduleWorkExecutor, scheduledWorkExecutorPool);
     }

Added: geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/work/InflowContextHandler.java
URL: http://svn.apache.org/viewvc/geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/work/InflowContextHandler.java?rev=705104&view=auto
==============================================================================
--- geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/work/InflowContextHandler.java
(added)
+++ geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/work/InflowContextHandler.java
Wed Oct 15 17:14:10 2008
@@ -0,0 +1,37 @@
+/*
+ * 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.geronimo.connector.work;
+
+import javax.resource.spi.work.InflowContext;
+import javax.resource.spi.work.WorkCompletedException;
+
+/**
+ * @version $Rev:$ $Date:$
+ */
+public interface InflowContextHandler<E extends InflowContext> {
+
+    void before(E inflowContext) throws WorkCompletedException;
+
+    void after(E inflowContext) throws WorkCompletedException;
+
+    Class<E> getHandledClass(); 
+
+}

Propchange: geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/work/InflowContextHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/work/InflowContextHandler.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/work/InflowContextHandler.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/work/TransactionInflowContextHandler.java
URL: http://svn.apache.org/viewvc/geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/work/TransactionInflowContextHandler.java?rev=705104&view=auto
==============================================================================
--- geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/work/TransactionInflowContextHandler.java
(added)
+++ geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/work/TransactionInflowContextHandler.java
Wed Oct 15 17:14:10 2008
@@ -0,0 +1,76 @@
+/*
+ * 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.geronimo.connector.work;
+
+import javax.resource.spi.work.TransactionInflowContext;
+import javax.resource.spi.work.WorkCompletedException;
+import javax.transaction.xa.XAException;
+import javax.transaction.InvalidTransactionException;
+import javax.transaction.SystemException;
+
+import org.apache.geronimo.transaction.manager.XAWork;
+import org.apache.geronimo.transaction.manager.ImportedTransactionActiveException;
+
+/**
+ * @version $Rev:$ $Date:$
+ */
+public class TransactionInflowContextHandler implements InflowContextHandler<TransactionInflowContext>{
+
+    private final XAWork xaWork;
+
+    public TransactionInflowContextHandler(XAWork xaWork) {
+        this.xaWork = xaWork;
+    }
+
+    public void before(TransactionInflowContext inflowContext) throws WorkCompletedException
{
+        if (inflowContext.getXid() != null) {
+            try {
+                long transactionTimeout = inflowContext.getTransactionTimeout();
+                //translate -1 value to 0 to indicate default transaction timeout.
+                xaWork.begin(inflowContext.getXid(), transactionTimeout < 0 ? 0 : transactionTimeout);
+            } catch (XAException e) {
+                throw (WorkCompletedException)new WorkCompletedException("Transaction import
failed for xid " + inflowContext.getXid(), WorkCompletedException.TX_RECREATE_FAILED).initCause(e);
+            } catch (InvalidTransactionException e) {
+                throw (WorkCompletedException)new WorkCompletedException("Transaction import
failed for xid " + inflowContext.getXid(), WorkCompletedException.TX_RECREATE_FAILED).initCause(e);
+            } catch (SystemException e) {
+                throw (WorkCompletedException)new WorkCompletedException("Transaction import
failed for xid " + inflowContext.getXid(), WorkCompletedException.TX_RECREATE_FAILED).initCause(e);
+            } catch (ImportedTransactionActiveException e) {
+                throw (WorkCompletedException)new WorkCompletedException("Transaction already
active for xid " + inflowContext.getXid(), WorkCompletedException.TX_CONCURRENT_WORK_DISALLOWED).initCause(e);
+            }
+        }
+    }
+
+    public void after(TransactionInflowContext inflowContext) throws WorkCompletedException
{
+        if (inflowContext.getXid() != null) {
+            try {
+                xaWork.end(inflowContext.getXid());
+            } catch (XAException e) {
+                throw (WorkCompletedException)new WorkCompletedException("Transaction end
failed for xid " + inflowContext.getXid(), WorkCompletedException.TX_RECREATE_FAILED).initCause(e);
+            } catch (SystemException e) {
+                throw (WorkCompletedException)new WorkCompletedException("Transaction end
failed for xid " + inflowContext.getXid(), WorkCompletedException.TX_RECREATE_FAILED).initCause(e);
+            }
+        }
+    }
+
+    public Class<TransactionInflowContext> getHandledClass() {
+        return TransactionInflowContext.class;
+    }
+}

Propchange: geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/work/TransactionInflowContextHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/work/TransactionInflowContextHandler.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/work/TransactionInflowContextHandler.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/work/WorkerContext.java
URL: http://svn.apache.org/viewvc/geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/work/WorkerContext.java?rev=705104&r1=705103&r2=705104&view=diff
==============================================================================
--- geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/work/WorkerContext.java
(original)
+++ geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/work/WorkerContext.java
Wed Oct 15 17:14:10 2008
@@ -17,9 +17,17 @@
 
 package org.apache.geronimo.connector.work;
 
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
 import java.util.concurrent.CountDownLatch;
 
+import javax.resource.NotSupportedException;
 import javax.resource.spi.work.ExecutionContext;
+import javax.resource.spi.work.InflowContext;
+import javax.resource.spi.work.InflowContextProvider;
+import javax.resource.spi.work.TransactionInflowContext;
 import javax.resource.spi.work.Work;
 import javax.resource.spi.work.WorkAdapter;
 import javax.resource.spi.work.WorkCompletedException;
@@ -28,12 +36,7 @@
 import javax.resource.spi.work.WorkListener;
 import javax.resource.spi.work.WorkManager;
 import javax.resource.spi.work.WorkRejectedException;
-import javax.transaction.InvalidTransactionException;
-import javax.transaction.SystemException;
-import javax.transaction.xa.XAException;
 
-import org.apache.geronimo.transaction.manager.ImportedTransactionActiveException;
-import org.apache.geronimo.transaction.manager.XAWork;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -46,6 +49,8 @@
 
     private static final Logger log = LoggerFactory.getLogger(WorkerContext.class);
 
+    private static final List<InflowContext> NO_INFLOW_CONTEXT = Collections.emptyList();
+
     /**
      * Null WorkListener used as the default WorkListener.
      */
@@ -93,16 +98,9 @@
     private long startTimeOut;
 
     /**
-     * Execution context of the actual work to be executed.
-     */
-    private final ExecutionContext executionContext;
-
-    private final XAWork xaWork;
-
-    /**
      * Listener to be notified during the life-cycle of the work treatment.
      */
-    private WorkListener workListener = NULL_WORK_LISTENER;
+    private final WorkListener workListener;
 
     /**
      * Work exception, if any.
@@ -120,40 +118,59 @@
     private CountDownLatch endLatch = new CountDownLatch(1);
 
     /**
+     * Execution context of the actual work to be executed.
+     */
+    private final ExecutionContext executionContext;
+
+    private final List<InflowContextHandler> inflowContextHandlers;
+
+
+    /**
      * Create a WorkWrapper.
-     *
-     * @param work                      Work to be wrapped.
-     * @param xaWork
+     * TODO include a InflowContextLifecycleListener
+     * @param work   Work to be wrapped.
+     * @param inflowContextHandlers InflowContextHandlers supported by this work manager
      */
-    public WorkerContext(Work work, XAWork xaWork) {
+    public WorkerContext(Work work, List<InflowContextHandler> inflowContextHandlers)
{
         adaptee = work;
+        this.inflowContextHandlers = inflowContextHandlers;
         executionContext = null;
-        this.xaWork = xaWork;
+        workListener = NULL_WORK_LISTENER;
     }
 
     /**
      * Create a WorkWrapper with the specified execution context.
      *
+     * TODO include a InflowContextLifecycleListener
      * @param aWork         Work to be wrapped.
      * @param aStartTimeout a time duration (in milliseconds) within which the
-     *                      execution of the Work instance must start.
+ *                      execution of the Work instance must start.
      * @param execContext   an object containing the execution context with which
-     *                      the submitted Work instance must be executed.
+*                      the submitted Work instance must be executed.
      * @param workListener  an object which would be notified when the various
-     *                      Work processing events (work accepted, work rejected, work started,
+     * @param inflowContextHandlers InflowContextHandlers supported by this work manager
+     * @throws javax.resource.spi.work.WorkRejectedException if executionContext supplied
yet Work implements InflowContextProvider
      */
     public WorkerContext(Work aWork,
                          long aStartTimeout,
                          ExecutionContext execContext,
-                         XAWork xaWork,
-                         WorkListener workListener) {
+                         WorkListener workListener, List<InflowContextHandler> inflowContextHandlers)
throws WorkRejectedException {
         adaptee = aWork;
         startTimeOut = aStartTimeout;
-        executionContext = execContext;
-        this.xaWork = xaWork;
-        if (null != workListener) {
+        if (null == workListener) {
+            this.workListener = NULL_WORK_LISTENER;
+        } else {
             this.workListener = workListener;
         }
+        if (aWork instanceof InflowContextProvider) {
+            if (execContext != null) {
+                throw new WorkRejectedException("Execution context provided but Work implements
InflowContextProvider");
+            }
+            executionContext = null;
+        } else {
+            executionContext = execContext;
+        }
+        this.inflowContextHandlers = inflowContextHandlers;
     }
 
     /* (non-Javadoc)
@@ -229,7 +246,7 @@
      * @return true if the Work has timed out and false otherwise.
      */
     public synchronized boolean isTimedOut() {
-        assert isAccepted: "The work is not accepted.";
+        assert isAccepted : "The work is not accepted.";
         // A value of 0 means that the work never times out.
         //??? really?
         if (0 == startTimeOut || startTimeOut == WorkManager.INDEFINITE) {
@@ -278,6 +295,7 @@
             endLatch.countDown();
             return;
         }
+
         // Implementation note: the work listener is notified prior to release
         // the start lock. This behavior is intentional and seems to be the
         // more conservative.
@@ -286,29 +304,50 @@
         //Implementation note: we assume this is being called without an interesting TransactionContext,
         //and ignore/replace whatever is associated with the current thread.
         try {
-            if (executionContext == null || executionContext.getXid() == null) {
-                adaptee.run();
-            } else {
+            List<InflowContext> inflowContexts = NO_INFLOW_CONTEXT;
+            if (executionContext != null) {
+                TransactionInflowContext txInflowContext = new TransactionInflowContext();
                 try {
-                    long transactionTimeout = executionContext.getTransactionTimeout();
-                    //translate -1 value to 0 to indicate default transaction timeout.
-                    xaWork.begin(executionContext.getXid(), transactionTimeout < 0 ? 0
: transactionTimeout);
-                } catch (XAException e) {
-                    throw new WorkCompletedException("Transaction import failed for xid "
+ executionContext.getXid(), WorkCompletedException.TX_RECREATE_FAILED).initCause(e);
-                } catch (InvalidTransactionException e) {
-                    throw new WorkCompletedException("Transaction import failed for xid "
+ executionContext.getXid(), WorkCompletedException.TX_RECREATE_FAILED).initCause(e);
-                } catch (SystemException e) {
-                    throw new WorkCompletedException("Transaction import failed for xid "
+ executionContext.getXid(), WorkCompletedException.TX_RECREATE_FAILED).initCause(e);
-                } catch (ImportedTransactionActiveException e) {
-                    throw new WorkCompletedException("Transaction already active for xid
" + executionContext.getXid(), WorkCompletedException.TX_CONCURRENT_WORK_DISALLOWED).initCause(e);
+                    txInflowContext.setTransactionTimeout(executionContext.getTransactionTimeout());
+                } catch (NotSupportedException e) {
+                    throw new WorkRejectedException("Could not read tx timeout");
                 }
-                try {
-                    adaptee.run();
-                } finally {
-                    xaWork.end(executionContext.getXid());
+                inflowContexts = Collections.<InflowContext>singletonList(txInflowContext);
+            } else if (adaptee instanceof InflowContextProvider) {
+                inflowContexts = ((InflowContextProvider) adaptee).getInflowContexts();
+            }
+            List<InflowContextHandler> sortedHandlers = new ArrayList<InflowContextHandler>(inflowContexts.size());
+            for (InflowContext inflowContext : inflowContexts) {
+                boolean found = false;
+                for (Iterator<InflowContextHandler> it = inflowContextHandlers.iterator();
it.hasNext();) {
+                    InflowContextHandler inflowContextHandler = it.next();
+                    //TODO is this the right way around?
+                    if (inflowContext.getClass().isAssignableFrom(inflowContextHandler.getHandledClass()))
{
+                        it.remove();
+                        sortedHandlers.add(inflowContextHandler);
+                        found = true;
+                        break;
+                    }
                 }
+                if (!found) {
+                    throw new WorkCompletedException("Duplicate or unhandled InflowContext:
" + inflowContext);
+                }
+            }
+            // TODO use a InflowContextLifecycleListener
 
+            int i = 0;
+            for (InflowContext inflowContext : inflowContexts) {
+                inflowContextHandlers.get(i).before(inflowContext);
+            }
+            try {
+                adaptee.run();
+            } finally {
+                int j = 0;
+                for (InflowContext inflowContext : inflowContexts) {
+                    inflowContextHandlers.get(j).after(inflowContext);
+                }
             }
+
             workListener.workCompleted(new WorkEvent(this, WorkEvent.WORK_COMPLETED, adaptee,
null));
         } catch (Throwable e) {
             workException = (WorkException) (e instanceof WorkCompletedException ? e : new
WorkCompletedException("Unknown error", WorkCompletedException.UNDEFINED).initCause(e));

Modified: geronimo/components/txmanager/trunk/geronimo-connector/src/test/java/org/apache/geronimo/connector/BootstrapContextTest.java
URL: http://svn.apache.org/viewvc/geronimo/components/txmanager/trunk/geronimo-connector/src/test/java/org/apache/geronimo/connector/BootstrapContextTest.java?rev=705104&r1=705103&r2=705104&view=diff
==============================================================================
--- geronimo/components/txmanager/trunk/geronimo-connector/src/test/java/org/apache/geronimo/connector/BootstrapContextTest.java
(original)
+++ geronimo/components/txmanager/trunk/geronimo-connector/src/test/java/org/apache/geronimo/connector/BootstrapContextTest.java
Wed Oct 15 17:14:10 2008
@@ -18,6 +18,7 @@
 package org.apache.geronimo.connector;
 
 import java.util.Timer;
+import java.util.Collections;
 import java.util.concurrent.RejectedExecutionException;
 import java.util.concurrent.RejectedExecutionHandler;
 import java.util.concurrent.SynchronousQueue;
@@ -30,6 +31,8 @@
 
 import junit.framework.TestCase;
 import org.apache.geronimo.connector.work.GeronimoWorkManager;
+import org.apache.geronimo.connector.work.TransactionInflowContextHandler;
+import org.apache.geronimo.connector.work.InflowContextHandler;
 import org.apache.geronimo.transaction.manager.GeronimoTransactionManager;
 import org.apache.geronimo.transaction.manager.XAWork;
 
@@ -94,7 +97,8 @@
      */
     public void testGetSetWorkManager() throws Exception {
         GeronimoTransactionManager transactionManager = new GeronimoTransactionManager();
-        GeronimoWorkManager manager = new GeronimoWorkManager(pool, pool, pool, transactionManager);
+        TransactionInflowContextHandler txInflowContextHandler = new TransactionInflowContextHandler(transactionManager);
+        GeronimoWorkManager manager = new GeronimoWorkManager(pool, pool, pool, Collections.<InflowContextHandler>singletonList(txInflowContextHandler));
         GeronimoBootstrapContext context = new GeronimoBootstrapContext(manager, transactionManager);
         WorkManager wm = context.getWorkManager();
 
@@ -106,7 +110,8 @@
      */
     public void testGetSetXATerminator() throws Exception {
         GeronimoTransactionManager transactionManager = new GeronimoTransactionManager();
-        GeronimoWorkManager manager = new GeronimoWorkManager(pool, pool, pool, transactionManager);
+        TransactionInflowContextHandler txInflowContextHandler = new TransactionInflowContextHandler(transactionManager);
+        GeronimoWorkManager manager = new GeronimoWorkManager(pool, pool, pool, Collections.<InflowContextHandler>singletonList(txInflowContextHandler));
         GeronimoBootstrapContext context = new GeronimoBootstrapContext(manager, transactionManager);
         XATerminator xat = context.getXATerminator();
 

Modified: geronimo/components/txmanager/trunk/geronimo-connector/src/test/java/org/apache/geronimo/connector/work/PooledWorkManagerTest.java
URL: http://svn.apache.org/viewvc/geronimo/components/txmanager/trunk/geronimo-connector/src/test/java/org/apache/geronimo/connector/work/PooledWorkManagerTest.java?rev=705104&r1=705103&r2=705104&view=diff
==============================================================================
--- geronimo/components/txmanager/trunk/geronimo-connector/src/test/java/org/apache/geronimo/connector/work/PooledWorkManagerTest.java
(original)
+++ geronimo/components/txmanager/trunk/geronimo-connector/src/test/java/org/apache/geronimo/connector/work/PooledWorkManagerTest.java
Wed Oct 15 17:14:10 2008
@@ -24,6 +24,7 @@
 import java.util.concurrent.ThreadFactory;
 import java.util.concurrent.ThreadPoolExecutor;
 import java.util.concurrent.TimeUnit;
+import java.util.Collections;
 
 import javax.resource.spi.work.ExecutionContext;
 import javax.resource.spi.work.Work;
@@ -51,6 +52,7 @@
         super.setUp();
         
         XAWork xaWork = new GeronimoTransactionManager();
+        TransactionInflowContextHandler txInflowContextHandler = new TransactionInflowContextHandler(xaWork);
         int poolSize = 1;
         int keepAliveTime = 30000;
         ThreadPoolExecutor pool = new ThreadPoolExecutor(
@@ -63,7 +65,7 @@
         pool.setThreadFactory(new ThreadPoolThreadFactory("Connector Test", getClass().getClassLoader()));
 
 
-        workManager = new GeronimoWorkManager(pool, pool, pool, xaWork);
+        workManager = new GeronimoWorkManager(pool, pool, pool, Collections.<InflowContextHandler>singletonList(txInflowContextHandler));
         workManager.doStart();
     }
 

Modified: geronimo/components/txmanager/trunk/geronimo-transaction/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/components/txmanager/trunk/geronimo-transaction/pom.xml?rev=705104&r1=705103&r2=705104&view=diff
==============================================================================
--- geronimo/components/txmanager/trunk/geronimo-transaction/pom.xml (original)
+++ geronimo/components/txmanager/trunk/geronimo-transaction/pom.xml Wed Oct 15 17:14:10 2008
@@ -54,10 +54,10 @@
             <artifactId>geronimo-jta_1.1_spec</artifactId>
         </dependency>
 
-        <dependency>
-            <groupId>org.apache.geronimo.specs</groupId>
-            <artifactId>geronimo-j2ee-connector_1.5_spec</artifactId>
-        </dependency>
+            <dependency>
+                <groupId>org.apache.geronimo.specs</groupId>
+                <artifactId>geronimo-j2ee-connector_1.6_spec</artifactId>
+            </dependency>
 
         <dependency>
             <groupId>org.objectweb.howl</groupId>

Modified: geronimo/components/txmanager/trunk/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/components/txmanager/trunk/pom.xml?rev=705104&r1=705103&r2=705104&view=diff
==============================================================================
--- geronimo/components/txmanager/trunk/pom.xml (original)
+++ geronimo/components/txmanager/trunk/pom.xml Wed Oct 15 17:14:10 2008
@@ -85,8 +85,8 @@
 
             <dependency>
                 <groupId>org.apache.geronimo.specs</groupId>
-                <artifactId>geronimo-j2ee-connector_1.5_spec</artifactId>
-                <version>2.0.0</version>
+                <artifactId>geronimo-j2ee-connector_1.6_spec</artifactId>
+                <version>1.0-EA-SNAPSHOT</version>
             </dependency>
 
             <dependency>



Mime
View raw message