Package org.jboss.as.cmp.component

Examples of org.jboss.as.cmp.component.CmpEntityBeanComponentInstance


* @author John Bailey
*/
public class CmpEntityBeanSynchronizationInterceptor extends EntityBeanSynchronizationInterceptor {
    public Object processInvocation(final InterceptorContext context) throws Exception {
        final CmpEntityBeanComponent component = (CmpEntityBeanComponent) context.getPrivateData(Component.class);
        final CmpEntityBeanComponentInstance instance = (CmpEntityBeanComponentInstance) context.getPrivateData(ComponentInstance.class);
        //we do not synchronize for instances that are not associated with an identity
        if (instance.getPrimaryKey() == null) {
            return context.proceed();
        }
        final CmpEntityBeanContext entityContext = instance.getEjbContext();

        if (!entityContext.isValid()) {
            component.getStoreManager().loadEntity(entityContext);
            entityContext.setValid(true);
        }

        // now it's ready and can be scheduled for the synchronization
        final Transaction transaction = component.getTransactionManager().getTransaction();
        if (TxUtils.isActive(transaction)) {
            entityContext.getTxAssociation().scheduleSync(transaction, instance.getEjbContext());
        }

        return super.processInvocation(context);
    }
View Full Code Here


public class CmpEntityBeanEjbCreateMethodInterceptorFactory extends EntityBeanEjbCreateMethodInterceptorFactory {

    public static final CmpEntityBeanEjbCreateMethodInterceptorFactory INSTANCE = new CmpEntityBeanEjbCreateMethodInterceptorFactory();

    protected Object invokeEjbCreate(final InterceptorContext context, final Method ejbCreate, final EntityBeanComponentInstance instance, final Object[] params) throws Exception {
        final CmpEntityBeanComponentInstance cmpInstance = CmpEntityBeanComponentInstance.class.cast(instance);
        final JDBCEntityPersistenceStore storeManager = cmpInstance.getComponent().getStoreManager();
        storeManager.initEntity(cmpInstance.getEjbContext());
        ejbCreate.invoke(instance.getInstance(), params);
        return storeManager.createEntity(context.getMethod(), context.getParameters(), cmpInstance.getEjbContext());
    }
View Full Code Here

        ejbCreate.invoke(instance.getInstance(), params);
        return storeManager.createEntity(context.getMethod(), context.getParameters(), cmpInstance.getEjbContext());
    }

    protected void invokeEjbPostCreate(final InterceptorContext context, final Method ejbPostCreate, final EntityBeanComponentInstance instance, final Object[] params) throws Exception {
        final CmpEntityBeanComponentInstance cmpInstance = CmpEntityBeanComponentInstance.class.cast(instance);
        final CmpEntityBeanComponent component = cmpInstance.getComponent();
        final JDBCEntityPersistenceStore storeManager = component.getStoreManager();
        storeManager.postCreateEntity(context.getMethod(), context.getParameters(), cmpInstance.getEjbContext());
        ejbPostCreate.invoke(instance.getInstance(), params);

        if (storeManager.getCmpConfig().isInsertAfterEjbPostCreate()) {
            storeManager.createEntity(context.getMethod(), context.getParameters(), cmpInstance.getEjbContext());
        } else {
            // Invoke store after post create
            cmpInstance.store();
        }

        final Transaction transaction = component.getTransactionManager().getTransaction();
        if (TxUtils.isActive(transaction)) {
            TransactionEntityMap.NONE.scheduleSync(transaction, cmpInstance.getEjbContext());
        }
    }
View Full Code Here

        CMRMessage relationshipMessage = context.getPrivateData(CMRMessage.class);
        if (relationshipMessage == null) {
            // Not a relationship message. Invoke down the chain
            return context.proceed();
        }
        final CmpEntityBeanComponentInstance instance = (CmpEntityBeanComponentInstance) context.getPrivateData(ComponentInstance.class);
        final CmpEntityBeanContext ctx = instance.getEjbContext();

        // We are going to work with the context a lot
        JDBCCMRFieldBridge cmrField = (JDBCCMRFieldBridge) context.getParameters()[0];

        if (CMRMessage.GET_RELATED_ID == relationshipMessage) {
View Full Code Here

        this.localHome = localHome;
    }


    protected Object invokeFind(final InterceptorContext context, final EntityBeanComponentInstance instance) throws Exception {
        final CmpEntityBeanComponentInstance cmpInstance = CmpEntityBeanComponentInstance.class.cast(instance);
        final CmpEntityBeanComponent cmpComponent = cmpInstance.getComponent();
        try {
            cmpComponent.getComponentClass().getDeclaredMethod(finderMethod.getName(), finderMethod.getParameterTypes());
            return super.invokeFind(context, instance);
        } 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());
        }
View Full Code Here

        this.localHome = localHome;
    }


    protected Object invokeFind(final InterceptorContext context, final EntityBeanComponentInstance instance) throws Exception {
        final CmpEntityBeanComponentInstance cmpInstance = CmpEntityBeanComponentInstance.class.cast(instance);
        final CmpEntityBeanComponent cmpComponent = cmpInstance.getComponent();
        try {
            cmpComponent.getComponentClass().getDeclaredMethod(finderMethod.getName(), finderMethod.getParameterTypes());
            return super.invokeFind(context, instance);
        } 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());
        }
View Full Code Here

        super(ejbRemove);
    }

    protected void afterRemove(final EntityBeanComponentInstance instance) throws RemoveException, RemoteException {
        // Invoke CMP remove
        final CmpEntityBeanComponentInstance cmpInstance = CmpEntityBeanComponentInstance.class.cast(instance);
        cmpInstance.getComponent().getStoreManager().removeEntity(cmpInstance.getEjbContext());
        super.afterRemove(instance);
    }
View Full Code Here

public class CmpEntityBeanEjbCreateMethodInterceptorFactory extends EntityBeanEjbCreateMethodInterceptorFactory {

    public static final CmpEntityBeanEjbCreateMethodInterceptorFactory INSTANCE = new CmpEntityBeanEjbCreateMethodInterceptorFactory();

    protected Object invokeEjbCreate(final InterceptorContext context, final Method ejbCreate, final EntityBeanComponentInstance instance, final Object[] params) throws Exception {
        final CmpEntityBeanComponentInstance cmpInstance = CmpEntityBeanComponentInstance.class.cast(instance);
        final JDBCEntityPersistenceStore storeManager = cmpInstance.getComponent().getStoreManager();
        storeManager.initEntity(cmpInstance.getEjbContext());
        ejbCreate.invoke(instance.getInstance(), params);
        return storeManager.createEntity(context.getMethod(), context.getParameters(), cmpInstance.getEjbContext());
    }
View Full Code Here

        ejbCreate.invoke(instance.getInstance(), params);
        return storeManager.createEntity(context.getMethod(), context.getParameters(), cmpInstance.getEjbContext());
    }

    protected void invokeEjbPostCreate(final InterceptorContext context, final Method ejbPostCreate, final EntityBeanComponentInstance instance, final Object[] params) throws Exception {
        final CmpEntityBeanComponentInstance cmpInstance = CmpEntityBeanComponentInstance.class.cast(instance);
        final CmpEntityBeanComponent component = cmpInstance.getComponent();
        final JDBCEntityPersistenceStore storeManager = component.getStoreManager();
        storeManager.postCreateEntity(context.getMethod(), context.getParameters(), cmpInstance.getEjbContext());
        ejbPostCreate.invoke(instance.getInstance(), params);

        if (storeManager.getCmpConfig().isInsertAfterEjbPostCreate()) {
            storeManager.createEntity(context.getMethod(), context.getParameters(), cmpInstance.getEjbContext());
        }

        final Transaction transaction = component.getTransactionManager().getTransaction();
        if (TxUtils.isActive(transaction)) {
            TransactionEntityMap.NONE.scheduleSync(transaction, cmpInstance.getEjbContext());
        }
    }
View Full Code Here

        CMRMessage relationshipMessage = context.getPrivateData(CMRMessage.class);
        if (relationshipMessage == null) {
            // Not a relationship message. Invoke down the chain
            return context.proceed();
        }
        final CmpEntityBeanComponentInstance instance = (CmpEntityBeanComponentInstance) context.getPrivateData(ComponentInstance.class);
        final CmpEntityBeanContext ctx = instance.getEjbContext();

        // We are going to work with the context a lot
        JDBCCMRFieldBridge cmrField = (JDBCCMRFieldBridge) context.getParameters()[0];

        if (CMRMessage.GET_RELATED_ID == relationshipMessage) {
View Full Code Here

TOP

Related Classes of org.jboss.as.cmp.component.CmpEntityBeanComponentInstance

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.