Search in sources :

Example 41 with BeanContext

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

the class EjbHomeProxyHandler method createHomeProxy.

public static Object createHomeProxy(final BeanContext beanContext, final InterfaceType interfaceType, final List<Class> objectInterfaces, final Class mainInterface) {
    if (!interfaceType.isHome()) {
        throw new IllegalArgumentException("InterfaceType is not a Home type: " + interfaceType);
    }
    try {
        final EjbHomeProxyHandler handler = createHomeHandler(beanContext, interfaceType, objectInterfaces, mainInterface);
        final List<Class> proxyInterfaces = new ArrayList<>(2);
        final Class homeInterface = beanContext.getInterface(interfaceType);
        proxyInterfaces.add(homeInterface);
        proxyInterfaces.add(IntraVmProxy.class);
        if (BeanType.STATEFUL.equals(beanContext.getComponentType()) || BeanType.MANAGED.equals(beanContext.getComponentType())) {
            proxyInterfaces.add(BeanContext.Removable.class);
        }
        return ProxyManager.newProxyInstance(proxyInterfaces.toArray(new Class[proxyInterfaces.size()]), handler);
    } catch (final Exception e) {
        throw new OpenEJBRuntimeException("Can't create EJBHome stub" + e.getMessage(), e);
    }
}
Also used : OpenEJBRuntimeException(org.apache.openejb.OpenEJBRuntimeException) BeanContext(org.apache.openejb.BeanContext) ArrayList(java.util.ArrayList) AccessException(java.rmi.AccessException) InvalidateReferenceException(org.apache.openejb.InvalidateReferenceException) ApplicationException(org.apache.openejb.ApplicationException) EJBAccessException(javax.ejb.EJBAccessException) OpenEJBException(org.apache.openejb.OpenEJBException) AccessLocalException(javax.ejb.AccessLocalException) RemoteException(java.rmi.RemoteException) EJBException(javax.ejb.EJBException) ObjectStreamException(java.io.ObjectStreamException) SystemException(org.apache.openejb.SystemException) OpenEJBRuntimeException(org.apache.openejb.OpenEJBRuntimeException)

Example 42 with BeanContext

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

the class EjbHomeProxyHandler method homeMethod.

/*-------------------------------------------------*/
/*  Home interface methods                         */
/*-------------------------------------------------*/
protected Object homeMethod(final Class interfce, final Method method, final Object[] args, final Object proxy) throws Throwable {
    checkAuthorization(method);
    final BeanContext beanContext = getBeanContext();
    if (beanContext.isAsynchronous(method)) {
        return beanContext.getModuleContext().getAppContext().getAsynchronousPool().invoke(new CUCallable<Object>(new Callable<Object>() {

            @Override
            public Object call() throws Exception {
                try {
                    return homeMethodInvoke(interfce, method, args);
                } catch (final ApplicationException ae) {
                    logger.error("EjbHomeProxyHandler: Asynchronous call to '" + interfce.getSimpleName() + "' on '" + method.getName() + "' failed", ae);
                    throw ae;
                }
            }
        }), method.getReturnType() == Void.TYPE);
    } else {
        return homeMethodInvoke(interfce, method, args);
    }
}
Also used : BeanContext(org.apache.openejb.BeanContext) ApplicationException(org.apache.openejb.ApplicationException) Callable(java.util.concurrent.Callable) CUCallable(org.apache.openejb.threads.task.CUCallable)

Example 43 with BeanContext

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

the class EjbSelect method execute_void.

/**
 * Perform a select operation when the return value is
 * a void.  This one is slightly different from the
 * rest, as the container operation performed is an
 * update() rather than a select() because there's
 * no value to return.
 *
 * @param obj             The ejb object we're executing on behalf of.
 * @param methodSignature The signature of the selectxxxx method being invoked.
 * @param args            The arguments to the select.  These need to match
 *                        the method signature.
 * @throws FinderException
 */
public static void execute_void(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;
    cmpContainer.update(beanContext, methodSignature, args);
}
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 44 with BeanContext

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

the class EjbSelect method execute_Object.

/**
 * The single execution stub for all non-primitive
 * select operations.  This method has an additional
 * returnType parameter used to instantiate the return
 * value.
 *
 * @param obj             The EJB object we're operating against.
 * @param methodSignature The signature of the ejbSelectxxxx method.
 * @param returnType      The return type signature of the method.
 * @param args            The select arguments.
 * @return An object of the specified type...which might be
 * one of the collection types.
 * @throws FinderException
 */
public static Object execute_Object(final Object obj, final String methodSignature, final String returnType, 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;
    return cmpContainer.select(beanContext, methodSignature, returnType, args);
}
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 45 with BeanContext

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

the class EjbSelect method execute_char.

public static char execute_char(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 Character result = (Character) cmpContainer.select(beanContext, methodSignature, "char", args);
    return result;
}
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