Search in sources :

Example 1 with EntityContext

use of org.apache.openejb.core.entity.EntityContext in project tomee by apache.

the class CmpContainer method setEntityContext.

private void setEntityContext(final EntityBean entityBean) {
    if (entityBean == null) {
        throw new NullPointerException("entityBean is null");
    }
    // activating entity doen't have a primary key
    final BeanContext beanContext = getBeanContextByClass(entityBean.getClass());
    final ThreadContext callContext = new ThreadContext(beanContext, null);
    callContext.setCurrentOperation(Operation.SET_CONTEXT);
    final ThreadContext oldCallContext = ThreadContext.enter(callContext);
    try {
        entityBean.setEntityContext(new EntityContext(securityService));
    } catch (final RemoteException e) {
        throw new EJBException(e);
    } finally {
        ThreadContext.exit(oldCallContext);
    }
}
Also used : BeanContext(org.apache.openejb.BeanContext) ThreadContext(org.apache.openejb.core.ThreadContext) EntityContext(org.apache.openejb.core.entity.EntityContext) RemoteException(java.rmi.RemoteException) OpenEJBException(org.apache.openejb.OpenEJBException) EJBException(javax.ejb.EJBException)

Example 2 with EntityContext

use of org.apache.openejb.core.entity.EntityContext in project tomee by apache.

the class CmpContainer method deploy.

@Override
public void deploy(final BeanContext beanContext) throws OpenEJBException {
    synchronized (this) {
        final Object deploymentId = beanContext.getDeploymentID();
        cmpEngine.deploy(beanContext);
        beanContext.setContainerData(cmpEngine);
        beanContext.set(EJBContext.class, new EntityContext(securityService));
        // try to set deploymentInfo static field on bean implementation class
        try {
            final Field field = beanContext.getCmpImplClass().getField("deploymentInfo");
            field.set(null, beanContext);
        } catch (final Exception e) {
        // ignore
        }
        // add to indexes
        deploymentsById.put(deploymentId, beanContext);
        beansByClass.put(beanContext.getCmpImplClass(), beanContext);
        beanContext.setContainer(this);
    }
}
Also used : Field(java.lang.reflect.Field) EJBLocalObject(javax.ejb.EJBLocalObject) EJBObject(javax.ejb.EJBObject) EntityContext(org.apache.openejb.core.entity.EntityContext) ObjectNotFoundException(javax.ejb.ObjectNotFoundException) EJBAccessException(javax.ejb.EJBAccessException) RemoveException(javax.ejb.RemoveException) OpenEJBException(org.apache.openejb.OpenEJBException) InvocationTargetException(java.lang.reflect.InvocationTargetException) RemoteException(java.rmi.RemoteException) EJBException(javax.ejb.EJBException) NoSuchObjectException(java.rmi.NoSuchObjectException) EjbTransactionUtil.handleApplicationException(org.apache.openejb.core.transaction.EjbTransactionUtil.handleApplicationException) EjbTransactionUtil.handleSystemException(org.apache.openejb.core.transaction.EjbTransactionUtil.handleSystemException) ApplicationException(org.apache.openejb.ApplicationException) FinderException(javax.ejb.FinderException)

Aggregations

RemoteException (java.rmi.RemoteException)2 EJBException (javax.ejb.EJBException)2 OpenEJBException (org.apache.openejb.OpenEJBException)2 EntityContext (org.apache.openejb.core.entity.EntityContext)2 Field (java.lang.reflect.Field)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 NoSuchObjectException (java.rmi.NoSuchObjectException)1 EJBAccessException (javax.ejb.EJBAccessException)1 EJBLocalObject (javax.ejb.EJBLocalObject)1 EJBObject (javax.ejb.EJBObject)1 FinderException (javax.ejb.FinderException)1 ObjectNotFoundException (javax.ejb.ObjectNotFoundException)1 RemoveException (javax.ejb.RemoveException)1 ApplicationException (org.apache.openejb.ApplicationException)1 BeanContext (org.apache.openejb.BeanContext)1 ThreadContext (org.apache.openejb.core.ThreadContext)1 EjbTransactionUtil.handleApplicationException (org.apache.openejb.core.transaction.EjbTransactionUtil.handleApplicationException)1 EjbTransactionUtil.handleSystemException (org.apache.openejb.core.transaction.EjbTransactionUtil.handleSystemException)1