Author: rfeng
Date: Fri Nov  9 16:16:46 2007
New Revision: 593697

URL: http://svn.apache.org/viewvc?rev=593697&view=rev
Log:
Add more logic to deal with the TX intents

Added:
    
incubator/tuscany/java/sca/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionManagerWrapper.java
   (with props)
    
incubator/tuscany/java/sca/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionalAction.java
   (with props)
Modified:
    incubator/tuscany/java/sca/modules/policy-transaction/pom.xml
    
incubator/tuscany/java/sca/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionManagerHelper.java
    
incubator/tuscany/java/sca/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionModuleActivator.java
    
incubator/tuscany/java/sca/modules/policy-transaction/src/test/java/org/apache/tuscany/sca/policy/transaction/PolicyReadTestCase.java
    
incubator/tuscany/java/sca/modules/policy-transaction/src/test/java/org/apache/tuscany/sca/policy/transaction/TransactionManagerHelperTestCase.java

Modified: incubator/tuscany/java/sca/modules/policy-transaction/pom.xml
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/policy-transaction/pom.xml?rev=593697&r1=593696&r2=593697&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/policy-transaction/pom.xml (original)
+++ incubator/tuscany/java/sca/modules/policy-transaction/pom.xml Fri Nov  9 
16:16:46 2007
@@ -1,76 +1,108 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
-       * 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.    
+    * 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.    
 -->
 <project>
-       <modelVersion>4.0.0</modelVersion>
-       <parent>
-               <groupId>org.apache.tuscany.sca</groupId>
-               <artifactId>tuscany-modules</artifactId>
-               <version>1.1-incubating-SNAPSHOT</version>
-               <relativePath>../pom.xml</relativePath>
-       </parent>
-       <artifactId>tuscany-policy-transaction</artifactId>
-       <name>Apache Tuscany Transaction Policy Model</name>
-
-       <dependencies>
-
-               <dependency>
-                       <groupId>org.apache.tuscany.sca</groupId>
-                       <artifactId>tuscany-contribution</artifactId>
-                       <version>1.1-incubating-SNAPSHOT</version>
-               </dependency>
-
-               <dependency>
-                       <groupId>org.apache.tuscany.sca</groupId>
-                       <artifactId>tuscany-assembly-xml</artifactId>
-                       <version>1.1-incubating-SNAPSHOT</version>
-               </dependency>
-
-               <dependency>
-                       <groupId>org.apache.geronimo.components</groupId>
-                       <artifactId>geronimo-transaction</artifactId>
-                       <version>2.0.2</version>
-               </dependency>
-
-               <dependency>
-                       <groupId>org.apache.tuscany.sca</groupId>
-                       <artifactId>tuscany-contribution-impl</artifactId>
-                       <version>1.1-incubating-SNAPSHOT</version>
-                       <scope>test</scope>
-               </dependency>
-
-               <!-- 
-                       <dependency>
-                       <groupId>jotm</groupId>
-                       <artifactId>jotm</artifactId>
-                       <version>2.0.10</version>
-                       <exclusions>
-                       <exclusion>
-                       <artifactId>jta</artifactId>
-                       <groupId>javax.transaction</groupId>
-                       </exclusion>
-                       <exclusion>
-                       <artifactId>connector</artifactId>
-                       <groupId>javax.resource</groupId>
-                       </exclusion>
-                       </exclusions>
-                       </dependency>
-               -->
-       </dependencies>
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.tuscany.sca</groupId>
+        <artifactId>tuscany-modules</artifactId>
+        <version>1.1-incubating-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+    <artifactId>tuscany-policy-transaction</artifactId>
+    <name>Apache Tuscany SCA Transaction Policy Model</name>
+
+    <dependencies>
+
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-contribution</artifactId>
+            <version>1.1-incubating-SNAPSHOT</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-assembly-xml</artifactId>
+            <version>1.1-incubating-SNAPSHOT</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.geronimo.components</groupId>
+            <artifactId>geronimo-transaction</artifactId>
+            <version>2.0.2</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.geronimo.components</groupId>
+            <artifactId>geronimo-connector</artifactId>
+            <version>2.0.2</version>
+        </dependency>
+        
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-contribution-impl</artifactId>
+            <version>1.1-incubating-SNAPSHOT</version>
+            <scope>test</scope>
+        </dependency>
+        
+        <!-- 
+        <dependency>
+            <groupId>org.apache.activemq</groupId>
+            <artifactId>activemq-core</artifactId>
+            <version>4.1.1</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.activemq</groupId>
+            <artifactId>activemq-ra</artifactId>
+            <version>4.1.1</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.geronimo.specs</groupId>
+            <artifactId>geronimo-jms_1.1_spec</artifactId>
+            <version>1.1</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.derby</groupId>
+            <artifactId>derby</artifactId>
+            <version>10.3.1.4</version>
+            <scope>test</scope>
+        </dependency>
+        -->
+        <!-- 
+            <dependency>
+            <groupId>jotm</groupId>
+            <artifactId>jotm</artifactId>
+            <version>2.0.10</version>
+            <exclusions>
+            <exclusion>
+            <artifactId>jta</artifactId>
+            <groupId>javax.transaction</groupId>
+            </exclusion>
+            <exclusion>
+            <artifactId>connector</artifactId>
+            <groupId>javax.resource</groupId>
+            </exclusion>
+            </exclusions>
+            </dependency>
+        -->
+    </dependencies>
 </project>

Modified: 
incubator/tuscany/java/sca/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionManagerHelper.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionManagerHelper.java?rev=593697&r1=593696&r2=593697&view=diff
==============================================================================
--- 
incubator/tuscany/java/sca/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionManagerHelper.java
 (original)
+++ 
incubator/tuscany/java/sca/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionManagerHelper.java
 Fri Nov  9 16:16:46 2007
@@ -20,13 +20,13 @@
 package org.apache.tuscany.sca.policy.transaction;
 
 import java.lang.reflect.InvocationTargetException;
-import java.security.PrivilegedExceptionAction;
 
 import javax.transaction.HeuristicMixedException;
 import javax.transaction.HeuristicRollbackException;
 import javax.transaction.InvalidTransactionException;
 import javax.transaction.NotSupportedException;
 import javax.transaction.RollbackException;
+import javax.transaction.Status;
 import javax.transaction.SystemException;
 import javax.transaction.Transaction;
 import javax.transaction.TransactionManager;
@@ -45,18 +45,29 @@
     }
 
     public Transaction managedGlobalTransactionPreInvoke() throws 
SystemException, NotSupportedException {
-        if (tm.getTransaction() == null) {
+        int status = tm.getStatus();
+        if (status == Status.STATUS_COMMITTED || status == 
Status.STATUS_NO_TRANSACTION
+            || status == Status.STATUS_ROLLEDBACK) {
             tm.begin();
             return tm.getTransaction();
         }
         return null;
     }
 
-    public void managedGlobalTransactionPostInvoke(Transaction created) throws 
InvalidTransactionException,
-        IllegalStateException, SystemException, SecurityException, 
HeuristicMixedException, HeuristicRollbackException,
-        RollbackException {
+    public void managedGlobalTransactionPostInvoke(Transaction created, 
boolean rollback)
+        throws InvalidTransactionException, IllegalStateException, 
SystemException, SecurityException,
+        HeuristicMixedException, HeuristicRollbackException, RollbackException 
{
         if (created != null) {
-            created.commit();
+            int status = created.getStatus();
+            if (status == Status.STATUS_MARKED_ROLLBACK) {
+                created.rollback();
+            } else if (status == Status.STATUS_ACTIVE) {
+                if (rollback) {
+                    created.rollback();
+                } else {
+                    created.commit();
+                }
+            }
         }
     }
 
@@ -112,7 +123,7 @@
 
     public <T> T handlesOutbound(TransactionIntent referenceIntent,
                                  TransactionIntent implIntent,
-                                 PrivilegedExceptionAction<T> action) throws 
Exception {
+                                 TransactionalAction<T> action) throws 
Exception {
 
         if (implIntent == null) {
             implIntent = TransactionIntent.noManagedTransaction;
@@ -137,17 +148,31 @@
         }
     }
 
-    private <T> T run(PrivilegedExceptionAction<T> action) throws Exception {
+    private <T> T run(TransactionalAction<T> action) throws Exception {
+        // Make sure a global TX is in place
+        Transaction tx = managedGlobalTransactionPreInvoke();
+        boolean rollback = false;
         try {
             return action.run();
-        } catch (Exception e) {
-            throw new InvocationTargetException(e);
+        } catch (InvocationTargetException e) {
+            throw e;
+        } catch (Throwable e) {
+            rollback = true;
+            if (e instanceof Error) {
+                throw (Error)e;
+            } else if (e instanceof RuntimeException) {
+                throw (RuntimeException)e;
+            } else {
+                throw (Exception)e;
+            }
+        } finally {
+            managedGlobalTransactionPostInvoke(tx, rollback);
         }
     }
 
     public <T> T handlesInbound(TransactionIntent serviceIntent,
                                 TransactionIntent implIntent,
-                                PrivilegedExceptionAction<T> action) throws 
Exception {
+                                TransactionalAction<T> action) throws 
Exception {
         if (serviceIntent == null && implIntent == null) {
             return run(action);
         }
@@ -160,28 +185,15 @@
             if (implIntent != TransactionIntent.managedTransactionGlobal) {
                 throw new IncompatibleIntentException(serviceIntent + "<-X->" 
+ implIntent);
             } else {
-                // Make sure a global TX is in place
-                Transaction tx = managedGlobalTransactionPreInvoke();
-                try {
-                    return run(action);
-                } finally {
-                    managedGlobalTransactionPostInvoke(tx);
-                }
+                return run(action);
             }
         } else if (serviceIntent == TransactionIntent.suspendsTransaction) {
             Transaction tx1 = suspendsTransactionPreInvoke();
             try {
                 if (implIntent == TransactionIntent.managedTransactionGlobal) {
-                    // Start a new TX
-                    Transaction tx2 = managedGlobalTransactionPreInvoke();
-                    try {
-                        return run(action);
-                    } finally {
-                        // Commit tx2
-                        managedGlobalTransactionPostInvoke(tx2);
-                    }
-                } else {
                     return run(action);
+                } else {
+                    return action.run();
                 }
             } finally {
                 suspendsTransactionPostInvoke(tx1);
@@ -189,22 +201,16 @@
         } else {
             if (implIntent == TransactionIntent.managedTransactionGlobal) {
                 // Start a new TX
-                Transaction tx2 = managedGlobalTransactionPreInvoke();
-                try {
-                    return run(action);
-                } finally {
-                    // Commit tx2
-                    managedGlobalTransactionPostInvoke(tx2);
-                }
-            } else {
                 return run(action);
+            } else {
+                return action.run();
             }
         }
     }
 
     public <T> void handlesOneWay(TransactionIntent onewayIntent,
                                   TransactionIntent implIntent,
-                                  PrivilegedExceptionAction<T> action) throws 
Exception {
+                                  TransactionalAction<T> action) throws 
Exception {
         if (implIntent == null) {
             implIntent = TransactionIntent.noManagedTransaction;
         }

Added: 
incubator/tuscany/java/sca/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionManagerWrapper.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionManagerWrapper.java?rev=593697&view=auto
==============================================================================
--- 
incubator/tuscany/java/sca/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionManagerWrapper.java
 (added)
+++ 
incubator/tuscany/java/sca/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionManagerWrapper.java
 Fri Nov  9 16:16:46 2007
@@ -0,0 +1,90 @@
+/*
+ * 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.tuscany.sca.policy.transaction;
+
+import java.io.File;
+
+import javax.transaction.TransactionManager;
+
+import org.apache.geronimo.transaction.log.HOWLLog;
+import org.apache.geronimo.transaction.manager.GeronimoTransactionManager;
+import org.apache.geronimo.transaction.manager.XidFactory;
+import org.apache.geronimo.transaction.manager.XidFactoryImpl;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class TransactionManagerWrapper {
+    private TransactionManager transactionManager;
+    private HOWLLog howlLog;
+
+    private String logFileDir = "target/logs";
+    private String bufferClassName = "org.objectweb.howl.log.BlockLogBuffer";
+    private int bufferSizeKBytes = 32;
+    private boolean checksumEnabled = true;
+    private boolean adler32Checksum = true;
+    private int flushSleepTimeMilliseconds = 50;
+    private String logFileExt = "log";
+    private String logFileName = "transaction";
+    private int maxBlocksPerFile = -1;
+    private int maxLogFiles = 2;
+    private int maxBuffers = 0;
+    private int minBuffers = 4;
+    private int threadsWaitingForceThreshold = -1;
+    private File serverBaseDir = new File(System.getProperty("basedir", 
System.getProperty("user.dir")));
+
+    public TransactionManagerWrapper() {
+        super();
+    }
+
+    public void start() {
+        try {
+            XidFactory xidFactory = new XidFactoryImpl();
+            howlLog =
+                new HOWLLog(bufferClassName, bufferSizeKBytes, 
checksumEnabled, adler32Checksum,
+                            flushSleepTimeMilliseconds, logFileDir, 
logFileExt, logFileName, maxBlocksPerFile,
+                            maxBuffers, maxLogFiles, minBuffers, 
threadsWaitingForceThreshold, xidFactory,
+                            serverBaseDir);
+
+            howlLog.doStart();
+            transactionManager = new GeronimoTransactionManager(1200, 
xidFactory, howlLog);
+        } catch (Exception e) {
+            throw new IllegalStateException(e);
+        }
+    }
+
+    /**
+     * @see 
org.apache.tuscany.sca.core.ModuleActivator#stop(org.apache.tuscany.sca.core.ExtensionPointRegistry)
+     */
+    public void stop() {
+        try {
+            if (howlLog != null) {
+                howlLog.doStop();
+            }
+        } catch (Exception e) {
+            throw new IllegalStateException(e);
+        }
+    }
+
+    public TransactionManager getTransactionManager() {
+        return transactionManager;
+    }
+
+}

Propchange: 
incubator/tuscany/java/sca/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionManagerWrapper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
incubator/tuscany/java/sca/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionManagerWrapper.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: 
incubator/tuscany/java/sca/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionModuleActivator.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionModuleActivator.java?rev=593697&r1=593696&r2=593697&view=diff
==============================================================================
--- 
incubator/tuscany/java/sca/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionModuleActivator.java
 (original)
+++ 
incubator/tuscany/java/sca/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionModuleActivator.java
 Fri Nov  9 16:16:46 2007
@@ -19,14 +19,8 @@
 
 package org.apache.tuscany.sca.policy.transaction;
 
-import java.io.File;
-
 import javax.transaction.TransactionManager;
 
-import org.apache.geronimo.transaction.log.HOWLLog;
-import org.apache.geronimo.transaction.manager.GeronimoTransactionManager;
-import org.apache.geronimo.transaction.manager.XidFactory;
-import org.apache.geronimo.transaction.manager.XidFactoryImpl;
 import org.apache.tuscany.sca.core.ExtensionPointRegistry;
 import org.apache.tuscany.sca.core.ModuleActivator;
 
@@ -34,50 +28,26 @@
  * @version $Rev$ $Date$
  */
 public class TransactionModuleActivator implements ModuleActivator {
-    private TransactionManager transactionManager;
-    private HOWLLog howlLog;
-
-    private String logFileDir = "target/logs";
-    private String bufferClassName = "org.objectweb.howl.log.BlockLogBuffer";
-    private int bufferSizeKBytes = 32;
-    private boolean checksumEnabled = true;
-    private boolean adler32Checksum = true;
-    private int flushSleepTimeMilliseconds = 50;
-    private String logFileExt = "log";
-    private String logFileName = "transaction";
-    private int maxBlocksPerFile = -1;
-    private int maxLogFiles = 2;
-    private int maxBuffers = 0;
-    private int minBuffers = 4;
-    private int threadsWaitingForceThreshold = -1;
-    private File serverBaseDir = new File(System.getProperty("basedir", 
System.getProperty("user.dir")));
-
+    private TransactionManagerWrapper wrapper;
     /**
      * @see 
org.apache.tuscany.sca.core.ModuleActivator#start(org.apache.tuscany.sca.core.ExtensionPointRegistry)
      */
     public void start(ExtensionPointRegistry registry) {
         if (registry != null) {
-            transactionManager = 
registry.getExtensionPoint(TransactionManager.class);
+            TransactionManager transactionManager = 
registry.getExtensionPoint(TransactionManager.class);
             if (transactionManager != null) {
                 // The transaction manage is provided by the hosting 
environment
                 return;
             }
         }
         try {
-            XidFactory xidFactory = new XidFactoryImpl();
-            howlLog =
-                new HOWLLog(bufferClassName, bufferSizeKBytes, 
checksumEnabled, adler32Checksum,
-                            flushSleepTimeMilliseconds, logFileDir, 
logFileExt, logFileName, maxBlocksPerFile,
-                            maxBuffers, maxLogFiles, minBuffers, 
threadsWaitingForceThreshold, xidFactory,
-                            serverBaseDir);
-
-            howlLog.doStart();
-            transactionManager = new GeronimoTransactionManager(1200, 
xidFactory, howlLog);
+            wrapper = new TransactionManagerWrapper();
+            wrapper.start();
         } catch (Exception e) {
             throw new IllegalStateException(e);
         }
         if (registry != null) {
-            registry.addExtensionPoint(transactionManager);
+            registry.addExtensionPoint(wrapper.getTransactionManager());
         }
     }
 
@@ -86,19 +56,15 @@
      */
     public void stop(ExtensionPointRegistry registry) {
         try {
-            if (howlLog != null) {
-                howlLog.doStop();
+            if (wrapper != null) {
+                wrapper.stop();
             }
-            if (registry != null && transactionManager != null) {
-                registry.removeExtensionPoint(transactionManager);
+            if (registry != null && wrapper != null) {
+                registry.removeExtensionPoint(wrapper.getTransactionManager());
             }
         } catch (Exception e) {
             throw new IllegalStateException(e);
         }
-    }
-
-    TransactionManager getTransactionManager() {
-        return transactionManager;
     }
 
 }

Added: 
incubator/tuscany/java/sca/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionalAction.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionalAction.java?rev=593697&view=auto
==============================================================================
--- 
incubator/tuscany/java/sca/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionalAction.java
 (added)
+++ 
incubator/tuscany/java/sca/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionalAction.java
 Fri Nov  9 16:16:46 2007
@@ -0,0 +1,31 @@
+/*
+ * 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.tuscany.sca.policy.transaction;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface TransactionalAction<T> {
+    /**
+     * @return
+     * @throws Exception
+     */
+    T run() throws Exception;
+}

Propchange: 
incubator/tuscany/java/sca/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionalAction.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
incubator/tuscany/java/sca/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionalAction.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: 
incubator/tuscany/java/sca/modules/policy-transaction/src/test/java/org/apache/tuscany/sca/policy/transaction/PolicyReadTestCase.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/policy-transaction/src/test/java/org/apache/tuscany/sca/policy/transaction/PolicyReadTestCase.java?rev=593697&r1=593696&r2=593697&view=diff
==============================================================================
--- 
incubator/tuscany/java/sca/modules/policy-transaction/src/test/java/org/apache/tuscany/sca/policy/transaction/PolicyReadTestCase.java
 (original)
+++ 
incubator/tuscany/java/sca/modules/policy-transaction/src/test/java/org/apache/tuscany/sca/policy/transaction/PolicyReadTestCase.java
 Fri Nov  9 16:16:46 2007
@@ -1,3 +1,21 @@
+/*
+ * 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.tuscany.sca.policy.transaction;
 
 import java.io.InputStream;

Modified: 
incubator/tuscany/java/sca/modules/policy-transaction/src/test/java/org/apache/tuscany/sca/policy/transaction/TransactionManagerHelperTestCase.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/policy-transaction/src/test/java/org/apache/tuscany/sca/policy/transaction/TransactionManagerHelperTestCase.java?rev=593697&r1=593696&r2=593697&view=diff
==============================================================================
--- 
incubator/tuscany/java/sca/modules/policy-transaction/src/test/java/org/apache/tuscany/sca/policy/transaction/TransactionManagerHelperTestCase.java
 (original)
+++ 
incubator/tuscany/java/sca/modules/policy-transaction/src/test/java/org/apache/tuscany/sca/policy/transaction/TransactionManagerHelperTestCase.java
 Fri Nov  9 16:16:46 2007
@@ -137,8 +137,8 @@
     }
 
     public void testHelper() throws Exception {
-        TransactionModuleActivator activator = new 
TransactionModuleActivator();
-        activator.start(null);
+        TransactionManagerWrapper activator = new TransactionManagerWrapper();
+        activator.start();
         TransactionManager tm = activator.getTransactionManager();
         // GeronimoUserTransaction tx = new GeronimoUserTransaction(tm);
         TransactionManagerHelper helper = new TransactionManagerHelper(tm);
@@ -150,10 +150,16 @@
         assertNotNull(t1);
         // The current TX should be T1
         assertSame(t1, tm.getTransaction());
-        tm.getTransaction().enlistResource(new MockXAResource("Derby", "001"));
-        tm.getTransaction().enlistResource(new MockXAResource("DB2", "002"));
+        
+        XAResource res1 = new MockXAResource("Derby", "001");
+        XAResource res2 = new MockXAResource("DB2", "002");
+        tm.getTransaction().enlistResource(res1);
+        tm.getTransaction().enlistResource(res2);
 
         Transaction suspended = helper.suspendsTransactionPreInvoke();
+        suspended.delistResource(res1, XAResource.TMSUSPEND);
+        suspended.delistResource(res2, XAResource.TMSUSPEND);
+       
         // T1 is suspended
         assertSame(t1, suspended);
         // No more active TX
@@ -163,21 +169,26 @@
         assertNotNull(t2);
         // The current TX should be T2
         assertSame(t2, tm.getTransaction());
-        tm.getTransaction().enlistResource(new MockXAResource("Oracle", 
"003"));
+        
+        XAResource res3 = new MockXAResource("Oracle", "003");
+        tm.getTransaction().enlistResource(res3);
 
+        tm.getTransaction().delistResource(res3, XAResource.TMSUCCESS);
         tm.rollback();
 
         // Skip post
         // helper.managedGlobalTransactionPostInvoke(t2);
 
         helper.suspendsTransactionPostInvoke(suspended);
-        // T1 is not resumed
+        suspended.enlistResource(res1);
+        suspended.enlistResource(res2);
+        // T1 is now resumed
         assertSame(t1, tm.getTransaction());
 
-        helper.managedGlobalTransactionPostInvoke(t1);
+        helper.managedGlobalTransactionPostInvoke(t1, false);
         assertNotNull(tm.getTransaction());
         assertEquals(6, t1.getStatus());
 
-        activator.stop(null);
+        activator.stop();
     }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to