Examples of EZBSessionContext


Examples of org.ow2.easybeans.api.container.EZBSessionContext

         * context.
         */

        // Get Bean and context
        EasyBeansSFSB statefulBean = (EasyBeansSFSB) invocationContext.getTarget();
        EZBSessionContext sessionContext = (EZBSessionContext) statefulBean.getEasyBeansContext();
        // Get bean transaction (if any)
        Transaction beanTransaction = sessionContext.getBeanTransaction();
        // resume transaction for the call
        if (beanTransaction != null) {
            logger.debug("Resuming bean transaction {0}", beanTransaction);
            try {
                getTransactionManager().resume(beanTransaction);
            } catch (InvalidTransactionException ite) {
                throw new EJBException(
                        "Cannot call resume() on the previous bean transaction. There is an invalid transaction", ite);
            } catch (IllegalStateException ise) {
                throw new EJBException(
                        "Cannot call resume() on the previous bean transaction. There is another associated transaction",
                        ise);
            } catch (SystemException se) {
                throw new EJBException(
                        "Cannot call resume() on the previous bean transaction. Unexpected error condition", se);
            }
        }

        try {
            return invocationContext.proceed();
        } catch (Exception e) {
            handleBeanManagedException(invocationContext, e);
            // Shouldn't come here
            return null;
        } finally {

            /*
             * Saves the current bean transaction if the business method that
             * started a transaction completes without committing or rolling
             * back the transaction.
             */
            Transaction transactionAfter = null;
            try {
                transactionAfter = getTransactionManager().getTransaction();
            } catch (SystemException se) {
                throw new EJBException("Cannot get the current transaction on transaction manager.", se);
            }
            if (transactionAfter != null) {
                int transactionStatus = transactionAfter.getStatus();
                // not yet committed or rollbacked --> save transaction for the next call.
                if (transactionStatus != STATUS_COMMITTED && transactionStatus != STATUS_ROLLEDBACK) {
                    logger.debug("Saving bean transaction {0}", transactionAfter);
                    sessionContext.setBeanTransaction(transactionAfter);
                } else {
                    sessionContext.setBeanTransaction(null);
                }
            } else {
                // In case Transaction has completely disappeared
                sessionContext.setBeanTransaction(null);
            }

            /*
             * The container resumes the suspended association when the business
             * method has completed.
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.