[seam-commits] Seam SVN: r13430 - in modules/persistence/trunk: api and 4 other directories.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Sun Jul 18 05:57:51 EDT 2010


Author: swd847
Date: 2010-07-18 05:57:51 -0400 (Sun, 18 Jul 2010)
New Revision: 13430

Added:
   modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/transaction/TransactionPropagation.java
   modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/transaction/Transactional.java
Removed:
   modules/persistence/trunk/impl/src/main/java/org/jboss/seam/transaction/JtaTxInterceptor.java
   modules/persistence/trunk/impl/src/main/java/org/jboss/seam/transaction/TransactionPropagation.java
   modules/persistence/trunk/impl/src/main/java/org/jboss/seam/transaction/Transactional.java
Modified:
   modules/persistence/trunk/api/pom.xml
   modules/persistence/trunk/impl/pom.xml
   modules/persistence/trunk/impl/src/main/java/org/jboss/seam/transaction/TransactionInterceptor.java
   modules/persistence/trunk/impl/src/test/java/org/jboss/seam/transactions/test/TransactionManagedBean.java
   modules/persistence/trunk/pom.xml
Log:
move classes to API



Modified: modules/persistence/trunk/api/pom.xml
===================================================================
--- modules/persistence/trunk/api/pom.xml	2010-07-18 08:58:16 UTC (rev 13429)
+++ modules/persistence/trunk/api/pom.xml	2010-07-18 09:57:51 UTC (rev 13430)
@@ -16,7 +16,23 @@
    <prerequisites>
       <maven>3.0</maven>
    </prerequisites>
+   
+   <dependencies>
+   
+      <dependency>
+        <groupId>javax.enterprise</groupId>
+        <artifactId>cdi-api</artifactId>
+      </dependency>
 
+	  <dependency>
+		  <groupId>org.jboss.spec</groupId>
+		  <artifactId>jboss-javaee-6.0</artifactId>
+		  <type>pom</type>
+		  <scope>provided</scope>
+	  </dependency>
+	  
+   </dependencies>
+
    <scm>
       <connection>scm:svn:http://anonsvn.jboss.org/repos/seam/modules/persistence/trunk/api</connection>
       <developerConnection>scm:svn:https://svn.jboss.org/repos/seam/modules/persistence/trunk/api</developerConnection>

Copied: modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/transaction/TransactionPropagation.java (from rev 13428, modules/persistence/trunk/impl/src/main/java/org/jboss/seam/transaction/TransactionPropagation.java)
===================================================================
--- modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/transaction/TransactionPropagation.java	                        (rev 0)
+++ modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/transaction/TransactionPropagation.java	2010-07-18 09:57:51 UTC (rev 13430)
@@ -0,0 +1,61 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.persistence.transaction;
+
+/**
+ * @author Dan Allen
+ */
+public enum TransactionPropagation
+{
+   REQUIRED, SUPPORTS, MANDATORY, NEVER;
+
+   public boolean isNewTransactionRequired(boolean transactionActive)
+   {
+      switch (this)
+      {
+      case REQUIRED:
+         return !transactionActive;
+      case SUPPORTS:
+         return false;
+      case MANDATORY:
+         if (!transactionActive)
+         {
+            throw new IllegalStateException("No transaction active on call to MANDATORY method");
+         }
+         else
+         {
+            return false;
+         }
+      case NEVER:
+         if (transactionActive)
+         {
+            throw new IllegalStateException("Transaction active on call to NEVER method");
+         }
+         else
+         {
+            return false;
+         }
+      default:
+         throw new IllegalArgumentException();
+      }
+   }
+}
\ No newline at end of file

Copied: modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/transaction/Transactional.java (from rev 13428, modules/persistence/trunk/impl/src/main/java/org/jboss/seam/transaction/Transactional.java)
===================================================================
--- modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/transaction/Transactional.java	                        (rev 0)
+++ modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/transaction/Transactional.java	2010-07-18 09:57:51 UTC (rev 13430)
@@ -0,0 +1,50 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.persistence.transaction;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.enterprise.util.Nonbinding;
+import javax.interceptor.InterceptorBinding;
+
+
+/**
+ * @author Dan Allen
+ */
+ at Inherited
+ at InterceptorBinding
+ at Retention(RetentionPolicy.RUNTIME)
+ at Target( { ElementType.METHOD, ElementType.TYPE })
+public @interface Transactional
+{
+   /**
+    * The transaction propagation type.
+    * 
+    * @return REQUIRED by default
+    */
+   @Nonbinding 
+   TransactionPropagation value() default TransactionPropagation.REQUIRED;
+}
\ No newline at end of file

Modified: modules/persistence/trunk/impl/pom.xml
===================================================================
--- modules/persistence/trunk/impl/pom.xml	2010-07-18 08:58:16 UTC (rev 13429)
+++ modules/persistence/trunk/impl/pom.xml	2010-07-18 09:57:51 UTC (rev 13430)
@@ -22,7 +22,6 @@
       <jboss.domain>default</jboss.domain>
       <glassfish.version>3.0.1-b19</glassfish.version>
       <jboss-as-client.version>6.0.0-SNAPSHOT</jboss-as-client.version>
-      <jboss-javaee6-spec.version>1.0.0.Beta4</jboss-javaee6-spec.version>
       <jboss-server-manager.version>1.0.3.GA</jboss-server-manager.version>
    </properties>
 
@@ -30,34 +29,7 @@
       <maven>3.0</maven>
    </prerequisites>
 
-   <dependencyManagement>
-      <dependencies>
-         <dependency>
-            <groupId>org.jboss.seam</groupId>
-            <artifactId>seam</artifactId>
-            <version>${seam.version}</version>
-            <type>pom</type>
-            <scope>import</scope>
-         </dependency>
 
-         <dependency>
-            <groupId>org.jboss.arquillian</groupId>
-            <artifactId>arquillian-junit</artifactId>
-            <version>${arquillian.version}</version>
-            <scope>test</scope>
-         </dependency>
-
-         <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <version>${junit.version}</version>
-         </dependency>
-
-      </dependencies>
-
-
-   </dependencyManagement>
-
    <dependencies>
       <dependency>
          <groupId>junit</groupId>
@@ -104,7 +76,6 @@
        <dependency>
           <groupId>org.jboss.spec</groupId>
           <artifactId>jboss-javaee-6.0</artifactId>
-          <version>${jboss-javaee6-spec.version}</version>
           <type>pom</type>
           <scope>provided</scope>
        </dependency>

Deleted: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/transaction/JtaTxInterceptor.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/transaction/JtaTxInterceptor.java	2010-07-18 08:58:16 UTC (rev 13429)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/transaction/JtaTxInterceptor.java	2010-07-18 09:57:51 UTC (rev 13430)
@@ -1,146 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat, Inc., and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.seam.transaction;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Method;
-
-import javax.inject.Inject;
-import javax.interceptor.AroundInvoke;
-import javax.interceptor.Interceptor;
-import javax.interceptor.InvocationContext;
-import javax.transaction.Status;
-import javax.transaction.UserTransaction;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * A rudimentary transaction interceptor implementation, intended as a proof
- * of concept.
- *
- * @author Matt Corey
- * @author Dan Allen
- */
-public @Transactional @Interceptor class JtaTxInterceptor {
-
-   private static final Logger log = LoggerFactory.getLogger(JtaTxInterceptor.class);
-
-   @Inject private UserTransaction utx;
-
-   /**
-    * Super quick impl. Needs to be done correctly.
-    */
-   @AroundInvoke
-   public Object workInTransaction(InvocationContext ic) throws Exception {
-      // TODO cache this information
-      TransactionPropagation type = getTransactionPropagation(ic.getMethod());
-
-      int status = utx.getStatus();
-      boolean transactionActive = (status == Status.STATUS_ACTIVE || status == Status.STATUS_MARKED_ROLLBACK);
-      boolean beginTransaction = isNewTransactionRequired(type, transactionActive);
-
-      if (beginTransaction) {
-         log.debug("Beginning transaction");
-         utx.begin();
-      }
-
-      Object result = null;
-      try {
-         result = ic.proceed();
-
-         if (beginTransaction) {
-            if (utx.getStatus() == Status.STATUS_MARKED_ROLLBACK) {
-               log.debug("Rolling back transaction marked for rollback");
-               utx.rollback();
-            }
-            else {
-               log.debug("Committing transaction");
-               utx.commit();
-            }
-         }
-
-         return result;
-      } catch (Exception e) {
-         if (beginTransaction && utx.getStatus() != Status.STATUS_NO_TRANSACTION) {
-            // FIXME don't rollback if this is an application exception which indicates no rollback
-            log.debug("Rolling back transaction as the result of an exception");
-            utx.rollback();
-         }
-
-         throw e;
-      }
-   }
-
-    /**
-     * Get the TransactionPropagation value
-     * FIXME cache this information
-     */
-    private TransactionPropagation getTransactionPropagation(Method m) {
-       // first look at the explicit method-level annotation
-       if (m.isAnnotationPresent(Transactional.class)) {
-          return m.getAnnotation(Transactional.class).value();
-       }
-        // now look at the method-level meta-annotations
-        for (Annotation a: m.getAnnotations()) {
-            if (a.annotationType().isAnnotationPresent(Transactional.class)) {
-                return a.annotationType().getAnnotation(Transactional.class).value();
-            }
-        }
-        // now try the explicit class-level annotation
-        if (m.getDeclaringClass().isAnnotationPresent(Transactional.class)) {
-           return m.getDeclaringClass().getAnnotation(Transactional.class).value();
-        }
-        // finally, try the class-level meta-annotations
-        for (Annotation a: m.getDeclaringClass().getAnnotations()) {
-            if (a.annotationType().isAnnotationPresent(Transactional.class)) {
-                return a.annotationType().getAnnotation(Transactional.class).value();
-            }
-        }
-        return null;
-    }
-
-   private boolean isNewTransactionRequired(TransactionPropagation type, boolean transactionActive) {
-      switch (type) {
-         case REQUIRED:
-            return !transactionActive;
-         case SUPPORTS:
-            return false;
-         case MANDATORY:
-            if (!transactionActive) {
-               throw new IllegalStateException("No transaction active on call to method that requires a transaction.");
-            }
-            else {
-               return false;
-            }
-         case NEVER:
-            if (transactionActive) {
-               throw new IllegalStateException("Transaction active on call to method that does not support transactions.");
-            }
-            else {
-               return false;
-            }
-         default:
-            throw new IllegalArgumentException("Unknown transaction type " + type);
-      }
-   }
-}
\ No newline at end of file

Modified: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/transaction/TransactionInterceptor.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/transaction/TransactionInterceptor.java	2010-07-18 08:58:16 UTC (rev 13429)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/transaction/TransactionInterceptor.java	2010-07-18 09:57:51 UTC (rev 13430)
@@ -31,6 +31,9 @@
 import javax.interceptor.Interceptor;
 import javax.interceptor.InvocationContext;
 
+import org.jboss.seam.persistence.transaction.TransactionPropagation;
+import org.jboss.seam.persistence.transaction.Transactional;
+
 /**
  * Implements transaction propagation rules for Seam JavaBean components.
  * 

Deleted: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/transaction/TransactionPropagation.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/transaction/TransactionPropagation.java	2010-07-18 08:58:16 UTC (rev 13429)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/transaction/TransactionPropagation.java	2010-07-18 09:57:51 UTC (rev 13430)
@@ -1,61 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat, Inc., and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.seam.transaction;
-
-/**
- * @author Dan Allen
- */
-public enum TransactionPropagation
-{
-   REQUIRED, SUPPORTS, MANDATORY, NEVER;
-
-   public boolean isNewTransactionRequired(boolean transactionActive)
-   {
-      switch (this)
-      {
-      case REQUIRED:
-         return !transactionActive;
-      case SUPPORTS:
-         return false;
-      case MANDATORY:
-         if (!transactionActive)
-         {
-            throw new IllegalStateException("No transaction active on call to MANDATORY method");
-         }
-         else
-         {
-            return false;
-         }
-      case NEVER:
-         if (transactionActive)
-         {
-            throw new IllegalStateException("Transaction active on call to NEVER method");
-         }
-         else
-         {
-            return false;
-         }
-      default:
-         throw new IllegalArgumentException();
-      }
-   }
-}
\ No newline at end of file

Deleted: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/transaction/Transactional.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/transaction/Transactional.java	2010-07-18 08:58:16 UTC (rev 13429)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/transaction/Transactional.java	2010-07-18 09:57:51 UTC (rev 13430)
@@ -1,49 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat, Inc., and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.seam.transaction;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-import javax.enterprise.util.Nonbinding;
-import javax.interceptor.InterceptorBinding;
-
-/**
- * @author Dan Allen
- */
- at Inherited
- at InterceptorBinding
- at Retention(RetentionPolicy.RUNTIME)
- at Target( { ElementType.METHOD, ElementType.TYPE })
-public @interface Transactional
-{
-   /**
-    * The transaction propagation type.
-    * 
-    * @return REQUIRED by default
-    */
-   @Nonbinding
-   TransactionPropagation value() default TransactionPropagation.REQUIRED;
-}
\ No newline at end of file

Modified: modules/persistence/trunk/impl/src/test/java/org/jboss/seam/transactions/test/TransactionManagedBean.java
===================================================================
--- modules/persistence/trunk/impl/src/test/java/org/jboss/seam/transactions/test/TransactionManagedBean.java	2010-07-18 08:58:16 UTC (rev 13429)
+++ modules/persistence/trunk/impl/src/test/java/org/jboss/seam/transactions/test/TransactionManagedBean.java	2010-07-18 09:57:51 UTC (rev 13430)
@@ -3,8 +3,8 @@
 import javax.inject.Inject;
 import javax.persistence.EntityManager;
 
-import org.jboss.seam.transaction.TransactionPropagation;
-import org.jboss.seam.transaction.Transactional;
+import org.jboss.seam.persistence.transaction.TransactionPropagation;
+import org.jboss.seam.persistence.transaction.Transactional;
 import org.jboss.seam.transactions.test.util.DontRollBackException;
 
 @Transactional(TransactionPropagation.REQUIRED)

Modified: modules/persistence/trunk/pom.xml
===================================================================
--- modules/persistence/trunk/pom.xml	2010-07-18 08:58:16 UTC (rev 13429)
+++ modules/persistence/trunk/pom.xml	2010-07-18 09:57:51 UTC (rev 13430)
@@ -31,6 +31,7 @@
 
    <properties>
       <seam.version>3.0.0.b01</seam.version>
+      <jboss-javaee6-spec.version>1.0.0.Beta4</jboss-javaee6-spec.version>
    </properties>
 
    <dependencyManagement>
@@ -50,8 +51,15 @@
             <artifactId>seam-persistence-api</artifactId>
             <version>${project.version}</version>
          </dependency>
-
-
+         
+        <dependency>
+          <groupId>org.jboss.spec</groupId>
+          <artifactId>jboss-javaee-6.0</artifactId>
+          <version>${jboss-javaee6-spec.version}</version>
+          <type>pom</type>
+          <scope>provided</scope>
+        </dependency>
+       
          <dependency>
             <groupId>org.jboss.seam.persistence</groupId>
             <artifactId>seam-persistence</artifactId>



More information about the seam-commits mailing list