1 25 26 package org.objectweb.easybeans.persistence.interceptors; 27 28 import org.objectweb.easybeans.api.EasyBeansInterceptor; 29 import org.objectweb.easybeans.api.EasyBeansInvocationContext; 30 31 38 public class NoTxMethodCallOnlyEntityManagerInterceptor implements EasyBeansInterceptor { 39 40 47 public Object intercept(final EasyBeansInvocationContext invocationContext) throws Exception { 48 boolean persistentManagerPresent = (invocationContext.getFactory().getContainer().getPersistenceUnitManager() != null); 49 if (persistentManagerPresent) { 50 try { 51 invocationContext.getFactory().getContainer().getPersistenceUnitManager().addCurrent(); 52 return invocationContext.proceed(); 53 } finally { 54 invocationContext.getFactory().getContainer().getPersistenceUnitManager() 55 .closeCurrentAndReturnToPrevious(); 56 } 57 } 58 return invocationContext.proceed(); 60 } 61 62 } 63 | Popular Tags |