aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cschnei...@apache.org
Subject svn commit: r1696456 [1/2] - in /aries/trunk/transaction: transaction-blueprint/ transaction-blueprint/src/main/java/org/apache/aries/transaction/ transaction-blueprint/src/main/java/org/apache/aries/transaction/annotations/ transaction-blueprint/src/m...
Date Tue, 18 Aug 2015 16:40:51 GMT
Author: cschneider
Date: Tue Aug 18 16:40:50 2015
New Revision: 1696456

URL: http://svn.apache.org/r1696456
Log:
[ARIES-1382] Only allow jta annotations

Added:
    aries/trunk/transaction/transaction-blueprint/src/main/java/org/apache/aries/transaction/ComponentTxData.java
    aries/trunk/transaction/transaction-blueprint/src/main/java/org/apache/aries/transaction/parsing/AnnotationProcessor.java
    aries/trunk/transaction/transaction-blueprint/src/test/java/org/apache/aries/transaction/ComponentTxDataTest.java
    aries/trunk/transaction/transaction-blueprint/src/test/java/org/apache/aries/transaction/pojo/BaseClass.java
    aries/trunk/transaction/transaction-blueprint/src/test/java/org/apache/aries/transaction/pojo/ExtendedPojo.java
    aries/trunk/transaction/transaction-blueprint/src/test/java/org/apache/aries/transaction/pojo/ExtendedPojo2.java
    aries/trunk/transaction/transaction-blueprint/src/test/java/org/apache/aries/transaction/pojo/ExtendedPojo3.java
    aries/trunk/transaction/transaction-itests/src/test/java/org/apache/aries/transaction/itests/MandatoryTest.java
      - copied, changed from r1696014, aries/trunk/transaction/transaction-itests/src/test/java/org/apache/aries/transaction/itests/MandatoryTranAttributeTest.java
    aries/trunk/transaction/transaction-itests/src/test/java/org/apache/aries/transaction/itests/NeverTest.java
      - copied, changed from r1696014, aries/trunk/transaction/transaction-itests/src/test/java/org/apache/aries/transaction/itests/NeverTranAttributeTest.java
    aries/trunk/transaction/transaction-itests/src/test/java/org/apache/aries/transaction/itests/NotSupportedTest.java
      - copied, changed from r1696014, aries/trunk/transaction/transaction-itests/src/test/java/org/apache/aries/transaction/itests/NeverTranAttributeTest.java
    aries/trunk/transaction/transaction-itests/src/test/java/org/apache/aries/transaction/itests/RequiredTest.java
      - copied, changed from r1696014, aries/trunk/transaction/transaction-itests/src/test/java/org/apache/aries/transaction/itests/RequiredTranAttributeTest.java
    aries/trunk/transaction/transaction-itests/src/test/java/org/apache/aries/transaction/itests/RequiresNewTest.java
      - copied, changed from r1696014, aries/trunk/transaction/transaction-itests/src/test/java/org/apache/aries/transaction/itests/RequiresNewTranAttributeTest.java
    aries/trunk/transaction/transaction-itests/src/test/java/org/apache/aries/transaction/itests/SupportsTest.java
      - copied, changed from r1696014, aries/trunk/transaction/transaction-itests/src/test/java/org/apache/aries/transaction/itests/SupportsTranAttributeTest.java
    aries/trunk/transaction/transaction-testbundle/src/main/java/org/apache/aries/transaction/test/Counter.java
      - copied, changed from r1696014, aries/trunk/transaction/transaction-blueprint/src/main/java/org/apache/aries/transaction/annotations/TransactionPropagationType.java
    aries/trunk/transaction/transaction-testbundle/src/main/java/org/apache/aries/transaction/test/impl/MandatoryTestBeanImpl.java
      - copied, changed from r1696014, aries/trunk/transaction/transaction-testbundle/src/main/java/org/apache/aries/transaction/test/impl/JtaAnnotatedTestBeanImpl.java
    aries/trunk/transaction/transaction-testbundle/src/main/java/org/apache/aries/transaction/test/impl/NeverTestBeanImpl.java
      - copied, changed from r1696014, aries/trunk/transaction/transaction-blueprint/src/test/java/org/apache/aries/transaction/pojo/JtaAnnotatedPojo.java
    aries/trunk/transaction/transaction-testbundle/src/main/java/org/apache/aries/transaction/test/impl/NotSupportedTestBeanImpl.java
      - copied, changed from r1696014, aries/trunk/transaction/transaction-testbundle/src/main/java/org/apache/aries/transaction/test/impl/JtaAnnotatedTestBeanImpl.java
    aries/trunk/transaction/transaction-testbundle/src/main/java/org/apache/aries/transaction/test/impl/RequiredTestBeanImpl.java
      - copied, changed from r1696014, aries/trunk/transaction/transaction-testbundle/src/main/java/org/apache/aries/transaction/test/impl/AnnotatedTestBeanImpl.java
    aries/trunk/transaction/transaction-testbundle/src/main/java/org/apache/aries/transaction/test/impl/RequiresNewTestBeanImpl.java
      - copied, changed from r1696014, aries/trunk/transaction/transaction-testbundle/src/main/java/org/apache/aries/transaction/test/impl/JtaAnnotatedTestBeanImpl.java
    aries/trunk/transaction/transaction-testbundle/src/main/java/org/apache/aries/transaction/test/impl/SupportsTestBeanImpl.java
      - copied, changed from r1696014, aries/trunk/transaction/transaction-testbundle/src/main/java/org/apache/aries/transaction/test/impl/JtaAnnotatedTestBeanImpl.java
Removed:
    aries/trunk/transaction/transaction-blueprint/src/main/java/org/apache/aries/transaction/BundleWideTxData.java
    aries/trunk/transaction/transaction-blueprint/src/main/java/org/apache/aries/transaction/BundleWideTxDataUtil.java
    aries/trunk/transaction/transaction-blueprint/src/main/java/org/apache/aries/transaction/MatchedTxData.java
    aries/trunk/transaction/transaction-blueprint/src/main/java/org/apache/aries/transaction/TxComponentMetaDataHelper.java
    aries/trunk/transaction/transaction-blueprint/src/main/java/org/apache/aries/transaction/TxComponentMetaDataHelperImpl.java
    aries/trunk/transaction/transaction-blueprint/src/main/java/org/apache/aries/transaction/annotations/Transaction.java
    aries/trunk/transaction/transaction-blueprint/src/main/java/org/apache/aries/transaction/annotations/TransactionPropagationType.java
    aries/trunk/transaction/transaction-blueprint/src/main/java/org/apache/aries/transaction/annotations/packageinfo
    aries/trunk/transaction/transaction-blueprint/src/main/java/org/apache/aries/transaction/exception/TransactionRollbackException.java
    aries/trunk/transaction/transaction-blueprint/src/main/java/org/apache/aries/transaction/exception/packageinfo
    aries/trunk/transaction/transaction-blueprint/src/main/java/org/apache/aries/transaction/parsing/AnnotationParser.java
    aries/trunk/transaction/transaction-blueprint/src/main/java/org/apache/aries/transaction/parsing/TxBlueprintListener.java
    aries/trunk/transaction/transaction-blueprint/src/main/java/org/apache/aries/transaction/parsing/TxTypeConverter.java
    aries/trunk/transaction/transaction-blueprint/src/test/java/org/apache/aries/transaction/AnnotationParserTest.java
    aries/trunk/transaction/transaction-blueprint/src/test/java/org/apache/aries/transaction/BundleWideNameSpaceHandlerTest.java
    aries/trunk/transaction/transaction-blueprint/src/test/java/org/apache/aries/transaction/NameSpaceHandlerTest.java
    aries/trunk/transaction/transaction-blueprint/src/test/java/org/apache/aries/transaction/pojo/JtaAnnotatedPojo.java
    aries/trunk/transaction/transaction-blueprint/src/test/resources/org/apache/aries/transaction/aries.xml
    aries/trunk/transaction/transaction-blueprint/src/test/resources/org/apache/aries/transaction/aries2.xml
    aries/trunk/transaction/transaction-blueprint/src/test/resources/org/apache/aries/transaction/aries3.xml
    aries/trunk/transaction/transaction-blueprint/src/test/resources/org/apache/aries/transaction/aries4.xml
    aries/trunk/transaction/transaction-blueprint/src/test/resources/org/apache/aries/transaction/aries5.xml
    aries/trunk/transaction/transaction-blueprint/src/test/resources/org/apache/aries/transaction/aries6.xml
    aries/trunk/transaction/transaction-blueprint/src/test/resources/org/apache/aries/transaction/aries7.xml
    aries/trunk/transaction/transaction-blueprint/src/test/resources/org/apache/aries/transaction/aries8.xml
    aries/trunk/transaction/transaction-blueprint/src/test/resources/org/apache/aries/transaction/aries9.xml
    aries/trunk/transaction/transaction-blueprint/src/test/resources/org/apache/aries/transaction/bundlewide-aries.xml
    aries/trunk/transaction/transaction-blueprint/src/test/resources/org/apache/aries/transaction/bundlewide-aries2.xml
    aries/trunk/transaction/transaction-blueprint/src/test/resources/org/apache/aries/transaction/bundlewide-aries3.xml
    aries/trunk/transaction/transaction-blueprint/src/test/resources/org/apache/aries/transaction/bundlewide-aries4.xml
    aries/trunk/transaction/transaction-blueprint/src/test/resources/org/apache/aries/transaction/bundlewide-aries5.xml
    aries/trunk/transaction/transaction-blueprint/src/test/resources/org/apache/aries/transaction/bundlewide-aries6.xml
    aries/trunk/transaction/transaction-blueprint/src/test/resources/org/apache/aries/transaction/mixed-aries.xml
    aries/trunk/transaction/transaction-blueprint/src/test/resources/org/apache/aries/transaction/mixed-aries2.xml
    aries/trunk/transaction/transaction-itests/src/test/java/org/apache/aries/transaction/itests/InvalidTranAttributeTest.java
    aries/trunk/transaction/transaction-itests/src/test/java/org/apache/aries/transaction/itests/MandatoryAnnotatedTranAttributeTest.java
    aries/trunk/transaction/transaction-itests/src/test/java/org/apache/aries/transaction/itests/MandatoryJtaAnnotatedTranAttributeTest.java
    aries/trunk/transaction/transaction-itests/src/test/java/org/apache/aries/transaction/itests/MandatoryTranAttributeTest.java
    aries/trunk/transaction/transaction-itests/src/test/java/org/apache/aries/transaction/itests/NeverTranAttributeTest.java
    aries/trunk/transaction/transaction-itests/src/test/java/org/apache/aries/transaction/itests/NotSupportedTranAttributeTest.java
    aries/trunk/transaction/transaction-itests/src/test/java/org/apache/aries/transaction/itests/RequiredTranAttributeTest.java
    aries/trunk/transaction/transaction-itests/src/test/java/org/apache/aries/transaction/itests/RequiresNewTranAttributeTest.java
    aries/trunk/transaction/transaction-itests/src/test/java/org/apache/aries/transaction/itests/SupportsTranAttributeTest.java
    aries/trunk/transaction/transaction-testbundle/src/main/java/org/apache/aries/transaction/test/impl/AnnotatedTestBeanImpl.java
    aries/trunk/transaction/transaction-testbundle/src/main/java/org/apache/aries/transaction/test/impl/JtaAnnotatedTestBeanImpl.java
Modified:
    aries/trunk/transaction/transaction-blueprint/pom.xml
    aries/trunk/transaction/transaction-blueprint/src/main/java/org/apache/aries/transaction/TransactionAttribute.java
    aries/trunk/transaction/transaction-blueprint/src/main/java/org/apache/aries/transaction/TxInterceptorImpl.java
    aries/trunk/transaction/transaction-blueprint/src/main/java/org/apache/aries/transaction/parsing/TxNamespaceHandler.java
    aries/trunk/transaction/transaction-blueprint/src/main/resources/OSGI-INF/blueprint/transaction.xml
    aries/trunk/transaction/transaction-blueprint/src/test/java/org/apache/aries/transaction/AnnotationEnablingNameSpaceHandlerTest.java
    aries/trunk/transaction/transaction-blueprint/src/test/java/org/apache/aries/transaction/BaseNameSpaceHandlerSetup.java
    aries/trunk/transaction/transaction-blueprint/src/test/java/org/apache/aries/transaction/InterceptorTest.java
    aries/trunk/transaction/transaction-blueprint/src/test/java/org/apache/aries/transaction/TranStrategyTest.java
    aries/trunk/transaction/transaction-blueprint/src/test/java/org/apache/aries/transaction/pojo/AnnotatedPojo.java
    aries/trunk/transaction/transaction-blueprint/src/test/java/org/apache/aries/transaction/pojo/BadlyAnnotatedPojo1.java
    aries/trunk/transaction/transaction-blueprint/src/test/java/org/apache/aries/transaction/pojo/BadlyAnnotatedPojo2.java
    aries/trunk/transaction/transaction-blueprint/src/test/resources/org/apache/aries/transaction/enable-annotations.xml
    aries/trunk/transaction/transaction-itests/pom.xml
    aries/trunk/transaction/transaction-itests/src/test/java/org/apache/aries/transaction/itests/AbstractIntegrationTest.java
    aries/trunk/transaction/transaction-testbundle/src/main/java/org/apache/aries/transaction/test/TestBean.java
    aries/trunk/transaction/transaction-testbundle/src/main/java/org/apache/aries/transaction/test/impl/Connector.java
    aries/trunk/transaction/transaction-testbundle/src/main/java/org/apache/aries/transaction/test/impl/TestBeanImpl.java
    aries/trunk/transaction/transaction-testbundle/src/main/resources/OSGI-INF/blueprint/config.xml

Modified: aries/trunk/transaction/transaction-blueprint/pom.xml
URL: http://svn.apache.org/viewvc/aries/trunk/transaction/transaction-blueprint/pom.xml?rev=1696456&r1=1696455&r2=1696456&view=diff
==============================================================================
--- aries/trunk/transaction/transaction-blueprint/pom.xml (original)
+++ aries/trunk/transaction/transaction-blueprint/pom.xml Tue Aug 18 16:40:50 2015
@@ -31,7 +31,7 @@
     <groupId>org.apache.aries.transaction</groupId>
     <artifactId>org.apache.aries.transaction.blueprint</artifactId>
     <packaging>bundle</packaging>
-    <version>1.2.0-SNAPSHOT</version>
+    <version>2.0.0-SNAPSHOT</version>
     <name>Apache Aries Transaction Blueprint</name>
 
     <scm>
@@ -43,8 +43,6 @@
     <properties>
         <!-- Export package versions are maintained in packageinfo files -->
         <aries.osgi.export.pkg>
-            org.apache.aries.transaction.exception,
-            org.apache.aries.transaction.annotations
         </aries.osgi.export.pkg>
         <aries.osgi.private.pkg>
             org.apache.aries.transaction,

Added: aries/trunk/transaction/transaction-blueprint/src/main/java/org/apache/aries/transaction/ComponentTxData.java
URL: http://svn.apache.org/viewvc/aries/trunk/transaction/transaction-blueprint/src/main/java/org/apache/aries/transaction/ComponentTxData.java?rev=1696456&view=auto
==============================================================================
--- aries/trunk/transaction/transaction-blueprint/src/main/java/org/apache/aries/transaction/ComponentTxData.java (added)
+++ aries/trunk/transaction/transaction-blueprint/src/main/java/org/apache/aries/transaction/ComponentTxData.java Tue Aug 18 16:40:50 2015
@@ -0,0 +1,90 @@
+package org.apache.aries.transaction;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.transaction.Transactional;
+import javax.transaction.Transactional.TxType;
+
+public class ComponentTxData {
+    private static final int BANNED_MODIFIERS = Modifier.PRIVATE | Modifier.STATIC;
+    
+    Map<Method, TxType> txMap = new HashMap<Method, Transactional.TxType>();
+    private boolean isTransactional;
+    private Class<?> beanClass;
+    
+    TxType getEffectiveType(Method m) {
+        try {
+            Method effectiveMethod = beanClass.getDeclaredMethod(m.getName(), m.getParameterTypes());
+            return txMap.get(effectiveMethod);
+        } catch (NoSuchMethodException e) {
+            try {
+                Method effectiveMethod = beanClass.getMethod(m.getName(), m.getParameterTypes());
+                return txMap.get(effectiveMethod);
+            } catch (NoSuchMethodException e1) {
+                return null;
+            } catch (SecurityException e1) {
+                throw new RuntimeException("Security exception when determining effective method", e1);
+            }
+        } catch (SecurityException e) {
+            throw new RuntimeException("Security exception when determining effective method", e);
+        }
+    }
+    
+    public ComponentTxData(Class<?> c) {
+        beanClass = c;
+        isTransactional = false;
+        // Check class hierarchy
+        while (c != Object.class) {
+            isTransactional |= parseTxData(c);
+            for (Class<?> iface : c.getInterfaces()) {
+                isTransactional |= parseTxData(iface);
+            }
+            c = c.getSuperclass();
+        }
+    }
+
+    private boolean parseTxData(Class<?> c) {
+        boolean shouldAssignInterceptor = false;
+        TxType defaultType = getType(c.getAnnotation(Transactional.class));
+        if (defaultType != null) {
+            shouldAssignInterceptor = true;
+        }
+        for (Method m : c.getDeclaredMethods()) {
+            try {
+                TxType t = getType(m.getAnnotation(Transactional.class));
+                if (t != null) {
+                   assertAllowedModifier(m);
+                   txMap.put(m, t);
+                   shouldAssignInterceptor = true;
+                } else if (defaultType != null){
+                   txMap.put(m, defaultType);
+                }
+            } catch(IllegalStateException e) {
+                // don't break bean creation due to invalid transaction attribute
+            }
+        }
+
+        return shouldAssignInterceptor;
+    }
+
+    private TxType getType(Transactional jtaT) {
+        return (jtaT != null) ? jtaT.value() : null;
+    }
+
+    private void assertAllowedModifier(Method m) {
+        if ((m.getModifiers() & BANNED_MODIFIERS) != 0) {
+            throw new IllegalArgumentException("Transaction annotation is not allowed on private or static method " + m);
+        }
+    }
+
+    public boolean isTransactional() {
+        return isTransactional;
+    }
+    
+    public Class<?> getBeanClass() {
+        return beanClass;
+    }
+}

Modified: aries/trunk/transaction/transaction-blueprint/src/main/java/org/apache/aries/transaction/TransactionAttribute.java
URL: http://svn.apache.org/viewvc/aries/trunk/transaction/transaction-blueprint/src/main/java/org/apache/aries/transaction/TransactionAttribute.java?rev=1696456&r1=1696455&r2=1696456&view=diff
==============================================================================
--- aries/trunk/transaction/transaction-blueprint/src/main/java/org/apache/aries/transaction/TransactionAttribute.java (original)
+++ aries/trunk/transaction/transaction-blueprint/src/main/java/org/apache/aries/transaction/TransactionAttribute.java Tue Aug 18 16:40:50 2015
@@ -27,8 +27,7 @@ import javax.transaction.Status;
 import javax.transaction.SystemException;
 import javax.transaction.Transaction;
 import javax.transaction.TransactionManager;
-
-import org.apache.aries.transaction.annotations.TransactionPropagationType;
+import javax.transaction.Transactional.TxType;
 
 public enum TransactionAttribute {
     MANDATORY
@@ -53,7 +52,7 @@ public enum TransactionAttribute {
         return new TransactionToken(null, null, NEVER);
       }
     },
-    NOTSUPPORTED
+    NOT_SUPPORTED
     {
       public TransactionToken begin(TransactionManager man) throws SystemException
       {
@@ -61,7 +60,7 @@ public enum TransactionAttribute {
           return new TransactionToken(null, man.suspend(), this);
         }
 
-        return new TransactionToken(null, null, NOTSUPPORTED);
+        return new TransactionToken(null, null, NOT_SUPPORTED);
       }
 
       public void finish(TransactionManager man, TransactionToken tranToken) throws SystemException,
@@ -98,7 +97,7 @@ public enum TransactionAttribute {
         }
       }
     },
-    REQUIRESNEW
+    REQUIRES_NEW
     {
       public TransactionToken begin(TransactionManager man) throws SystemException, NotSupportedException,
           InvalidTransactionException, IllegalStateException
@@ -114,7 +113,7 @@ public enum TransactionAttribute {
           man.resume(suspendedTransaction);
           throw e;
         }
-        return new TransactionToken(man.getTransaction(), suspendedTransaction, REQUIRESNEW, true);
+        return new TransactionToken(man.getTransaction(), suspendedTransaction, REQUIRES_NEW, true);
       }
 
       public void finish(TransactionManager man, TransactionToken tranToken) throws SystemException,
@@ -148,9 +147,9 @@ public enum TransactionAttribute {
       }
     };
 
-    public static TransactionAttribute fromValue(TransactionPropagationType type)
+    public static TransactionAttribute fromValue(TxType type)
     {
-      return valueOf(type.name().toUpperCase());
+      return valueOf(type.name());
     }
 
     public TransactionToken begin(TransactionManager man) throws SystemException, NotSupportedException,

Modified: aries/trunk/transaction/transaction-blueprint/src/main/java/org/apache/aries/transaction/TxInterceptorImpl.java
URL: http://svn.apache.org/viewvc/aries/trunk/transaction/transaction-blueprint/src/main/java/org/apache/aries/transaction/TxInterceptorImpl.java?rev=1696456&r1=1696455&r2=1696456&view=diff
==============================================================================
--- aries/trunk/transaction/transaction-blueprint/src/main/java/org/apache/aries/transaction/TxInterceptorImpl.java (original)
+++ aries/trunk/transaction/transaction-blueprint/src/main/java/org/apache/aries/transaction/TxInterceptorImpl.java Tue Aug 18 16:40:50 2015
@@ -20,12 +20,12 @@ package org.apache.aries.transaction;
 
 import java.lang.reflect.Method;
 
+import javax.transaction.RollbackException;
 import javax.transaction.Transaction;
 import javax.transaction.TransactionManager;
+import javax.transaction.Transactional.TxType;
 
 import org.apache.aries.blueprint.Interceptor;
-import org.apache.aries.transaction.annotations.TransactionPropagationType;
-import org.apache.aries.transaction.exception.TransactionRollbackException;
 import org.osgi.service.blueprint.reflect.ComponentMetadata;
 import org.osgi.service.coordinator.Coordination;
 import org.osgi.service.coordinator.CoordinationException;
@@ -38,18 +38,22 @@ public class TxInterceptorImpl implement
 
     private TransactionManager tm;
     private Coordinator coordinator;
-    private TxComponentMetaDataHelper metaDataHelper;
+    private ComponentTxData txData;
+
+    public TxInterceptorImpl(TransactionManager tm, Coordinator coordinator, ComponentTxData txData) {
+        this.tm = tm;
+        this.coordinator = coordinator;
+        this.txData = txData;
+    }
 
     public int getRank() {
         return 1; // Higher rank than jpa interceptor to make sure transaction is started first
     }
 
     public Object preCall(ComponentMetadata cm, Method m, Object... parameters) throws Throwable {
-        final String methodName = m.getName();
-        final TransactionPropagationType type = metaDataHelper.getComponentMethodTxAttribute(cm, methodName);
-
-        // attribute could be null here which means no transaction
+        final TxType type = txData.getEffectiveType(m);
         if (type == null) {
+            // No transaction
             return null;
         }
         TransactionAttribute txAttribute = TransactionAttribute.fromValue(type);
@@ -63,10 +67,10 @@ public class TxInterceptorImpl implement
     }
 
     public void postCallWithException(ComponentMetadata cm, Method m, Throwable ex, Object preCallToken) {
-        LOGGER.debug("PostCallWithException for bean {}, method {}.", getCmId(cm), m.getName(), ex);
         if (!(preCallToken instanceof TransactionToken)) {
             return;
         }
+        LOGGER.debug("PostCallWithException for bean {}, method {}.", getCmId(cm), m.getName(), ex);
         final TransactionToken token = (TransactionToken)preCallToken;
         try {
             token.getCoordination().end();
@@ -77,6 +81,7 @@ public class TxInterceptorImpl implement
             Transaction tran = token.getActiveTransaction();
             if (tran != null && isRollBackException(ex)) {
                 tran.setRollbackOnly();
+                LOGGER.info("Setting transaction to rollback only because of exception ", ex);
             }
             token.getTransactionAttribute().finish(tm, token);
         } catch (Exception e) {
@@ -104,7 +109,9 @@ public class TxInterceptorImpl implement
             } catch (Exception e) {
                 // We are throwing an exception, so we don't error it out
                 LOGGER.debug("Exception while completing transaction.", e);
-                throw new TransactionRollbackException(e);
+                RollbackException rbe = new javax.transaction.RollbackException();
+                rbe.addSuppressed(e);
+                throw rbe;
             }
         } else {
             // TODO: what now?
@@ -115,15 +122,4 @@ public class TxInterceptorImpl implement
         return ex instanceof RuntimeException || ex instanceof Error;
     }
 
-    public final void setTransactionManager(TransactionManager manager) {
-        tm = manager;
-    }
-
-    public void setCoordinator(Coordinator coordinator) {
-        this.coordinator = coordinator;
-    }
-
-    public final void setTxMetaDataHelper(TxComponentMetaDataHelper transactionEnhancer) {
-        this.metaDataHelper = transactionEnhancer;
-    }
 }

Added: aries/trunk/transaction/transaction-blueprint/src/main/java/org/apache/aries/transaction/parsing/AnnotationProcessor.java
URL: http://svn.apache.org/viewvc/aries/trunk/transaction/transaction-blueprint/src/main/java/org/apache/aries/transaction/parsing/AnnotationProcessor.java?rev=1696456&view=auto
==============================================================================
--- aries/trunk/transaction/transaction-blueprint/src/main/java/org/apache/aries/transaction/parsing/AnnotationProcessor.java (added)
+++ aries/trunk/transaction/transaction-blueprint/src/main/java/org/apache/aries/transaction/parsing/AnnotationProcessor.java Tue Aug 18 16:40:50 2015
@@ -0,0 +1,69 @@
+/**
+ * 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.aries.transaction.parsing;
+
+import javax.transaction.TransactionManager;
+
+import org.apache.aries.blueprint.BeanProcessor;
+import org.apache.aries.blueprint.ComponentDefinitionRegistry;
+import org.apache.aries.transaction.ComponentTxData;
+import org.apache.aries.transaction.TxInterceptorImpl;
+import org.osgi.service.blueprint.reflect.BeanMetadata;
+import org.osgi.service.coordinator.Coordinator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Adds the transactional interceptor if Transaction annotation is present
+ * on bean class or superclasses.
+ */
+public class AnnotationProcessor implements BeanProcessor {
+
+    private static final Logger LOGGER = LoggerFactory.getLogger(AnnotationProcessor.class);
+
+    private final ComponentDefinitionRegistry cdr;
+    private TransactionManager tm;
+    private Coordinator coordinator;
+
+    public AnnotationProcessor(ComponentDefinitionRegistry cdr, TransactionManager tm, Coordinator coordinator) {
+        this.cdr = cdr;
+        this.tm = tm;
+        this.coordinator = coordinator;
+    }
+
+    public void afterDestroy(Object arg0, String arg1) {
+    }
+
+    public Object afterInit(Object arg0, String arg1, BeanCreator arg2, BeanMetadata arg3) {
+        return arg0;
+    }
+
+    public void beforeDestroy(Object arg0, String arg1) {
+    }
+
+    public Object beforeInit(Object bean, String beanName, BeanCreator beanCreator, BeanMetadata beanData) {
+        ComponentTxData txData = new ComponentTxData(bean.getClass());
+        if (txData.isTransactional()) {
+            LOGGER.debug("Adding transaction interceptor to bean {} with class {}.", beanName, bean.getClass());
+            cdr.registerInterceptorWithComponent(beanData, new TxInterceptorImpl(tm, coordinator, txData));
+        }
+        return bean;
+    }
+
+}

Modified: aries/trunk/transaction/transaction-blueprint/src/main/java/org/apache/aries/transaction/parsing/TxNamespaceHandler.java
URL: http://svn.apache.org/viewvc/aries/trunk/transaction/transaction-blueprint/src/main/java/org/apache/aries/transaction/parsing/TxNamespaceHandler.java?rev=1696456&r1=1696455&r2=1696456&view=diff
==============================================================================
--- aries/trunk/transaction/transaction-blueprint/src/main/java/org/apache/aries/transaction/parsing/TxNamespaceHandler.java (original)
+++ aries/trunk/transaction/transaction-blueprint/src/main/java/org/apache/aries/transaction/parsing/TxNamespaceHandler.java Tue Aug 18 16:40:50 2015
@@ -18,34 +18,21 @@
  */
 package org.apache.aries.transaction.parsing;
 
-import java.io.Closeable;
-import java.io.IOException;
-import java.io.InputStream;
 import java.net.URL;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.Map;
-import java.util.Properties;
 import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
+
+import javax.transaction.TransactionManager;
 
 import org.apache.aries.blueprint.ComponentDefinitionRegistry;
-import org.apache.aries.blueprint.Interceptor;
 import org.apache.aries.blueprint.NamespaceHandler;
 import org.apache.aries.blueprint.ParserContext;
-import org.apache.aries.blueprint.PassThroughMetadata;
 import org.apache.aries.blueprint.mutable.MutableBeanMetadata;
 import org.apache.aries.blueprint.mutable.MutablePassThroughMetadata;
-import org.apache.aries.transaction.BundleWideTxData;
-import org.apache.aries.transaction.TxComponentMetaDataHelper;
-import org.apache.aries.transaction.annotations.TransactionPropagationType;
-import org.osgi.framework.Bundle;
-import org.osgi.service.blueprint.container.BlueprintContainer;
 import org.osgi.service.blueprint.reflect.ComponentMetadata;
 import org.osgi.service.blueprint.reflect.Metadata;
+import org.osgi.service.coordinator.Coordinator;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.w3c.dom.Element;
@@ -53,18 +40,10 @@ import org.w3c.dom.Node;
 
 public class TxNamespaceHandler implements NamespaceHandler {
     public static final String ANNOTATION_PARSER_BEAN_NAME = ".org_apache_aries_transaction_annotations";
-    private static final String BEAN = "bean";
-    private static final String VALUE = "value";
-    private static final String METHOD = "method";
-    public static final String DEFAULT_INTERCEPTOR_ID = "txinterceptor";
-    private static final String INTERCEPTOR_BLUEPRINT_ID = "interceptor.blueprint.id";
-
     private static final Logger LOGGER = LoggerFactory.getLogger(TxNamespaceHandler.class);
+    private TransactionManager tm;
+    private Coordinator coordinator;
 
-    private TxComponentMetaDataHelper metaDataHelper;
-    private Interceptor interceptor = null;
-
-    private final ConcurrentMap<ComponentDefinitionRegistry,Bundle> registered = new ConcurrentHashMap<ComponentDefinitionRegistry, Bundle>();
     private final Map<String, String> schemaMap;
     
     public TxNamespaceHandler() {
@@ -76,31 +55,12 @@ public class TxNamespaceHandler implemen
 
     private void parseElement(Element elt, ComponentMetadata cm, ParserContext pc)
     {
-        LOGGER.debug("parser asked to parse element {} ", elt);
+        LOGGER.debug("parser asked to parse element {} ", elt.getNodeName());
 
         ComponentDefinitionRegistry cdr = pc.getComponentDefinitionRegistry();
-        if ("transaction".equals(elt.getLocalName())) {
-            Bundle blueprintBundle = getBlueprintBundle(cdr);
-
-            // don't register components if we have no bundle (= dry parse)
-            if (blueprintBundle != null) {
-              registered.put(cdr, blueprintBundle);
-              TransactionPropagationType txType = getType(elt.getAttribute(VALUE));
-              String method = elt.getAttribute(METHOD);
-              String beanAttr = elt.getAttribute(BEAN);
-              if (cm == null) {
-                  // if the enclosing component is null, then we assume this is the top element
-                  registerComponentsWithInterceptor(cdr, beanAttr);
-                  metaDataHelper.populateBundleWideTransactionData(cdr, txType, method, beanAttr);
-              } else {
-                  cdr.registerInterceptorWithComponent(cm, interceptor);
-                  
-                  metaDataHelper.setComponentTransactionData(cdr, cm, txType, method);
-              }
-            }
-        } else if ("enable-annotations".equals(elt.getLocalName())) {
+        if ("enable-annotations".equals(elt.getLocalName())) {
             Node n = elt.getChildNodes().item(0);
-            if(n == null || Boolean.parseBoolean(n.getNodeValue())) {
+            if (n == null || Boolean.parseBoolean(n.getNodeValue())) {
                 //We need to register a bean processor to add annotation-based config
                 if (!cdr.containsComponentDefinition(ANNOTATION_PARSER_BEAN_NAME)) {
                     LOGGER.debug("Enabling annotation based transactions");
@@ -111,37 +71,21 @@ public class TxNamespaceHandler implemen
         }
     }
 
-    private Bundle getBlueprintBundle(ComponentDefinitionRegistry cdr) {
-        ComponentMetadata meta = cdr.getComponentDefinition("blueprintBundle");
-        Bundle blueprintBundle = null;
-        if (meta instanceof PassThroughMetadata) {
-            blueprintBundle = (Bundle) ((PassThroughMetadata) meta).getObject();
-        }
-        return blueprintBundle;
-    }
-
     private MutableBeanMetadata createAnnotationParserBean(ParserContext pc, ComponentDefinitionRegistry cdr) {
         MutableBeanMetadata meta = pc.createMetadata(MutableBeanMetadata.class);
         meta.setId(ANNOTATION_PARSER_BEAN_NAME);
-        meta.setRuntimeClass(AnnotationParser.class);
+        meta.setRuntimeClass(AnnotationProcessor.class);
         meta.setProcessor(true);
-
-        MutablePassThroughMetadata cdrMeta = pc.createMetadata(MutablePassThroughMetadata.class);
-        cdrMeta.setObject(cdr);
-        meta.addArgument(cdrMeta, ComponentDefinitionRegistry.class.getName(), 0);
-
-        MutablePassThroughMetadata interceptorMeta = pc.createMetadata(MutablePassThroughMetadata.class);
-        interceptorMeta.setObject(interceptor);
-        meta.addArgument(interceptorMeta, Interceptor.class.getName(), 1);
-
-        MutablePassThroughMetadata helperMeta = pc.createMetadata(MutablePassThroughMetadata.class);
-        helperMeta.setObject(metaDataHelper);
-        meta.addArgument(helperMeta, TxComponentMetaDataHelper.class.getName(), 2);
+        meta.addArgument(passThrough(pc, cdr), ComponentDefinitionRegistry.class.getName(), 0);
+        meta.addArgument(passThrough(pc, tm), TransactionManager.class.getName(), 1);
+        meta.addArgument(passThrough(pc, coordinator), Coordinator.class.getName(), 1);
         return meta;
     }
 
-    private TransactionPropagationType getType(String typeSt) {
-        return typeSt == null || typeSt.length() == 0 ? null : TransactionPropagationType.valueOf(typeSt);
+    private MutablePassThroughMetadata passThrough(ParserContext pc, Object o) {
+        MutablePassThroughMetadata meta = pc.createMetadata(MutablePassThroughMetadata.class);
+        meta.setObject(o);
+        return meta;
     }
 
     public ComponentMetadata decorate(Node node, ComponentMetadata cm, ParserContext pc)
@@ -164,37 +108,13 @@ public class TxNamespaceHandler implemen
         String xsdPath = schemaMap.get(namespaceUri);
         return xsdPath != null ? this.getClass().getResource(xsdPath) : null;
     }
-
-    public final void setTxMetaDataHelper(TxComponentMetaDataHelper transactionEnhancer)
-    {
-        this.metaDataHelper = transactionEnhancer;
-    }
-
-    public final void setBlueprintContainer(BlueprintContainer container) 
-    {
-        String id = getTxInterceptorId();
-        this.interceptor = (Interceptor) container.getComponentInstance(id);
+    
+    public void setTm(TransactionManager tm) {
+        this.tm = tm;
     }
-
-    private String getTxInterceptorId() {
-        String id = DEFAULT_INTERCEPTOR_ID;
-        InputStream is = TxNamespaceHandler.class.getResourceAsStream("/provider.properties");
-        if (is == null) {
-            return id;
-        }
-        try {
-            Properties props = new Properties();
-            props.load(is);
-            if (props.containsKey(INTERCEPTOR_BLUEPRINT_ID)) {
-                id = props.getProperty(INTERCEPTOR_BLUEPRINT_ID);
-            }
-        } catch (IOException e) {
-            LOGGER.error("An IOException occurred while loading the provider "
-                         + "properties. Using the default provider.", e);
-        } finally {
-            safeClose(is);
-        }
-        return id;
+    
+    public void setCoordinator(Coordinator coordinator) {
+        this.coordinator = coordinator;
     }
 
     @SuppressWarnings("rawtypes")
@@ -203,55 +123,4 @@ public class TxNamespaceHandler implemen
         return null;
     }
     
-    public boolean isRegistered(ComponentDefinitionRegistry cdr) {
-        return registered.containsKey(cdr);
-    }
-    
-    public void unregister(Bundle blueprintBundle) {
-        Iterator<Map.Entry<ComponentDefinitionRegistry, Bundle>> it = registered.entrySet().iterator();
-        while (it.hasNext()) {
-            Map.Entry<ComponentDefinitionRegistry, Bundle> e = it.next();
-            if (blueprintBundle.equals(e.getValue())) {
-                metaDataHelper.unregister(e.getKey());
-                it.remove();
-            }
-        }
-    }
-    
-    private void registerComponentsWithInterceptor(ComponentDefinitionRegistry cdr, String bean) {
-        Set<String> ids = cdr.getComponentDefinitionNames();
-
-        if (bean == null || bean.length() == 0) {
-            // in this case, let's attempt to register all components
-            // if the component has already been registered with this interceptor,
-            // the registration will be ignored.
-            for (String id : ids) {
-                ComponentMetadata componentMetadata = cdr.getComponentDefinition(id);
-                cdr.registerInterceptorWithComponent(componentMetadata, interceptor);
-            }
-        } else {
-            //create a dummy bundle wide tx data, so we can get the bean patterns from it
-            BundleWideTxData data = new BundleWideTxData(null, "*", bean);
-            for (Pattern p : data.getBean()) {
-              for (String id : ids) {
-                  Matcher m = p.matcher(id);
-                  if (m.matches()) {
-                      ComponentMetadata componentMetadata = cdr.getComponentDefinition(id);
-                      cdr.registerInterceptorWithComponent(componentMetadata, interceptor);
-                  }
-              }
-            }
-        }
-    }
-    
-    private void safeClose(Closeable closeable) {
-        if (closeable != null) {
-            try {
-                closeable.close();
-            } catch (IOException e) {
-                // Ignore
-            }
-        }
-        
-    }
 }

Modified: aries/trunk/transaction/transaction-blueprint/src/main/resources/OSGI-INF/blueprint/transaction.xml
URL: http://svn.apache.org/viewvc/aries/trunk/transaction/transaction-blueprint/src/main/resources/OSGI-INF/blueprint/transaction.xml?rev=1696456&r1=1696455&r2=1696456&view=diff
==============================================================================
--- aries/trunk/transaction/transaction-blueprint/src/main/resources/OSGI-INF/blueprint/transaction.xml (original)
+++ aries/trunk/transaction/transaction-blueprint/src/main/resources/OSGI-INF/blueprint/transaction.xml Tue Aug 18 16:40:50 2015
@@ -39,26 +39,11 @@
   </service>
 
   <bean id="nsHandler" class="org.apache.aries.transaction.parsing.TxNamespaceHandler">
-    <property ref="txenhancer" name="txMetaDataHelper"/>
-    <property name="blueprintContainer" ref="blueprintContainer" />
-  </bean>
-  
-  <bean id="txenhancer" class="org.apache.aries.transaction.TxComponentMetaDataHelperImpl"/>
-  
-  <bean id="txinterceptor" class="org.apache.aries.transaction.TxInterceptorImpl">
-    <property name="transactionManager" ref="tm"/>
-    <property name="coordinator" ref="coordinator"/>
-    <property ref="txenhancer" name="txMetaDataHelper"/>
+    <property name="tm" ref="tm" />
+    <property name="coordinator" ref="coordinator" />
   </bean>
   
   <reference id="tm" interface="javax.transaction.TransactionManager"/>
   <reference id="coordinator" interface="org.osgi.service.coordinator.Coordinator"/>
-  
-  
-  <service interface="org.osgi.service.blueprint.container.BlueprintListener">
-  	<bean class="org.apache.aries.transaction.parsing.TxBlueprintListener">
-  	  <argument ref="nsHandler" />
-  	</bean>
-  </service>
-  
+
 </blueprint>
\ No newline at end of file

Modified: aries/trunk/transaction/transaction-blueprint/src/test/java/org/apache/aries/transaction/AnnotationEnablingNameSpaceHandlerTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/transaction/transaction-blueprint/src/test/java/org/apache/aries/transaction/AnnotationEnablingNameSpaceHandlerTest.java?rev=1696456&r1=1696455&r2=1696456&view=diff
==============================================================================
--- aries/trunk/transaction/transaction-blueprint/src/test/java/org/apache/aries/transaction/AnnotationEnablingNameSpaceHandlerTest.java (original)
+++ aries/trunk/transaction/transaction-blueprint/src/test/java/org/apache/aries/transaction/AnnotationEnablingNameSpaceHandlerTest.java Tue Aug 18 16:40:50 2015
@@ -39,7 +39,7 @@ public class AnnotationEnablingNameSpace
       assertNotNull(pmd);
       assertEquals(3, pmd.getArguments().size());
       assertEquals(cdr, ((PassThroughMetadata)pmd.getArguments().get(0).getValue()).getObject());
-      assertEquals(txenhancer, ((PassThroughMetadata) pmd.getArguments().get(2).getValue()).getObject());
+//      assertEquals(tm, ((PassThroughMetadata) pmd.getArguments().get(2).getValue()).getObject());
     }
     
     @Test
@@ -55,6 +55,6 @@ public class AnnotationEnablingNameSpace
         BeanMetadata compTop = (BeanMetadata) cdr.getComponentDefinition("top");
         assertNotNull(compTop);
         assertEquals(0, cdr.getInterceptors(compTop).size());
-        assertNull(txenhancer.getComponentMethodTxAttribute(compTop, "increment"));
+        //assertNull(txenhancer.getComponentMethodTxAttribute(compTop, "increment"));
     }
 }

Modified: aries/trunk/transaction/transaction-blueprint/src/test/java/org/apache/aries/transaction/BaseNameSpaceHandlerSetup.java
URL: http://svn.apache.org/viewvc/aries/trunk/transaction/transaction-blueprint/src/test/java/org/apache/aries/transaction/BaseNameSpaceHandlerSetup.java?rev=1696456&r1=1696455&r2=1696456&view=diff
==============================================================================
--- aries/trunk/transaction/transaction-blueprint/src/test/java/org/apache/aries/transaction/BaseNameSpaceHandlerSetup.java (original)
+++ aries/trunk/transaction/transaction-blueprint/src/test/java/org/apache/aries/transaction/BaseNameSpaceHandlerSetup.java Tue Aug 18 16:40:50 2015
@@ -18,8 +18,6 @@
  */
 package org.apache.aries.transaction;
 
-import static org.easymock.EasyMock.expect;
-
 import java.net.URI;
 import java.net.URL;
 import java.util.Arrays;
@@ -39,12 +37,11 @@ import org.junit.After;
 import org.junit.Before;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.service.blueprint.container.BlueprintContainer;
+import org.osgi.service.coordinator.Coordinator;
 
 public class BaseNameSpaceHandlerSetup {
     protected Bundle b;
     protected DummyNamespaceHandlerRegistry nhri;
-    protected TxComponentMetaDataHelperImpl txenhancer;
     protected TxNamespaceHandler namespaceHandler;
     protected IMocksControl control;
 
@@ -53,17 +50,12 @@ public class BaseNameSpaceHandlerSetup {
         control = EasyMock.createControl();
         b = control.createMock(Bundle.class);
         TransactionManager tm = control.createMock(TransactionManager.class);
-        txenhancer = new TxComponentMetaDataHelperImpl();
-        TxInterceptorImpl txinterceptor = new TxInterceptorImpl();
-        txinterceptor.setTransactionManager(tm);
-        txinterceptor.setTxMetaDataHelper(txenhancer);
-        namespaceHandler = new TxNamespaceHandler();
-
-        BlueprintContainer container = control.createMock(BlueprintContainer.class);
-        expect(container.getComponentInstance(EasyMock.eq(TxNamespaceHandler.DEFAULT_INTERCEPTOR_ID))).andReturn(txinterceptor);
+        Coordinator coordinator = control.createMock(Coordinator.class);
         control.replay();
-        namespaceHandler.setBlueprintContainer(container);
-        namespaceHandler.setTxMetaDataHelper(txenhancer);
+
+        namespaceHandler = new TxNamespaceHandler();
+        namespaceHandler.setTm(tm);
+        namespaceHandler.setCoordinator(coordinator);
 
         String[] namespaces = new String[]
             {"http://aries.apache.org/xmlns/transactions/v1.0.0", 
@@ -79,7 +71,6 @@ public class BaseNameSpaceHandlerSetup {
         control.verify();
         b = null;
         nhri = null;
-        txenhancer = null;
     }
 
     protected ComponentDefinitionRegistry parseCDR(String name) throws Exception {

Added: aries/trunk/transaction/transaction-blueprint/src/test/java/org/apache/aries/transaction/ComponentTxDataTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/transaction/transaction-blueprint/src/test/java/org/apache/aries/transaction/ComponentTxDataTest.java?rev=1696456&view=auto
==============================================================================
--- aries/trunk/transaction/transaction-blueprint/src/test/java/org/apache/aries/transaction/ComponentTxDataTest.java (added)
+++ aries/trunk/transaction/transaction-blueprint/src/test/java/org/apache/aries/transaction/ComponentTxDataTest.java Tue Aug 18 16:40:50 2015
@@ -0,0 +1,93 @@
+/**
+ * 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.aries.transaction;
+
+import static org.junit.Assert.assertEquals;
+
+import java.lang.reflect.Method;
+
+import javax.transaction.Transactional.TxType;
+
+import org.apache.aries.transaction.pojo.BadlyAnnotatedPojo1;
+import org.apache.aries.transaction.pojo.AnnotatedPojo;
+import org.apache.aries.transaction.pojo.ExtendedPojo;
+import org.apache.aries.transaction.pojo.ExtendedPojo2;
+import org.apache.aries.transaction.pojo.ExtendedPojo3;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class ComponentTxDataTest {
+
+    @Test
+    public void testFindAnnotation() throws NoSuchMethodException, SecurityException {
+        ComponentTxData txData = new ComponentTxData(AnnotatedPojo.class);
+        Assert.assertTrue(txData.isTransactional());
+        assertEquals(TxType.REQUIRED, getType(txData, "increment"));
+        assertEquals(TxType.SUPPORTS, getType(txData, "checkValue"));
+        assertEquals(TxType.MANDATORY, getType(txData, "getRealObject"));
+    }
+    
+    @Test
+    public void testFindAnnotationExtended() throws Exception {
+        ComponentTxData txData = new ComponentTxData(ExtendedPojo.class);
+        assertEquals(TxType.REQUIRED, getType(txData, "defaultType"));
+        assertEquals(TxType.SUPPORTS, getType(txData, "supports"));
+    }
+
+    
+    @Test
+    public void testFindAnnotationExtended2() throws Exception {
+        ComponentTxData txData = new ComponentTxData(ExtendedPojo2.class);
+        assertEquals(TxType.MANDATORY, getType(txData, "defaultType"));
+        assertEquals(TxType.SUPPORTS, getType(txData, "supports"));
+    }
+    
+    @Test
+    public void testFindAnnotationExtended3() throws Exception {
+        ComponentTxData txData = new ComponentTxData(ExtendedPojo3.class);
+        assertEquals(TxType.MANDATORY, getType(txData, "defaultType"));
+        assertEquals(TxType.REQUIRED, getType(txData, "supports"));
+    }
+
+    @Test(expected=IllegalArgumentException.class)
+    public void testNoPrivateAnnotation() {
+        new ComponentTxData(BadlyAnnotatedPojo1.class);
+    }
+
+    @Test(expected=IllegalArgumentException.class)
+    public void testNoStaticAnnotation() {
+        new ComponentTxData(BadlyAnnotatedPojo1.class);
+    }
+    
+    private TxType getType(ComponentTxData txData, String methodName) {
+        Class<?> c = txData.getBeanClass();
+        Method m;
+        try {
+            m = c.getDeclaredMethod(methodName, String.class);
+        } catch (NoSuchMethodException e) {
+            try {
+                m = c.getMethod(methodName, String.class);
+            } catch (NoSuchMethodException e1) {
+                throw new IllegalArgumentException(e1);
+            }
+        }
+        return txData.getEffectiveType(m);
+    }
+
+}

Modified: aries/trunk/transaction/transaction-blueprint/src/test/java/org/apache/aries/transaction/InterceptorTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/transaction/transaction-blueprint/src/test/java/org/apache/aries/transaction/InterceptorTest.java?rev=1696456&r1=1696455&r2=1696456&view=diff
==============================================================================
--- aries/trunk/transaction/transaction-blueprint/src/test/java/org/apache/aries/transaction/InterceptorTest.java (original)
+++ aries/trunk/transaction/transaction-blueprint/src/test/java/org/apache/aries/transaction/InterceptorTest.java Tue Aug 18 16:40:50 2015
@@ -26,11 +26,13 @@ import java.io.IOException;
 import javax.transaction.Transaction;
 import javax.transaction.TransactionManager;
 
+import org.apache.aries.transaction.pojo.AnnotatedPojo;
 import org.easymock.EasyMock;
 import org.easymock.IMocksControl;
 import org.junit.Test;
 import org.osgi.service.coordinator.Coordination;
 import org.osgi.service.coordinator.CoordinationException;
+import org.osgi.service.coordinator.Coordinator;
 
 public class InterceptorTest {
 
@@ -61,8 +63,10 @@ public class InterceptorTest {
     
     private void postCallWithTransaction(Throwable th, boolean expectRollback, boolean failCoordination) throws Throwable {
         IMocksControl c = EasyMock.createControl();
-        TxInterceptorImpl sut = new TxInterceptorImpl();
-        sut.setTransactionManager(c.createMock(TransactionManager.class));
+        TransactionManager tm = c.createMock(TransactionManager.class);
+        Coordinator coordinator = c.createMock(Coordinator.class);
+        ComponentTxData txData = new ComponentTxData(AnnotatedPojo.class);
+        TxInterceptorImpl sut = new TxInterceptorImpl(tm, coordinator, txData );
         Transaction tran = c.createMock(Transaction.class);
         
         if (expectRollback) {

Modified: aries/trunk/transaction/transaction-blueprint/src/test/java/org/apache/aries/transaction/TranStrategyTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/transaction/transaction-blueprint/src/test/java/org/apache/aries/transaction/TranStrategyTest.java?rev=1696456&r1=1696455&r2=1696456&view=diff
==============================================================================
--- aries/trunk/transaction/transaction-blueprint/src/test/java/org/apache/aries/transaction/TranStrategyTest.java (original)
+++ aries/trunk/transaction/transaction-blueprint/src/test/java/org/apache/aries/transaction/TranStrategyTest.java Tue Aug 18 16:40:50 2015
@@ -158,7 +158,7 @@ public class TranStrategyTest {
       expect(tm.getStatus()).andReturn(Status.STATUS_ACTIVE);
       expect(tm.suspend()).andReturn(null);
       c.replay();
-      TransactionAttribute.NOTSUPPORTED.begin(tm);
+      TransactionAttribute.NOT_SUPPORTED.begin(tm);
       c.verify();
        
       // For all situations where there is no active transaction the
@@ -173,7 +173,7 @@ public class TranStrategyTest {
           expect(tm.getTransaction()).andReturn(null).anyTimes();
           c.replay();
         try {
-          assertNull("TransactionStrategy.NOT_SUPPORTED.begin() did not return null when manager status value is " + invalids[i], TransactionAttribute.NOTSUPPORTED.begin(tm).getActiveTransaction());
+          assertNull("TransactionStrategy.NOT_SUPPORTED.begin() did not return null when manager status value is " + invalids[i], TransactionAttribute.NOT_SUPPORTED.begin(tm).getActiveTransaction());
         } catch (Exception ise) {
             fail("TransactionStrategy.NOT_SUPPORTED.begin() threw unexpected exception when manager status value is " + invalids[i]);
         } 
@@ -191,13 +191,13 @@ public class TranStrategyTest {
         tm.resume(t);
         EasyMock.expectLastCall();
         c.replay();
-        TransactionToken tranToken = new TransactionToken(null, t, TransactionAttribute.NOTSUPPORTED);
-        TransactionAttribute.NOTSUPPORTED.finish(tm, tranToken);
+        TransactionToken tranToken = new TransactionToken(null, t, TransactionAttribute.NOT_SUPPORTED);
+        TransactionAttribute.NOT_SUPPORTED.finish(tm, tranToken);
         c.verify();
         
         c.reset();
-        tranToken = new TransactionToken(null, null, TransactionAttribute.NOTSUPPORTED);
-        TransactionAttribute.NOTSUPPORTED.finish(tm, tranToken);
+        tranToken = new TransactionToken(null, null, TransactionAttribute.NOT_SUPPORTED);
+        TransactionAttribute.NOT_SUPPORTED.finish(tm, tranToken);
       } catch (Exception e) {
           fail("TransactionStrategy.NOT_SUPPORTED.finish() threw unexpected exception, " + e);
       }
@@ -288,7 +288,7 @@ public class TranStrategyTest {
       expectLastCall();
       expect(tm.getTransaction()).andReturn(null);
       c.replay();
-      TransactionAttribute.REQUIRESNEW.begin(tm);
+      TransactionAttribute.REQUIRES_NEW.begin(tm);
       c.verify();
     }
     
@@ -312,7 +312,7 @@ public class TranStrategyTest {
           expectLastCall();
           c.replay();
         try {
-          assertNull("TransactionStrategy.REQUIRES_NEW.begin() did not return null when manager status value is " + manStatus[i], TransactionAttribute.REQUIRESNEW.begin(tm).getActiveTransaction());
+          assertNull("TransactionStrategy.REQUIRES_NEW.begin() did not return null when manager status value is " + manStatus[i], TransactionAttribute.REQUIRES_NEW.begin(tm).getActiveTransaction());
         } catch (Exception ise) {
             fail("TransactionStrategy.REQUIRES_NEW.begin() threw unexpected exception when manager status value is " + manStatus[i]);
         } 
@@ -361,7 +361,7 @@ public class TranStrategyTest {
       expectLastCall();
       c.replay();
       try {
-          TransactionAttribute.REQUIRESNEW.begin(tm);
+          TransactionAttribute.REQUIRES_NEW.begin(tm);
       } catch (SystemException se) {
           // Expect to be in here
       } catch (NotSupportedException nse) {
@@ -392,8 +392,8 @@ public class TranStrategyTest {
             expectLastCall();
             c.replay();
             try {
-                TransactionToken tranToken = new TransactionToken(t, t, TransactionAttribute.REQUIRESNEW, true);
-                TransactionAttribute.REQUIRESNEW.finish(tm, tranToken);
+                TransactionToken tranToken = new TransactionToken(t, t, TransactionAttribute.REQUIRES_NEW, true);
+                TransactionAttribute.REQUIRES_NEW.finish(tm, tranToken);
             } catch (Exception e) {
                 fail("TransactionStrategy.REQUIRES_NEW.finish() threw unexpected exception when manager status is " + allStates[i]);
             }
@@ -403,8 +403,8 @@ public class TranStrategyTest {
                 expect(tm.getStatus()).andReturn(allStates[i]);
                 requiresNew_assertion(tm, allStates[i]);
                 c.replay();
-                TransactionToken tranToken = new TransactionToken(t, null, TransactionAttribute.REQUIRESNEW, true);
-                TransactionAttribute.REQUIRESNEW.finish(tm, tranToken);
+                TransactionToken tranToken = new TransactionToken(t, null, TransactionAttribute.REQUIRES_NEW, true);
+                TransactionAttribute.REQUIRES_NEW.finish(tm, tranToken);
             } catch (Throwable e) {
                 e.printStackTrace();
                 fail("TransactionStrategy.REQUIRES_NEW.finish() threw unexpected exception when manager status is " + allStates[i]);

Modified: aries/trunk/transaction/transaction-blueprint/src/test/java/org/apache/aries/transaction/pojo/AnnotatedPojo.java
URL: http://svn.apache.org/viewvc/aries/trunk/transaction/transaction-blueprint/src/test/java/org/apache/aries/transaction/pojo/AnnotatedPojo.java?rev=1696456&r1=1696455&r2=1696456&view=diff
==============================================================================
--- aries/trunk/transaction/transaction-blueprint/src/test/java/org/apache/aries/transaction/pojo/AnnotatedPojo.java (original)
+++ aries/trunk/transaction/transaction-blueprint/src/test/java/org/apache/aries/transaction/pojo/AnnotatedPojo.java Tue Aug 18 16:40:50 2015
@@ -18,21 +18,22 @@
  */
 package org.apache.aries.transaction.pojo;
 
-import org.apache.aries.transaction.annotations.Transaction;
-import org.apache.aries.transaction.annotations.TransactionPropagationType;
+import javax.transaction.Transactional;
+import javax.transaction.Transactional.TxType;
 
+@Transactional(TxType.REQUIRED)
 public class AnnotatedPojo {
-	
-	@Transaction
-	public void increment(String key) {}
 
-	@Transaction(TransactionPropagationType.Supports)
-	protected int checkValue(String key) {
-		return 0;
-	}
-	
-	@Transaction(TransactionPropagationType.Mandatory)
-	Object getRealObject(String key) {
-		return null;
-	}
+    public void increment(String key) {
+    }
+
+    @Transactional(TxType.SUPPORTS)
+    protected int checkValue(String key) {
+        return 0;
+    }
+
+    @Transactional(TxType.MANDATORY)
+    Object getRealObject(String key) {
+        return null;
+    }
 }

Modified: aries/trunk/transaction/transaction-blueprint/src/test/java/org/apache/aries/transaction/pojo/BadlyAnnotatedPojo1.java
URL: http://svn.apache.org/viewvc/aries/trunk/transaction/transaction-blueprint/src/test/java/org/apache/aries/transaction/pojo/BadlyAnnotatedPojo1.java?rev=1696456&r1=1696455&r2=1696456&view=diff
==============================================================================
--- aries/trunk/transaction/transaction-blueprint/src/test/java/org/apache/aries/transaction/pojo/BadlyAnnotatedPojo1.java (original)
+++ aries/trunk/transaction/transaction-blueprint/src/test/java/org/apache/aries/transaction/pojo/BadlyAnnotatedPojo1.java Tue Aug 18 16:40:50 2015
@@ -18,24 +18,12 @@
  */
 package org.apache.aries.transaction.pojo;
 
-import org.apache.aries.transaction.annotations.Transaction;
-import org.apache.aries.transaction.annotations.TransactionPropagationType;
+import javax.transaction.Transactional;
+
 
 public class BadlyAnnotatedPojo1 {
-	
-	@Transaction
-	public void increment(String key) {}
 
-	@Transaction(TransactionPropagationType.Supports)
-	protected int checkValue(String key) {
-		return 0;
-	}
-	
-	@Transaction(TransactionPropagationType.Mandatory)
-	Object getRealObject(String key) {
-		return null;
-	}
-	
-	@Transaction
-	private void doesNotWork() {}
+    @Transactional
+    private void doesNotWork() {
+    }
 }

Modified: aries/trunk/transaction/transaction-blueprint/src/test/java/org/apache/aries/transaction/pojo/BadlyAnnotatedPojo2.java
URL: http://svn.apache.org/viewvc/aries/trunk/transaction/transaction-blueprint/src/test/java/org/apache/aries/transaction/pojo/BadlyAnnotatedPojo2.java?rev=1696456&r1=1696455&r2=1696456&view=diff
==============================================================================
--- aries/trunk/transaction/transaction-blueprint/src/test/java/org/apache/aries/transaction/pojo/BadlyAnnotatedPojo2.java (original)
+++ aries/trunk/transaction/transaction-blueprint/src/test/java/org/apache/aries/transaction/pojo/BadlyAnnotatedPojo2.java Tue Aug 18 16:40:50 2015
@@ -18,24 +18,11 @@
  */
 package org.apache.aries.transaction.pojo;
 
-import org.apache.aries.transaction.annotations.Transaction;
-import org.apache.aries.transaction.annotations.TransactionPropagationType;
+import javax.transaction.Transactional;
 
 public class BadlyAnnotatedPojo2 {
-	
-	@Transaction
-	public void increment(String key) {}
 
-	@Transaction(TransactionPropagationType.Supports)
-	protected int checkValue(String key) {
-		return 0;
-	}
-	
-	@Transaction(TransactionPropagationType.Mandatory)
-	Object getRealObject(String key) {
-		return null;
-	}
-	
-	@Transaction
-	public static void alsoDoesNotWork() {}
+    @Transactional
+    public static void alsoDoesNotWork() {
+    }
 }

Added: aries/trunk/transaction/transaction-blueprint/src/test/java/org/apache/aries/transaction/pojo/BaseClass.java
URL: http://svn.apache.org/viewvc/aries/trunk/transaction/transaction-blueprint/src/test/java/org/apache/aries/transaction/pojo/BaseClass.java?rev=1696456&view=auto
==============================================================================
--- aries/trunk/transaction/transaction-blueprint/src/test/java/org/apache/aries/transaction/pojo/BaseClass.java (added)
+++ aries/trunk/transaction/transaction-blueprint/src/test/java/org/apache/aries/transaction/pojo/BaseClass.java Tue Aug 18 16:40:50 2015
@@ -0,0 +1,17 @@
+package org.apache.aries.transaction.pojo;
+
+import javax.transaction.Transactional;
+import javax.transaction.Transactional.TxType;
+
+@Transactional(value=TxType.REQUIRED)
+public class BaseClass {
+
+    @Transactional(value=TxType.NEVER)
+    public void defaultType(String test) {
+        
+    }
+    
+    public void supports(String test) {
+        
+    }
+}

Added: aries/trunk/transaction/transaction-blueprint/src/test/java/org/apache/aries/transaction/pojo/ExtendedPojo.java
URL: http://svn.apache.org/viewvc/aries/trunk/transaction/transaction-blueprint/src/test/java/org/apache/aries/transaction/pojo/ExtendedPojo.java?rev=1696456&view=auto
==============================================================================
--- aries/trunk/transaction/transaction-blueprint/src/test/java/org/apache/aries/transaction/pojo/ExtendedPojo.java (added)
+++ aries/trunk/transaction/transaction-blueprint/src/test/java/org/apache/aries/transaction/pojo/ExtendedPojo.java Tue Aug 18 16:40:50 2015
@@ -0,0 +1,17 @@
+package org.apache.aries.transaction.pojo;
+
+import javax.transaction.Transactional;
+import javax.transaction.Transactional.TxType;
+
+public class ExtendedPojo extends BaseClass {
+
+    @Override
+    public void defaultType(String test) {
+    }
+
+    @Transactional(value=TxType.SUPPORTS)
+    @Override
+    public void supports(String test) {
+    }
+
+}

Added: aries/trunk/transaction/transaction-blueprint/src/test/java/org/apache/aries/transaction/pojo/ExtendedPojo2.java
URL: http://svn.apache.org/viewvc/aries/trunk/transaction/transaction-blueprint/src/test/java/org/apache/aries/transaction/pojo/ExtendedPojo2.java?rev=1696456&view=auto
==============================================================================
--- aries/trunk/transaction/transaction-blueprint/src/test/java/org/apache/aries/transaction/pojo/ExtendedPojo2.java (added)
+++ aries/trunk/transaction/transaction-blueprint/src/test/java/org/apache/aries/transaction/pojo/ExtendedPojo2.java Tue Aug 18 16:40:50 2015
@@ -0,0 +1,18 @@
+package org.apache.aries.transaction.pojo;
+
+import javax.transaction.Transactional;
+import javax.transaction.Transactional.TxType;
+
+@Transactional(value=TxType.MANDATORY)
+public class ExtendedPojo2 extends BaseClass {
+
+    @Override
+    public void defaultType(String test) {
+    }
+
+    @Transactional(value=TxType.SUPPORTS)
+    @Override
+    public void supports(String test) {
+    }
+
+}

Added: aries/trunk/transaction/transaction-blueprint/src/test/java/org/apache/aries/transaction/pojo/ExtendedPojo3.java
URL: http://svn.apache.org/viewvc/aries/trunk/transaction/transaction-blueprint/src/test/java/org/apache/aries/transaction/pojo/ExtendedPojo3.java?rev=1696456&view=auto
==============================================================================
--- aries/trunk/transaction/transaction-blueprint/src/test/java/org/apache/aries/transaction/pojo/ExtendedPojo3.java (added)
+++ aries/trunk/transaction/transaction-blueprint/src/test/java/org/apache/aries/transaction/pojo/ExtendedPojo3.java Tue Aug 18 16:40:50 2015
@@ -0,0 +1,14 @@
+package org.apache.aries.transaction.pojo;
+
+import javax.transaction.Transactional;
+import javax.transaction.Transactional.TxType;
+
+@Transactional(value=TxType.MANDATORY)
+public class ExtendedPojo3 extends BaseClass {
+
+    @Override
+    public void defaultType(String test) {
+        super.defaultType(test);
+    }
+
+}

Modified: aries/trunk/transaction/transaction-blueprint/src/test/resources/org/apache/aries/transaction/enable-annotations.xml
URL: http://svn.apache.org/viewvc/aries/trunk/transaction/transaction-blueprint/src/test/resources/org/apache/aries/transaction/enable-annotations.xml?rev=1696456&r1=1696455&r2=1696456&view=diff
==============================================================================
--- aries/trunk/transaction/transaction-blueprint/src/test/resources/org/apache/aries/transaction/enable-annotations.xml (original)
+++ aries/trunk/transaction/transaction-blueprint/src/test/resources/org/apache/aries/transaction/enable-annotations.xml Tue Aug 18 16:40:50 2015
@@ -22,5 +22,5 @@
 
     <tx:enable-annotations/>
 	
-	<bean id="top" class="org.apache.aries.transaction.pojo.AnnotatedPojo"/>
+	<bean id="top" class="org.apache.aries.transaction.pojo.JtaAnnotatedPojo"/>
 </blueprint>
\ No newline at end of file

Modified: aries/trunk/transaction/transaction-itests/pom.xml
URL: http://svn.apache.org/viewvc/aries/trunk/transaction/transaction-itests/pom.xml?rev=1696456&r1=1696455&r2=1696456&view=diff
==============================================================================
--- aries/trunk/transaction/transaction-itests/pom.xml (original)
+++ aries/trunk/transaction/transaction-itests/pom.xml Tue Aug 18 16:40:50 2015
@@ -133,7 +133,7 @@
             <groupId>org.apache.aries.transaction</groupId>
             <artifactId>org.apache.aries.transaction.blueprint</artifactId>
             <scope>test</scope>
-            <version>1.2.0-SNAPSHOT</version>
+            <version>2.0.0-SNAPSHOT</version>
         </dependency>
         <dependency>
             <groupId>org.apache.aries.transaction</groupId>

Modified: aries/trunk/transaction/transaction-itests/src/test/java/org/apache/aries/transaction/itests/AbstractIntegrationTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/transaction/transaction-itests/src/test/java/org/apache/aries/transaction/itests/AbstractIntegrationTest.java?rev=1696456&r1=1696455&r2=1696456&view=diff
==============================================================================
--- aries/trunk/transaction/transaction-itests/src/test/java/org/apache/aries/transaction/itests/AbstractIntegrationTest.java (original)
+++ aries/trunk/transaction/transaction-itests/src/test/java/org/apache/aries/transaction/itests/AbstractIntegrationTest.java Tue Aug 18 16:40:50 2015
@@ -34,6 +34,7 @@ import javax.inject.Inject;
 import javax.transaction.RollbackException;
 import javax.transaction.UserTransaction;
 
+import org.apache.aries.transaction.test.Counter;
 import org.apache.aries.transaction.test.TestBean;
 import org.junit.Assert;
 import org.junit.runner.RunWith;
@@ -55,6 +56,9 @@ public abstract class AbstractIntegratio
     
     @Inject
     UserTransaction tran;
+    
+    @Inject
+    Counter counter;
 
     protected boolean clientTransaction = true;
 
@@ -103,11 +107,15 @@ public abstract class AbstractIntegratio
                 mavenBundle("org.apache.aries.transaction", "org.apache.aries.transaction.testbundle").versionAsInProject(),
                 mavenBundle("org.apache.aries.transaction", "org.apache.aries.transaction.testds").versionAsInProject(),
 
-                //new VMOption( "-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000" ),
+                //debug(),
                 //new TimeoutOption( 0 ),
         };
     }
 
+    protected Option debug() {
+        return vmOption("-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005");
+    }
+
     private Option jta12Bundles() {
             return CoreOptions.composite(
                 mavenBundle("javax.interceptor", "javax.interceptor-api").versionAsInProject(),
@@ -138,12 +146,12 @@ public abstract class AbstractIntegratio
     // Test with client transaction and runtime exception - the user transaction is rolled back
     protected void assertInsertWithRuntimeExceptionRolledBack() throws Exception {
         TestBean bean = getBean();
-        int initialRows = bean.countRows();
+        int initialRows = counter.countRows();
 
         if (clientTransaction) {
             tran.begin();
         }
-        bean.insertRow("testWithClientTranAndWithRuntimeException", 1);
+        bean.insertRow("testWithClientTranAndWithRuntimeException", 1, null);
         try {
             bean.insertRow("testWithClientTranAndWithRuntimeException", 2, new RuntimeException("Dummy exception"));
         } catch (RuntimeException e) {
@@ -158,7 +166,7 @@ public abstract class AbstractIntegratio
             }
         }
 
-        int finalRows = bean.countRows();
+        int finalRows = counter.countRows();
         // In case of client transaction both are rolled back
         // In case of container transaction only second insert is rolled back
         assertEquals("Added rows", clientTransaction ? 0 : 1, finalRows - initialRows);
@@ -166,11 +174,11 @@ public abstract class AbstractIntegratio
 
     protected void assertInsertWithAppExceptionCommitted() throws Exception {
         TestBean bean = getBean();
-        int initialRows = bean.countRows();
+        int initialRows = counter.countRows();
         if (clientTransaction) {
             tran.begin();
         }
-        bean.insertRow("testWithClientTranAndWithAppException", 1);
+        bean.insertRow("testWithClientTranAndWithAppException", 1, null);
         try {
             bean.insertRow("testWithClientTranAndWithAppException", 2, new SQLException("Dummy exception"));
         } catch (SQLException e) {
@@ -180,33 +188,33 @@ public abstract class AbstractIntegratio
             tran.commit();
         }
 
-        int finalRows = bean.countRows();
+        int finalRows = counter.countRows();
         assertEquals("Added rows", 2, finalRows - initialRows);
     }
 
     protected void assertInsertSuccesful() throws Exception {
         TestBean bean = getBean();
-        int initialRows = bean.countRows();
+        int initialRows = counter.countRows();
 
         if (clientTransaction ) {
             tran.begin();
         }
-        bean.insertRow("testWithClientTran", 1);
+        bean.insertRow("testWithClientTran", 1, null);
         if (clientTransaction ) {
             tran.commit();
         }
-        int finalRows = bean.countRows();
+        int finalRows = counter.countRows();
         assertEquals("Added rows", 1, finalRows - initialRows);
     }
 
     protected void assertInsertFails() throws Exception {
         TestBean bean = getBean();
-        int initialRows = bean.countRows();
+        int initialRows = counter.countRows();
         if (clientTransaction ) {
             tran.begin();
         }
         try {
-            bean.insertRow("testWithClientTran", 1);
+            bean.insertRow("testWithClientTran", 1, null);
             fail("IllegalStateException not thrown");
         } catch (IllegalStateException e) {
             // Ignore Expected
@@ -214,7 +222,7 @@ public abstract class AbstractIntegratio
         if (clientTransaction ) {
             tran.commit();
         }
-        int finalRows = bean.countRows();
+        int finalRows = counter.countRows();
         assertEquals("Added rows", 0, finalRows - initialRows);
     }
     
@@ -222,7 +230,7 @@ public abstract class AbstractIntegratio
     // bean with a transaction strategy of Mandatory, and no transaction is available
     protected void assertDelegateInsertFails() throws Exception {
         TestBean bean = getBean();
-        int initialRows = bean.countRows();
+        int initialRows = counter.countRows();
 
         if (clientTransaction ) {
             tran.begin();
@@ -236,14 +244,14 @@ public abstract class AbstractIntegratio
         if (clientTransaction ) {
             tran.commit();
         }
-        int finalRows = bean.countRows();
+        int finalRows = counter.countRows();
         assertEquals("Added rows", 0, finalRows - initialRows);
     }
 
     // Test without client transaction - an exception is thrown because a transaction is mandatory
     protected void assertMandatoryTransaction() throws SQLException {
           try {
-              getBean().insertRow("testWithoutClientTran", 1);
+              getBean().insertRow("testWithoutClientTran", 1, null);
               fail("IllegalStateException not thrown");
           } catch (IllegalStateException e) {
               // Ignore expected
@@ -254,13 +262,13 @@ public abstract class AbstractIntegratio
 
     protected void assertDelegateInsert() throws Exception {
         TestBean bean = getBean();
-        int initialRows = bean.countRows();
+        int initialRows = counter.countRows();
     
         tran.begin();
         bean.delegateInsertRow("testWithClientTran", 1);
         tran.commit();
     
-        int finalRows = bean.countRows();
+        int finalRows = counter.countRows();
         assertEquals("Added rows", 1, finalRows - initialRows);
     }
 }
\ No newline at end of file

Copied: aries/trunk/transaction/transaction-itests/src/test/java/org/apache/aries/transaction/itests/MandatoryTest.java (from r1696014, aries/trunk/transaction/transaction-itests/src/test/java/org/apache/aries/transaction/itests/MandatoryTranAttributeTest.java)
URL: http://svn.apache.org/viewvc/aries/trunk/transaction/transaction-itests/src/test/java/org/apache/aries/transaction/itests/MandatoryTest.java?p2=aries/trunk/transaction/transaction-itests/src/test/java/org/apache/aries/transaction/itests/MandatoryTest.java&p1=aries/trunk/transaction/transaction-itests/src/test/java/org/apache/aries/transaction/itests/MandatoryTranAttributeTest.java&r1=1696014&r2=1696456&rev=1696456&view=diff
==============================================================================
--- aries/trunk/transaction/transaction-itests/src/test/java/org/apache/aries/transaction/itests/MandatoryTranAttributeTest.java (original)
+++ aries/trunk/transaction/transaction-itests/src/test/java/org/apache/aries/transaction/itests/MandatoryTest.java Tue Aug 18 16:40:50 2015
@@ -21,7 +21,7 @@ import org.apache.aries.transaction.test
 import org.junit.Test;
 import org.ops4j.pax.exam.util.Filter;
 
-public class MandatoryTranAttributeTest extends AbstractIntegrationTest {
+public class MandatoryTest extends AbstractIntegrationTest {
     @Inject
     @Filter("(tranAttribute=Mandatory)")
     TestBean bean;
@@ -30,14 +30,17 @@ public class MandatoryTranAttributeTest
     public void testMandatory() throws Exception {
         assertInsertSuccesful();
         assertInsertWithAppExceptionCommitted();
-        assertInsertWithRuntimeExceptionRolledBack();
         assertMandatoryTransaction();
     }
-
+    
+    @Test
+    public void testInsertWithRuntimeExceptionRolledBack() throws Exception {
+        assertInsertWithRuntimeExceptionRolledBack();
+    }
+    
     @Override
     protected TestBean getBean() {
         return bean;
     }
 
-
 }

Copied: aries/trunk/transaction/transaction-itests/src/test/java/org/apache/aries/transaction/itests/NeverTest.java (from r1696014, aries/trunk/transaction/transaction-itests/src/test/java/org/apache/aries/transaction/itests/NeverTranAttributeTest.java)
URL: http://svn.apache.org/viewvc/aries/trunk/transaction/transaction-itests/src/test/java/org/apache/aries/transaction/itests/NeverTest.java?p2=aries/trunk/transaction/transaction-itests/src/test/java/org/apache/aries/transaction/itests/NeverTest.java&p1=aries/trunk/transaction/transaction-itests/src/test/java/org/apache/aries/transaction/itests/NeverTranAttributeTest.java&r1=1696014&r2=1696456&rev=1696456&view=diff
==============================================================================
--- aries/trunk/transaction/transaction-itests/src/test/java/org/apache/aries/transaction/itests/NeverTranAttributeTest.java (original)
+++ aries/trunk/transaction/transaction-itests/src/test/java/org/apache/aries/transaction/itests/NeverTest.java Tue Aug 18 16:40:50 2015
@@ -21,7 +21,7 @@ import org.apache.aries.transaction.test
 import org.junit.Test;
 import org.ops4j.pax.exam.util.Filter;
 
-public class NeverTranAttributeTest extends AbstractIntegrationTest {
+public class NeverTest extends AbstractIntegrationTest {
     @Inject
     @Filter("(tranAttribute=Never)")
     TestBean bean;

Copied: aries/trunk/transaction/transaction-itests/src/test/java/org/apache/aries/transaction/itests/NotSupportedTest.java (from r1696014, aries/trunk/transaction/transaction-itests/src/test/java/org/apache/aries/transaction/itests/NeverTranAttributeTest.java)
URL: http://svn.apache.org/viewvc/aries/trunk/transaction/transaction-itests/src/test/java/org/apache/aries/transaction/itests/NotSupportedTest.java?p2=aries/trunk/transaction/transaction-itests/src/test/java/org/apache/aries/transaction/itests/NotSupportedTest.java&p1=aries/trunk/transaction/transaction-itests/src/test/java/org/apache/aries/transaction/itests/NeverTranAttributeTest.java&r1=1696014&r2=1696456&rev=1696456&view=diff
==============================================================================
--- aries/trunk/transaction/transaction-itests/src/test/java/org/apache/aries/transaction/itests/NeverTranAttributeTest.java (original)
+++ aries/trunk/transaction/transaction-itests/src/test/java/org/apache/aries/transaction/itests/NotSupportedTest.java Tue Aug 18 16:40:50 2015
@@ -15,36 +15,62 @@
  */
 package org.apache.aries.transaction.itests;
 
+import static junit.framework.Assert.assertEquals;
+
+import java.sql.SQLException;
+
 import javax.inject.Inject;
 
 import org.apache.aries.transaction.test.TestBean;
 import org.junit.Test;
 import org.ops4j.pax.exam.util.Filter;
 
-public class NeverTranAttributeTest extends AbstractIntegrationTest {
+public class NotSupportedTest extends AbstractIntegrationTest {
+    @Inject
+    @Filter("(tranAttribute=NotSupported)")
+    TestBean nsBean;
+
     @Inject
-    @Filter("(tranAttribute=Never)")
-    TestBean bean;
+    @Filter("(tranAttribute=Required)")
+    TestBean rBean;
 
     /**
-     * Test with client transaction - an exception is thrown because transactions are not allowed
+     * The client transaction is suspended. So the delegate bean that mandates a transaction
+     * fails.
      * @throws Exception
      */
     @Test
-    public void testInsertFails() throws Exception {
-        clientTransaction = true;
-        assertInsertFails();
-    }
-    
-    @Test
-    public void testDelegateInsertFails() throws Exception {
+    public void testNotSupported() throws Exception {
+        assertDelegateInsertFails();
         clientTransaction = false;
         assertDelegateInsertFails();
     }
 
+    @Test
+    public void testExceptionsDoNotAffectTransaction() throws Exception {
+        int initialRows = counter.countRows();
+
+        tran.begin();
+        rBean.insertRow("testWithClientTranAndWithRuntimeException", 1, null);
+        try {
+            nsBean.throwApplicationException();
+        } catch (SQLException e) {
+            // Ignore expected
+        }
+        try {
+            nsBean.throwRuntimeException();
+        } catch (RuntimeException e) {
+            // Ignore expected
+        }
+        tran.commit();
+
+        int finalRows = counter.countRows();
+        assertEquals("Added rows", 1, finalRows - initialRows);
+
+    }
+
     @Override
     protected TestBean getBean() {
-        return bean;
+        return nsBean;
     }
-
 }

Copied: aries/trunk/transaction/transaction-itests/src/test/java/org/apache/aries/transaction/itests/RequiredTest.java (from r1696014, aries/trunk/transaction/transaction-itests/src/test/java/org/apache/aries/transaction/itests/RequiredTranAttributeTest.java)
URL: http://svn.apache.org/viewvc/aries/trunk/transaction/transaction-itests/src/test/java/org/apache/aries/transaction/itests/RequiredTest.java?p2=aries/trunk/transaction/transaction-itests/src/test/java/org/apache/aries/transaction/itests/RequiredTest.java&p1=aries/trunk/transaction/transaction-itests/src/test/java/org/apache/aries/transaction/itests/RequiredTranAttributeTest.java&r1=1696014&r2=1696456&rev=1696456&view=diff
==============================================================================
--- aries/trunk/transaction/transaction-itests/src/test/java/org/apache/aries/transaction/itests/RequiredTranAttributeTest.java (original)
+++ aries/trunk/transaction/transaction-itests/src/test/java/org/apache/aries/transaction/itests/RequiredTest.java Tue Aug 18 16:40:50 2015
@@ -21,16 +21,24 @@ import org.apache.aries.transaction.test
 import org.junit.Test;
 import org.ops4j.pax.exam.util.Filter;
 
-public class RequiredTranAttributeTest extends AbstractIntegrationTest {
+public class RequiredTest extends AbstractIntegrationTest {
     @Inject
-    @Filter("(tranAttribute=Required)")
+    @Filter(timeout=120000, value="(tranAttribute=Required)")
     TestBean bean;
 
     @Test
-    public void testRequired() throws Exception {
+    public void testInsertSuccesful() throws Exception {
         clientTransaction = false;
         assertInsertSuccesful();
+    }
+    
+    @Test
+    public void testInsertWithAppExceptionCommitted() throws Exception {
         assertInsertWithAppExceptionCommitted();
+    }
+    
+    @Test
+    public void testInsertWithRuntimeExceptionRolledBack() throws Exception {
         assertInsertWithRuntimeExceptionRolledBack();
     }
 

Copied: aries/trunk/transaction/transaction-itests/src/test/java/org/apache/aries/transaction/itests/RequiresNewTest.java (from r1696014, aries/trunk/transaction/transaction-itests/src/test/java/org/apache/aries/transaction/itests/RequiresNewTranAttributeTest.java)
URL: http://svn.apache.org/viewvc/aries/trunk/transaction/transaction-itests/src/test/java/org/apache/aries/transaction/itests/RequiresNewTest.java?p2=aries/trunk/transaction/transaction-itests/src/test/java/org/apache/aries/transaction/itests/RequiresNewTest.java&p1=aries/trunk/transaction/transaction-itests/src/test/java/org/apache/aries/transaction/itests/RequiresNewTranAttributeTest.java&r1=1696014&r2=1696456&rev=1696456&view=diff
==============================================================================
--- aries/trunk/transaction/transaction-itests/src/test/java/org/apache/aries/transaction/itests/RequiresNewTranAttributeTest.java (original)
+++ aries/trunk/transaction/transaction-itests/src/test/java/org/apache/aries/transaction/itests/RequiresNewTest.java Tue Aug 18 16:40:50 2015
@@ -25,7 +25,7 @@ import org.apache.aries.transaction.test
 import org.junit.Test;
 import org.ops4j.pax.exam.util.Filter;
 
-public class RequiresNewTranAttributeTest extends AbstractIntegrationTest {
+public class RequiresNewTest extends AbstractIntegrationTest {
     @Inject
     @Filter("(tranAttribute=RequiresNew)")
     TestBean rnBean;
@@ -41,11 +41,11 @@ public class RequiresNewTranAttributeTes
      */
     @Test
     public void testClientTransactionRollback() throws Exception {
-        int initialRows = rnBean.countRows();
+        int initialRows = counter.countRows();
         tran.begin();
-        rnBean.insertRow("testWithClientTran", 1);
+        rnBean.insertRow("testWithClientTran", 1, null);
         tran.rollback();
-        int finalRows = rnBean.countRows();
+        int finalRows = counter.countRows();
         assertEquals("Added rows", 1, finalRows - initialRows);
     }
     
@@ -56,16 +56,16 @@ public class RequiresNewTranAttributeTes
      */
     @Test
     public void testClientTransactionAndApplicationException() throws Exception {
-        int initialRows = rnBean.countRows();
+        int initialRows = counter.countRows();
         tran.begin();
-        rBean.insertRow("testWithClientTranAndWithAppException", 1);
+        rBean.insertRow("testWithClientTranAndWithAppException", 1, null);
         try {
             rnBean.insertRow("testWithClientTranAndWithAppException", 2, new SQLException("Dummy exception"));
         } catch (SQLException e) {
             // Ignore expected
         }
         tran.commit();
-        int finalRows = rnBean.countRows();
+        int finalRows = counter.countRows();
         assertEquals("Added rows", 2, finalRows - initialRows);
 
     }
@@ -77,16 +77,16 @@ public class RequiresNewTranAttributeTes
      */
     @Test
     public void testClientTransactionAndRuntimeException() throws Exception {
-        int initialRows = rnBean.countRows();
+        int initialRows = counter.countRows();
         tran.begin();
-        rBean.insertRow("testWithClientTranAndWithRuntimeException", 1);
+        rBean.insertRow("testWithClientTranAndWithRuntimeException", 1, null);
         try {
             rnBean.insertRow("testWithClientTranAndWithRuntimeException", 2, new RuntimeException("Dummy exception"));
         } catch (RuntimeException e) {
          // Ignore expected
         }
         tran.commit();
-        int finalRows = rnBean.countRows();
+        int finalRows = counter.countRows();
         assertEquals("Added rows", 1, finalRows - initialRows);
     }
     

Copied: aries/trunk/transaction/transaction-itests/src/test/java/org/apache/aries/transaction/itests/SupportsTest.java (from r1696014, aries/trunk/transaction/transaction-itests/src/test/java/org/apache/aries/transaction/itests/SupportsTranAttributeTest.java)
URL: http://svn.apache.org/viewvc/aries/trunk/transaction/transaction-itests/src/test/java/org/apache/aries/transaction/itests/SupportsTest.java?p2=aries/trunk/transaction/transaction-itests/src/test/java/org/apache/aries/transaction/itests/SupportsTest.java&p1=aries/trunk/transaction/transaction-itests/src/test/java/org/apache/aries/transaction/itests/SupportsTranAttributeTest.java&r1=1696014&r2=1696456&rev=1696456&view=diff
==============================================================================
--- aries/trunk/transaction/transaction-itests/src/test/java/org/apache/aries/transaction/itests/SupportsTranAttributeTest.java (original)
+++ aries/trunk/transaction/transaction-itests/src/test/java/org/apache/aries/transaction/itests/SupportsTest.java Tue Aug 18 16:40:50 2015
@@ -21,7 +21,7 @@ import org.apache.aries.transaction.test
 import org.junit.Test;
 import org.ops4j.pax.exam.util.Filter;
 
-public class SupportsTranAttributeTest extends AbstractIntegrationTest {
+public class SupportsTest extends AbstractIntegrationTest {
     @Inject
     @Filter("(tranAttribute=Supports)")
     TestBean bean;



Mime
View raw message