Package org.jboss.as.cmp.context

Examples of org.jboss.as.cmp.context.CmpEntityBeanContext


    public synchronized void store() {
        EntityBean instance = getInstance();
        try {
            if (!isRemoved()) {
                instance.ejbStore();
                final CmpEntityBeanContext context = getEjbContext();
                final JDBCEntityPersistenceStore store = getComponent().getStoreManager();
                if (context.getPrimaryKey() != null && store.isStoreRequired(context)) {
                    store.storeEntity(context);
                }
            }
        } catch (RemoteException e) {
            throw new WrappedRemoteException(e);
View Full Code Here


        } catch (NoSuchMethodException ignored) {
        }

        final JDBCEntityPersistenceStore store = cmpComponent.getStoreManager();

        final CmpEntityBeanContext entityContext = cmpInstance.getEjbContext();

        // as per the spec 9.6.4, entities must be synchronized with the datastore when an ejbFind<METHOD> is called.
        if (!store.getCmpConfig().isSyncOnCommitOnly()) {
            cmpComponent.synchronizeEntitiesWithinTransaction(entityContext.getTransaction());
        }

        final JDBCQueryCommand.EntityProxyFactory factory = new JDBCQueryCommand.EntityProxyFactory() {
            public Object getEntityObject(final Object primaryKey) {
                return localHome ? cmpComponent.getEJBLocalObject(primaryKey) : cmpComponent.getEJBObject(primaryKey);
View Full Code Here

        return (CmpEntityBeanContext) super.getEjbContext();
    }

    public void setupContext() {
        try {
            final CmpEntityBeanContext context = new CmpEntityBeanContext(this);
            setEjbContext(context);
            getInstance().setEntityContext(context);
            getComponent().getStoreManager().activateEntity(context);
        } catch (RemoteException e) {
            throw new WrappedRemoteException(e);
View Full Code Here

        try {
            if (!isRemoved()) {

                invokeEjbStore();

                final CmpEntityBeanContext context = getEjbContext();
                final JDBCEntityPersistenceStore store = getComponent().getStoreManager();
                if (context.getPrimaryKey() != null && store.isStoreRequired(context)) {
                    store.storeEntity(context);
                }
            }
        } catch (RemoteException e) {
            throw new WrappedRemoteException(e);
View Full Code Here

    @Override
    public void setupContext(final InterceptorContext interceptorContext) {
        final InvocationType invocationType = interceptorContext.getPrivateData(InvocationType.class);
        try {
            interceptorContext.putPrivateData(InvocationType.class, InvocationType.SET_ENTITY_CONTEXT);
            final CmpEntityBeanContext context = new CmpEntityBeanContext(this);
            setEjbContext(context);
            getInstance().setEntityContext(context);
            getComponent().getStoreManager().activateEntity(context);
        } catch (RemoteException e) {
            throw new WrappedRemoteException(e);
View Full Code Here

    }

    @Override
    public void reload() {
        try {
            final CmpEntityBeanContext entityContext = getEjbContext();
            getComponent().getStoreManager().loadEntity(entityContext);
            entityContext.setValid(true);
        } catch (RemoteException e) {
            throw new RuntimeException(e);
        }
    }
View Full Code Here

        try {
            if (!isRemoved()) {

                invokeEjbStore();

                final CmpEntityBeanContext context = getEjbContext();
                final JDBCEntityPersistenceStore store = getComponent().getStoreManager();
                if (context.getPrimaryKeyUnchecked() != null && store.isStoreRequired(context)) {
                    store.storeEntity(context);
                }
            }
        } catch (RemoteException e) {
            throw new WrappedRemoteException(e);
View Full Code Here

            synchronizing = true;

            // This is an independent point of entry. We need to make sure the
            // thread is associated with the right context class loader
            Thread currentThread = Thread.currentThread();
            CmpEntityBeanContext context = null;
            try {
                for (CmpEntityBeanContext instance : instances) {
                    // any one can mark the tx rollback at any time so check
                    // before continuing to the next store
                    if (TxUtils.isRollback(tx)) {
                        return;
                    }
                    context = instance;
                    context.getTxAssociation().invokeEjbStore(currentThread, context);
                }

                for (CmpEntityBeanContext instance : instances) {
                    // any one can mark the tx rollback at any time so check
                    // before continuing to the next store
                    if (TxUtils.isRollback(tx)) {
                        return;
                    }
                    context = instance;
                    context.getTxAssociation().synchronize(currentThread, tx, context);
                }
            } catch (Exception causeByException) {
                // EJB 1.1 section 12.3.2 and EJB 2 section 18.3.3
                // exception during store must log exception, mark tx for
                // rollback and throw a TransactionRolledback[Local]Exception
                // if using caller's transaction.  All of this is handled by
                // the AbstractTxInterceptor and LogInterceptor.
                //
                // All we need to do here is mark the transaction for rollback
                // and rethrow the causeByException.  The caller will handle logging
                // and wraping with TransactionRolledback[Local]Exception.
                try {
                    tx.setRollbackOnly();
                } catch (Exception e) {
                    CmpLogger.ROOT_LOGGER.exceptionRollingBackTx(tx, e);
                }

                // Rethrow cause by exception
                if (causeByException instanceof EJBException) {
                    throw (EJBException) causeByException;
                }
                throw CmpMessages.MESSAGES.failedToStoreEntity(((context == null || context.getPrimaryKeyUnchecked() == null) ? "<null>" : context.getPrimaryKeyUnchecked().toString()), causeByException);
            } finally {
                synchronizing = false;
            }
        }
View Full Code Here

    @Override
    public void setupContext(final InterceptorContext interceptorContext) {
        final InvocationType invocationType = interceptorContext.getPrivateData(InvocationType.class);
        try {
            interceptorContext.putPrivateData(InvocationType.class, InvocationType.SET_ENTITY_CONTEXT);
            final CmpEntityBeanContext context = new CmpEntityBeanContext(this);
            setEjbContext(context);
            getInstance().setEntityContext(context);
            getComponent().getStoreManager().activateEntity(context);
        } catch (RemoteException e) {
            throw new WrappedRemoteException(e);
View Full Code Here

    }

    @Override
    public void reload() {
        try {
            final CmpEntityBeanContext entityContext = getEjbContext();
            getComponent().getStoreManager().loadEntity(entityContext);
            entityContext.setValid(true);
        } catch (RemoteException e) {
            throw new RuntimeException(e);
        }
    }
View Full Code Here

TOP

Related Classes of org.jboss.as.cmp.context.CmpEntityBeanContext

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.