1 17 18 package org.objectweb.jac.aspects.distrans; 19 20 21 22 import javax.transaction.NotSupportedException ; 23 import javax.transaction.SystemException ; 24 import javax.transaction.UserTransaction ; 25 import org.aopalliance.intercept.ConstructorInvocation; 26 import org.aopalliance.intercept.MethodInvocation; 27 import org.objectweb.jac.core.AspectComponent; 28 import org.objectweb.jac.core.Interaction; 29 import org.objectweb.jac.core.Wrapper; 30 import org.objectweb.jac.util.Log; 31 32 38 public class BeginTransactionWrapper extends Wrapper { 39 40 41 private UserTransaction usertx; 42 43 46 public BeginTransactionWrapper(AspectComponent ac) { 47 super(ac); 48 usertx = JOTMHelper.get().getUserTransaction(); 49 } 50 51 public Object invoke(MethodInvocation invocation) throws Throwable { 52 Interaction interaction = (Interaction) invocation; 53 try { 54 return _begin(interaction); 55 } catch (Exception e) { 56 Log.error("Error while beginning transaction"); 57 e.printStackTrace(); 58 } 59 return null; 60 } 61 62 private Object _begin(Interaction interaction) 63 throws NotSupportedException , SystemException { 64 65 usertx.begin(); 66 67 return proceed(interaction); 68 } 69 70 public Object construct(ConstructorInvocation invocation) 71 throws Throwable { 72 throw new Exception ("This wrapper does not support constructor wrapping"); 73 } 74 } 75 | Popular Tags |