1 package org.openejb.core.stateful; 2 3 import javax.ejb.EnterpriseBean ; 4 5 import org.openejb.ApplicationException; 6 import org.openejb.InvalidateReferenceException; 7 import org.openejb.core.transaction.TransactionContext; 8 import org.openejb.core.transaction.TransactionPolicy; 9 10 23 public class StatefulContainerManagedTxPolicy extends org.openejb.core.transaction.TransactionPolicy { 24 25 protected TransactionPolicy policy; 26 27 public StatefulContainerManagedTxPolicy(TransactionPolicy policy){ 28 this.policy = policy; 29 this.container = policy.getContainer(); 30 this.policyType = policy.policyType; 31 if(container instanceof org.openejb.Container && 32 ((org.openejb.Container)container).getContainerType()!=org.openejb.Container.STATEFUL) { 33 throw new IllegalArgumentException (); 34 } 35 } 36 37 public String policyToString() { 38 return policy.policyToString(); 39 } 40 41 public void beforeInvoke(EnterpriseBean instance, TransactionContext context) throws org.openejb.SystemException, org.openejb.ApplicationException{ 42 policy.beforeInvoke( instance, context ); 43 } 44 45 public void afterInvoke(EnterpriseBean instance, TransactionContext context) throws org.openejb.ApplicationException, org.openejb.SystemException{ 46 policy.afterInvoke( instance, context ); 47 } 48 49 public void handleApplicationException( Throwable appException, TransactionContext context) throws ApplicationException{ 50 policy.handleApplicationException( appException, context ); 51 } 52 53 public void handleSystemException( Throwable sysException, EnterpriseBean instance, TransactionContext context) throws org.openejb.ApplicationException, org.openejb.SystemException{ 54 try { 55 policy.handleSystemException( sysException, instance, context ); 56 } catch ( ApplicationException e ){ 57 throw new InvalidateReferenceException( e.getRootCause() ); 58 } 59 } 60 61 } 62 63 | Popular Tags |