dain        2004/04/13 16:18:49

  Modified:    modules/core/src/java/org/openejb/transaction
                        BeanPolicy.java
                        UncommittedTransactionException.java
  Log:

  Added support for ejb-ref and ejb-local-ref
  Change EJBProxyFactory to only need a ProxyInfo to construct proxies
  Added a hack version of Stateful BMT policy (does not handle holding a tx
  open between calls)
  
  Revision  Changes    Path
  1.3       +39 -2     
openejb/modules/core/src/java/org/openejb/transaction/BeanPolicy.java
  
  Index: BeanPolicy.java
  ===================================================================
  RCS file: 
/home/projects/openejb/scm/openejb/modules/core/src/java/org/openejb/transaction/BeanPolicy.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- BeanPolicy.java   3 Apr 2004 22:20:11 -0000       1.2
  +++ BeanPolicy.java   13 Apr 2004 20:18:49 -0000      1.3
  @@ -114,7 +114,44 @@
   
       public static final TransactionPolicy Stateful = new TransactionPolicy() {
           public InvocationResult invoke(Interceptor interceptor, EJBInvocation 
ejbInvocation, TransactionManager txnManager) throws Throwable {
  -            throw new IllegalStateException("Not yet implemented");
  +            TransactionContext clientContext = TransactionContext.getContext();
  +            if (clientContext != null) {
  +                clientContext.suspend();
  +            }
  +            try {
  +                TransactionContext beanContext = new 
UnspecifiedTransactionContext();
  +                TransactionContext.setContext(beanContext);
  +                beanContext.begin();
  +                ejbInvocation.setTransactionContext(beanContext);
  +                try {
  +                    InvocationResult result = interceptor.invoke(ejbInvocation);
  +                    if (beanContext != TransactionContext.getContext()) {
  +                        throw new UncommittedTransactionException("Support for 
transactions held between invocations is not supported");
  +                    }
  +                    beanContext.commit();
  +                    return result;
  +                } catch (Throwable t) {
  +                    try {
  +                        if (beanContext != TransactionContext.getContext()) {
  +                            TransactionContext.getContext().rollback();
  +                        }
  +                    } catch (Exception e) {
  +                        log.warn("Unable to roll back", e);
  +                    }
  +                    try {
  +                        beanContext.rollback();
  +                    } catch (Exception e) {
  +                        log.warn("Unable to roll back", e);
  +                    }
  +                    throw t;
  +                }
  +            } finally {
  +                ejbInvocation.setTransactionContext(clientContext);
  +                TransactionContext.setContext(clientContext);
  +                if (clientContext != null) {
  +                    clientContext.resume();
  +                }
  +            }
           }
           private Object readResolve() {
               return Stateful;
  
  
  
  1.2       +15 -1     
openejb/modules/core/src/java/org/openejb/transaction/UncommittedTransactionException.java
  
  Index: UncommittedTransactionException.java
  ===================================================================
  RCS file: 
/home/projects/openejb/scm/openejb/modules/core/src/java/org/openejb/transaction/UncommittedTransactionException.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- UncommittedTransactionException.java      1 Mar 2004 07:14:43 -0000       1.1
  +++ UncommittedTransactionException.java      13 Apr 2004 20:18:49 -0000      1.2
  @@ -53,4 +53,18 @@
    * @version $Revision$ $Date$
    */
   public class UncommittedTransactionException extends Exception {
  +    public UncommittedTransactionException() {
  +    }
  +
  +    public UncommittedTransactionException(String message) {
  +        super(message);
  +    }
  +
  +    public UncommittedTransactionException(String message, Throwable cause) {
  +        super(message, cause);
  +    }
  +
  +    public UncommittedTransactionException(Throwable cause) {
  +        super(cause);
  +    }
   }
  
  
  

Reply via email to