[jboss-cvs] jboss-seam/src/main/org/jboss/seam/annotations ...

Gavin King gavin.king at jboss.com
Sat Dec 16 05:03:45 EST 2006


  User: gavin   
  Date: 06/12/16 05:03:45

  Modified:    src/main/org/jboss/seam/annotations   Transactional.java
  Added:       src/main/org/jboss/seam/annotations  
                        TransactionPropagationType.java
  Log:
  JBSEAM-595
  
  Revision  Changes    Path
  1.3       +11 -7     jboss-seam/src/main/org/jboss/seam/annotations/Transactional.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: Transactional.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/annotations/Transactional.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -b -r1.2 -r1.3
  --- Transactional.java	24 Apr 2006 00:24:21 -0000	1.2
  +++ Transactional.java	16 Dec 2006 10:03:45 -0000	1.3
  @@ -1,7 +1,7 @@
   package org.jboss.seam.annotations;
   
  -import static java.lang.annotation.ElementType.TYPE;
   import static java.lang.annotation.ElementType.METHOD;
  +import static java.lang.annotation.ElementType.TYPE;
   import static java.lang.annotation.RetentionPolicy.RUNTIME;
   
   import java.lang.annotation.Documented;
  @@ -10,11 +10,10 @@
   import java.lang.annotation.Target;
   
   /**
  - * Specifies that the default behavior for an EJB session bean,
  - * @TransactionAttribute(REQUIRED), should apply to a JavaBean
  - * component or method of a JavaBean component. (JavaBean 
  - * components have @TransactionAttribute(SUPPORTS) behavior 
  - * otherwise.)
  + * Specifies that the transaction propagation for a JavaBean
  + * component or method of a JavaBean component. JavaBean 
  + * components have @Transactional(SUPPORTS) behavior 
  + * is no @Transactional annotation is specified.
    * 
    * @author Gavin King
    */
  @@ -24,5 +23,10 @@
   @Inherited
   public @interface Transactional
   {
  -
  +   /**
  +    * The transaction propagation type.
  +    * 
  +    * @return REQUIRED by default
  +    */
  +   TransactionPropagationType value() default TransactionPropagationType.REQUIRED;
   }
  
  
  
  1.1      date: 2006/12/16 10:03:45;  author: gavin;  state: Exp;jboss-seam/src/main/org/jboss/seam/annotations/TransactionPropagationType.java
  
  Index: TransactionPropagationType.java
  ===================================================================
  package org.jboss.seam.annotations;
  
  /**
   * Transaction propagation strategies for Seam JavaBean 
   * components. Note that unlike EJB3 components, there 
   * are no strategies for suspending transactions.
   * 
   * @author Gavin King
   *
   */
  public enum TransactionPropagationType
  {
     REQUIRED,
     MANDATORY, 
     SUPPORTS,
     NEVER;
     
     public boolean isNewTransactionRequired(boolean transactionActive)
     {
        try
        {
           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");
                 }
              case NEVER:
                 if ( transactionActive )
                 {
                    throw new IllegalStateException("Transaction active on call to NEVER method");
                 }
              default:
                 throw new IllegalArgumentException();
           }
        }
        catch (Exception e)
        {
           throw new RuntimeException(e);
        }
     }
     
  }
  
  
  



More information about the jboss-cvs-commits mailing list