Package org.apache.openejb.core

Examples of org.apache.openejb.core.Operation


    protected void passivate() throws SystemException {
        final ThreadContext threadContext = ThreadContext.getThreadContext();
        Hashtable<Object, BeanEntry> stateTable = new Hashtable<Object, BeanEntry>(bulkPassivationSize);

        BeanEntry currentEntry;
        final Operation currentOperation = threadContext.getCurrentOperation();
        final BaseContext.State[] originalAllowedStates = threadContext.setCurrentAllowedStates(StatefulContext.getStates());
        CoreDeploymentInfo deploymentInfo = threadContext.getDeploymentInfo();
        try {
            for (int i = 0; i < bulkPassivationSize; ++i) {
                currentEntry = lruQueue.first();
View Full Code Here


                    throw new SystemException(e);
                } catch (RollbackException e) {
                    throw new ApplicationException(new TransactionRolledbackException(e));
                }
                loadingBean(bean, callContext);
                Operation orginalOperation = callContext.getCurrentOperation();
                callContext.setCurrentOperation(Operation.LOAD);
                try {
                    bean.ejbLoad();
                } catch (NoSuchEntityException e) {
                    throw new InvalidateReferenceException(new NoSuchObjectException("Entity not found: " + primaryKey).initCause(e));
View Full Code Here

            } catch (Exception e) {
                logger.error("Bean instantiation failed for class " + deploymentInfo.getBeanClass(), e);
                throw new SystemException(e);
            }

            Operation currentOp = callContext.getCurrentOperation();
            callContext.setCurrentOperation(Operation.SET_CONTEXT);
            BaseContext.State[] originalStates = callContext.setCurrentAllowedStates(EntityContext.getStates());

            try {
                /*
                * setEntityContext executes in an unspecified transactional context. In this case we choose to
                * allow it to have what every transaction context is current. Better then suspending it
                * unnecessarily.
                *
                * We also chose not to invoke EntityContainer.invoke( ) method, which duplicate the exception handling
                * logic but also attempt to manage the begining and end of a transaction. It its a container managed transaciton
                * we don't want the TransactionScopeHandler commiting the transaction in afterInvoke() which is what it would attempt
                * to do.
                */
                bean.setEntityContext(createEntityContext());
            } catch (Exception e) {
                /*
                * The EJB 1.1 specification does not specify how exceptions thrown by setEntityContext impact the
                * transaction, if there is one.  In this case we choose the least disruptive operation, throwing an
                * application exception and NOT automatically marking the transaciton for rollback.
                */
                logger.error("Bean callback method failed ", e);
                throw new ApplicationException(e);
            } finally {
                callContext.setCurrentOperation(currentOp);
                callContext.setCurrentAllowedStates(originalStates);
            }
        } else {
            reusingBean(bean, callContext);
        }

        if ((callContext.getCurrentOperation() == Operation.BUSINESS) || (callContext.getCurrentOperation() == Operation.REMOVE)) {
            /*
            * When a bean is retrieved from the bean pool to service a client's business method request it must be
            * notified that its about to enter service by invoking its ejbActivate( ) method. A bean instance
            * does not have its ejbActivate() invoked when:
            * 1. Its being retreived to service an ejbCreate()/ejbPostCreate().
            * 2. Its being retrieved to service an ejbFind method.
            * 3. Its being retrieved to service an ejbRemove() method.
            * See section 9.1.4 of the EJB 1.1 specification.
            */
            Operation currentOp = callContext.getCurrentOperation();

            callContext.setCurrentOperation(Operation.ACTIVATE);
            BaseContext.State[] originalStates = callContext.setCurrentAllowedStates(EntityContext.getStates());
            try {
                /*
 
View Full Code Here

                * If the bean has a primary key; And its not being returned following a remove operation;
                * then the bean is being returned to the method ready pool after successfully executing a business method or create
                * method. In this case we need to call the bean instance's ejbPassivate before returning it to the pool per EJB 1.1
                * Section 9.1.
                */
                Operation currentOp = callContext.getCurrentOperation();

                callContext.setCurrentOperation(Operation.PASSIVATE);
                BaseContext.State[] originalStates = callContext.setCurrentAllowedStates(EntityContext.getStates());

                try {
View Full Code Here

    public void freeInstance(ThreadContext callContext, EntityBean bean) throws SystemException {

        discardInstance(callContext, bean);

        Operation currentOp = callContext.getCurrentOperation();
        callContext.setCurrentOperation(Operation.UNSET_CONTEXT);
        BaseContext.State[] originalStates = callContext.setCurrentAllowedStates(EntityContext.getStates());

        try {
            /*
 
View Full Code Here

            callContext = new ThreadContext(callContext.getDeploymentInfo(), callContext.getPrimaryKey());
        } catch (Exception e) {
        }
        sessionSynchronizations.put(callContext.getPrimaryKey(), callContext);

        Operation currentOperation = callContext.getCurrentOperation();
        callContext.setCurrentOperation(Operation.AFTER_BEGIN);
        BaseContext.State[] originalStates = callContext.setCurrentAllowedStates(StatefulContext.getStates());
        try {

            Method afterBegin = SessionSynchronization.class.getMethod("afterBegin");
View Full Code Here

    /**
     * Performs EJB rules when a system exception occurs.
     */
    public static void handleSystemException(final TransactionPolicy txPolicy, final Throwable sysException, final ThreadContext callContext) throws InvalidateReferenceException {
        // Log the system exception or error
        Operation operation = null;
        if (callContext != null) {
            operation = callContext.getCurrentOperation();
        }
        if (operation != null) {
            logger.error("EjbTransactionUtil.handleSystemException: " + sysException.getMessage(), sysException);
View Full Code Here

    private Instance createInstance(final ThreadContext callContext, final BeanContext beanContext) throws ApplicationException {
        try {
            final InstanceContext context = beanContext.newInstance();
            if (context.getBean() instanceof SessionBean) {
                final Operation originalOperation = callContext.getCurrentOperation();
                try {
                    callContext.setCurrentOperation(Operation.CREATE);
                    final InterceptorStack ejbCreate = new InterceptorStack(
                        context.getBean(),
                        beanContext.getCreateMethod(),
View Full Code Here

            }
        }

        final ThreadContext callContext = ThreadContext.getThreadContext();

        final Operation originalOperation = callContext == null ? null : callContext.getCurrentOperation();
        final BaseContext.State[] originalAllowedStates = callContext == null ? null : callContext.getCurrentAllowedStates();

        try {
            // call post destroy method
            if (callContext != null) {
View Full Code Here

        this.flushable = flushable;
    }

    @Override
    public void check(final Call call) {
        final Operation operation = ThreadContext.getThreadContext().getCurrentOperation();

        switch (call) {
            case getEJBLocalObject:
            case getEJBObject:
            case getBusinessObject:
View Full Code Here

TOP

Related Classes of org.apache.openejb.core.Operation

Copyright © 2018 www.massapicom. 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.