Search in sources :

Example 26 with BeanContext

use of org.apache.openejb.BeanContext in project tomee by apache.

the class BaseContext method getEJBLocalHome.

public EJBLocalHome getEJBLocalHome() {
    final ThreadContext threadContext = ThreadContext.getThreadContext();
    final BeanContext di = threadContext.getBeanContext();
    return di.getEJBLocalHome();
}
Also used : BeanContext(org.apache.openejb.BeanContext)

Example 27 with BeanContext

use of org.apache.openejb.BeanContext in project tomee by apache.

the class BaseContext method getRollbackOnly.

public boolean getRollbackOnly() throws IllegalStateException {
    doCheck(Call.getRollbackOnly);
    final ThreadContext threadContext = ThreadContext.getThreadContext();
    final BeanContext di = threadContext.getBeanContext();
    if (di.isBeanManagedTransaction()) {
        throw new IllegalStateException("bean-managed transaction beans can not access the getRollbackOnly() method: deploymentId=" + di.getDeploymentID());
    }
    final TransactionPolicy txPolicy = threadContext.getTransactionPolicy();
    if (txPolicy == null) {
        throw new IllegalStateException("ThreadContext does not contain a TransactionEnvironment");
    }
    if (txPolicy.getTransactionType() == TransactionType.Never || txPolicy.getTransactionType() == TransactionType.NotSupported || txPolicy.getTransactionType() == TransactionType.Supports) {
        throw new IllegalStateException("getRollbackOnly accessible only from MANDATORY, REQUIRED, or REQUIRES_NEW");
    }
    return txPolicy.isRollbackOnly();
}
Also used : BeanContext(org.apache.openejb.BeanContext) TransactionPolicy(org.apache.openejb.core.transaction.TransactionPolicy)

Example 28 with BeanContext

use of org.apache.openejb.BeanContext in project tomee by apache.

the class BaseContext method getUserTransaction.

public UserTransaction getUserTransaction(final UserTransaction userTransaction) throws IllegalStateException {
    final ThreadContext threadContext = ThreadContext.getThreadContext();
    final BeanContext di = threadContext.getBeanContext();
    if (di.isBeanManagedTransaction()) {
        return userTransaction;
    } else {
        throw new IllegalStateException("container-managed transaction beans can not access the UserTransaction");
    }
}
Also used : BeanContext(org.apache.openejb.BeanContext)

Example 29 with BeanContext

use of org.apache.openejb.BeanContext in project tomee by apache.

the class EjbSelect method execute_byte.

public static byte execute_byte(final Object obj, final String methodSignature, final Object... args) throws FinderException {
    final BeanContext beanContext = (BeanContext) obj;
    final Container container = beanContext.getContainer();
    if (!(container instanceof CmpContainer)) {
        throw new FinderException("Deployment is not connected to a CmpContainer " + beanContext.getDeploymentID());
    }
    final CmpContainer cmpContainer = (CmpContainer) container;
    final Number result = (Number) cmpContainer.select(beanContext, methodSignature, "byte", args);
    return result.byteValue();
}
Also used : BeanContext(org.apache.openejb.BeanContext) FinderException(javax.ejb.FinderException) CmpContainer(org.apache.openejb.core.cmp.CmpContainer) Container(org.apache.openejb.Container) CmpContainer(org.apache.openejb.core.cmp.CmpContainer)

Example 30 with BeanContext

use of org.apache.openejb.BeanContext in project tomee by apache.

the class EjbSelect method execute_short.

public static short execute_short(final Object obj, final String methodSignature, final Object... args) throws FinderException {
    final BeanContext beanContext = (BeanContext) obj;
    final Container container = beanContext.getContainer();
    if (!(container instanceof CmpContainer)) {
        throw new FinderException("Deployment is not connected to a CmpContainer " + beanContext.getDeploymentID());
    }
    final CmpContainer cmpContainer = (CmpContainer) container;
    final Number result = (Number) cmpContainer.select(beanContext, methodSignature, "short", args);
    return result.shortValue();
}
Also used : BeanContext(org.apache.openejb.BeanContext) FinderException(javax.ejb.FinderException) CmpContainer(org.apache.openejb.core.cmp.CmpContainer) Container(org.apache.openejb.Container) CmpContainer(org.apache.openejb.core.cmp.CmpContainer)

Aggregations

BeanContext (org.apache.openejb.BeanContext)198 OpenEJBException (org.apache.openejb.OpenEJBException)40 ThreadContext (org.apache.openejb.core.ThreadContext)40 Method (java.lang.reflect.Method)38 ContainerSystem (org.apache.openejb.spi.ContainerSystem)28 ArrayList (java.util.ArrayList)27 AppContext (org.apache.openejb.AppContext)26 TransactionPolicy (org.apache.openejb.core.transaction.TransactionPolicy)26 NamingException (javax.naming.NamingException)24 InterceptorData (org.apache.openejb.core.interceptor.InterceptorData)23 Context (javax.naming.Context)22 ApplicationException (org.apache.openejb.ApplicationException)20 HashMap (java.util.HashMap)19 EJBLocalObject (javax.ejb.EJBLocalObject)18 EJBObject (javax.ejb.EJBObject)18 SystemException (org.apache.openejb.SystemException)18 OpenEJBRuntimeException (org.apache.openejb.OpenEJBRuntimeException)17 ModuleContext (org.apache.openejb.ModuleContext)16 EjbTransactionUtil.createTransactionPolicy (org.apache.openejb.core.transaction.EjbTransactionUtil.createTransactionPolicy)16 FinderException (javax.ejb.FinderException)14