Examples of SessionSynchronizationListener


Examples of org.ow2.easybeans.transaction.SessionSynchronizationListener

         * is being committed.
         */

        // TODO: THE COMPLETED information should be retrieved on the bean
        // context, not on the session listener.
        SessionSynchronizationListener sessionSynchronizationListener = this.listeners.get(bean);
        if (sessionSynchronizationListener == null) {
            sessionSynchronizationListener =  new SessionSynchronizationListener(bean, invocationContext.getFactory());
            this.listeners.put(bean, sessionSynchronizationListener);
        }

        // add only once until
        if (sessionSynchronizationListener.isReady()) {

            try {
                getTransactionManager().getTransaction().registerSynchronization(sessionSynchronizationListener);
            } catch (IllegalStateException e) {
                throw new EJBException("Cannot register the synchronization", e);
            } catch (RollbackException e) {
                throw new TransactionRolledbackLocalException("Session rolled back");
            } catch (SystemException e) {
                throw new EJBException("Cannot register the synchronization", e);
            }

            // Change state
            OperationState oldState = invocationContext.getFactory().getOperationState();
            invocationContext.getFactory().getOperationStateThreadLocal().set(OperationState.AFTER_BEGIN);

            // Call method
            try {
                bean.afterBegin();
            } catch (EJBException e) {
                throw e;
            } catch (RemoteException e) {
                throw new EJBException("Cannot call afterBegin method", e);
            } finally {
                invocationContext.getFactory().getOperationStateThreadLocal().set(oldState);
            }
            sessionSynchronizationListener.inTX();
        }

    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.