1 25 26 package org.objectweb.easybeans.transaction; 27 28 import java.rmi.RemoteException ; 29 30 import javax.ejb.EJBException ; 31 import javax.ejb.SessionSynchronization ; 32 import javax.transaction.Synchronization ; 33 import static javax.transaction.Status.STATUS_COMMITTED ; 34 35 40 public class SessionSynchronizationListener implements Synchronization { 41 42 45 private SessionSynchronization synchronizedBean; 46 47 51 public SessionSynchronizationListener(final SessionSynchronization synchronizedBean) { 52 this.synchronizedBean = synchronizedBean; 53 } 54 55 65 public void beforeCompletion() { 66 try { 67 synchronizedBean.beforeCompletion(); 68 } catch (EJBException e) { 69 throw e; 70 } catch (RemoteException e) { 71 throw new EJBException ("Error in beforeCompletion()", e); 72 } 73 } 74 75 80 public void afterCompletion(final int status) { 81 try { 82 synchronizedBean.afterCompletion(status == STATUS_COMMITTED); 83 } catch (EJBException e) { 84 throw e; 85 } catch (RemoteException e) { 86 throw new EJBException ("Error in afterCompletion()", e); 87 } finally { 88 ready = true; 89 } 90 91 } 92 93 96 private boolean ready = true; 97 98 99 103 public boolean isReady() { 104 return ready; 105 } 106 107 110 public void inTX() { 111 ready = false; 112 } 113 114 115 116 } 117 | Popular Tags |