Package javax.ejb

Examples of javax.ejb.EntityBean


            EjbInvocation ejbInv = null;
            try {
                // Create new bean. The constructor is not allowed
                // to do a JNDI access (see EJB2.0 section 10.5.5),
                // so no need to call invocationMgr before instantiation.
                EntityBean ejb = (EntityBean) ejbClass.newInstance();
               
                // create EntityContext
                entityCtx = createEntityContextInstance(ejb, entityContainer);

                ejbInv = entityContainer.createEjbInvocation(ejb, entityCtx);
                invocationManager.preInvoke(ejbInv);
               
                // setEntityContext may be called with or without a Tx
                // spec 9.4.2
                ejb.setEntityContext(entityCtx);

                // NOTE : Annotations are *not* supported for entity beans
                // so we do not invoke the injection manager for this instance.

            } catch (Exception ex ) {
View Full Code Here


                //So no need to anything, as we cannot call unsetEntityCtx etc..
                return;
            }
           
            EntityContextImpl context = (EntityContextImpl) object;
            EntityBean ejb = (EntityBean)context.getEJB();
            if (!context.isInState(BeanState.DESTROYED)) {
                EjbInvocation ci = entityContainer.createEjbInvocation(ejb, context);
                invocationManager.preInvoke(ci);
               
                // kill the bean and let it be GC'ed
                try {
                    synchronized ( context ) {
                        containerStateManager.clearContext(context);
                        context.setState(BeanState.DESTROYED);
                        //context.cacheEntry = null;
                        context.setInUnsetEntityContext(true);
                       
                        try {
                            ejb.unsetEntityContext();
                        } catch ( Exception ex ) {
                            _logger.log(Level.FINE,
                                "Exception in ejb.unsetEntityContext()", ex);
                        }
                       
View Full Code Here

            // progress for this ejbObject, they will be serialized along with
            // this remove by the database. So we optimistically do ejbRemove.
           
            // call ejbRemove on the EJB
            // the EJB is allowed to veto the remove by throwing RemoveException
            EntityBean ejb = (EntityBean)inv.ejb;
            EntityContextImpl context = (EntityContextImpl)inv.context;
            callEJBRemove(ejb, context);
           
            // inv.ejbObject could be a EJBObject or a EJBLocalObject
            Object primaryKey = getInvocationKey(inv);
View Full Code Here

                addIncompleteTxEJB(context);
            }
           
            // need to call ejbLoad since there can be more than
            // one active EJB instance per primaryKey. (Option B in 9.11.5).
            EntityBean e = (EntityBean)context.getEJB();
            try {
                callEJBLoad(e, context, true);
            } catch ( NoSuchEntityException ex ) {
                _logger.log(Level.FINE, "Exception in afterBegin()", ex);
                // Error during ejbLoad, so discard bean: EJB2.0 18.3.3
View Full Code Here

    }
   
   
    // Called from beforeCompletion and preFind
    private void enlistResourcesAndStore(EntityContextImpl context) {
        EntityBean e = (EntityBean)context.getEJB();
        // NOTE : Use EjbInvocation instead of ComponentInvocation since
        // the context is available.  It is needed in case ejbStore/ejbLoad
        // makes use of EJB timer service in order to perform operations allowed
        // checks
        EjbInvocation inv = super.createEjbInvocation(e, context);
View Full Code Here

        }
       
        if ( context.isNewlyActivated() &&
            !inv.invocationInfo.isCreateHomeFinder ) {
            // follow EJB2.0 section 12.1.6.1
            EntityBean e = (EntityBean)context.getEJB();
            try {
                callEJBLoad(e, context, false);
            } catch ( NoSuchEntityException ex ) {
                // Error during ejbLoad, so discard bean: EJB2.0 18.3.3
                forceDestroyBean(context);
View Full Code Here

       
        if(_logger.isLoggable(Level.FINEST)) {
            _logger.log(Level.FINEST,"EntityContainer.passivateEJB(): context = (" +
                ctx + ")");
        }
        EntityBean ejb = (EntityBean)context.getEJB();
       
        EjbInvocation inv = super.createEjbInvocation(ejb, context);
        inv.method = ejbPassivateMethod;
       
        Object pkey = context.getPrimaryKey();
        boolean wasPassivated = false;
       
        // check state after locking ctx
        if ( !context.isInState(BeanState.READY) )
            return false;
        try {
            invocationManager.preInvoke(inv);
           
            // remove EJB from readyStore
            removeContextFromReadyStore(pkey, context);
           
            // no Tx needed for ejbPassivate
            ejb.ejbPassivate();
           
            wasPassivated = true;
        } catch ( Exception ex ) {
            _logger.log(Level.FINE, "Exception in passivateEJB()", ex);
            // Error during ejbStore/Passivate, discard bean: EJB2.0 18.3.3
View Full Code Here

       
        // if ( context.isPooled() ) {
        // context.isPooled(false);
        // return;
        // }
        EntityBean ejb = (EntityBean) context.getEJB();
        synchronized ( context ) {
            EjbInvocation inv = super.createEjbInvocation(ejb, context);
            inv.method = ejbPassivateMethod;
            invocationManager.preInvoke(inv);
           
            try {
                ejb.ejbPassivate();
            } catch ( Exception ex ) {
                _logger.log(Level.FINE,"Exception in passivateAndPoolEJB()",ex);
                forceDestroyBean(context);
                return;
            } finally {
View Full Code Here

            }
        }
       
        context.setState(BeanState.READY);
       
        EntityBean ejb = (EntityBean)context.getEJB();
       
        EjbInvocation inv2 = super.createEjbInvocation(ejb, context);
        inv2.method = ejbActivateMethod;
        invocationManager.preInvoke(inv2);
       
        try {
            ejb.ejbActivate();
           
            // Note: ejbLoad will be called during preInvokeTx
            // since this EJB instance is being associated with
            // a Tx for the first time.
           
View Full Code Here

    }

    private EntityBean createNewInstance(ThreadContext callContext) {
        CoreDeploymentInfo deploymentInfo = callContext.getDeploymentInfo();
        try {
            EntityBean bean = (EntityBean) deploymentInfo.getCmpImplClass().newInstance();
            return bean;
        } catch (Exception e) {
            throw new EJBException("Unable to create new entity bean instance " + deploymentInfo.getCmpImplClass(), e);
        }
    }
View Full Code Here

TOP

Related Classes of javax.ejb.EntityBean

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.