1 7 package org.jboss.ejb3.entity; 8 9 import org.jboss.aop.advice.Interceptor; 10 import org.jboss.aop.joinpoint.Invocation; 11 12 import javax.persistence.FlushModeType; 13 import javax.persistence.FlushModeType; 14 15 20 public class BeforeTxFlushModeInterceptor implements Interceptor 21 { 22 23 public String getName() 24 { 25 return BeforeTxFlushModeInterceptor.class.getName(); 26 } 27 28 29 public Object invoke(Invocation invocation) throws Throwable 30 { 31 32 FlushModeType old = (FlushModeType)FlushModeInterceptor.flushMode.get(); 33 try 34 { 35 return invocation.invokeNext(); 36 } 37 finally 38 { 39 FlushModeInterceptor.flushMode.set(old); 40 if (FlushModeInterceptor.txFlushMode.getTransaction() != null) FlushModeInterceptor.txFlushMode.set(old); 41 } 42 } 43 } 44 | Popular Tags |