Search in sources :

Example 1 with EJBLocalObject

use of javax.ejb.EJBLocalObject in project Payara by payara.

the class SafeProperties method instantiateEJBLocalObjectImpl.

protected EJBLocalObjectImpl instantiateEJBLocalObjectImpl(Object key) throws Exception {
    EJBLocalObjectImpl localObjImpl = null;
    EJBLocalObjectInvocationHandler handler = new EJBLocalObjectInvocationHandler(proxyInvocationInfoMap, localIntf);
    localObjImpl = handler;
    try {
        EJBLocalObject localObjectProxy = (EJBLocalObject) ejbLocalObjectProxyCtor.newInstance(new Object[] { handler });
        handler.setProxy(localObjectProxy);
    } catch (ClassCastException e) {
        String msg = localStrings.getLocalString("ejb.basecontainer_invalid_local_interface", "Local component interface [{0}] is invalid since it does not extend javax.ejb.EJBLocalObject.", localIntf);
        throw new IllegalArgumentException(msg, e);
    }
    localObjImpl.setContainer(this);
    if (key != null) {
        // associate the EJBObject with the key
        localObjImpl.setKey(key);
    }
    return localObjImpl;
}
Also used : EJBLocalObject(javax.ejb.EJBLocalObject) EJBObject(javax.ejb.EJBObject) EJBLocalObject(javax.ejb.EJBLocalObject)

Example 2 with EJBLocalObject

use of javax.ejb.EJBLocalObject in project tomee by apache.

the class BaseSessionContext method getEJBLocalObject.

public EJBLocalObject getEJBLocalObject() throws IllegalStateException {
    doCheck(Call.getEJBLocalObject);
    final ThreadContext threadContext = ThreadContext.getThreadContext();
    final BeanContext di = threadContext.getBeanContext();
    if (di.getLocalHomeInterface() == null) {
        throw new IllegalStateException("Bean does not have an EJBLocalObject interface: " + di.getDeploymentID());
    }
    return (EJBLocalObject) EjbObjectProxyHandler.createProxy(di, threadContext.getPrimaryKey(), InterfaceType.EJB_LOCAL, di.getLocalInterface());
}
Also used : BeanContext(org.apache.openejb.BeanContext) EJBLocalObject(javax.ejb.EJBLocalObject)

Example 3 with EJBLocalObject

use of javax.ejb.EJBLocalObject in project tomee by apache.

the class Cmp2Util method getEjbProxy.

public static <Proxy extends EJBLocalObject> Proxy getEjbProxy(final BeanContext beanContext, final EntityBean entity) {
    if (entity == null) {
        return null;
    }
    // build the primary key
    final Object primaryKey = getPrimaryKey(beanContext, entity);
    // get the cmp container
    if (!(beanContext.getContainer() instanceof CmpContainer)) {
        throw new IllegalArgumentException("Proxy is not connected to a CMP container but is conect to " + beanContext.getContainer().getClass().getName());
    }
    final Proxy proxy = (Proxy) EjbObjectProxyHandler.createProxy(beanContext, primaryKey, InterfaceType.EJB_LOCAL_HOME, beanContext.getLocalInterface());
    return proxy;
}
Also used : CmpContainer(org.apache.openejb.core.cmp.CmpContainer) EJBObject(javax.ejb.EJBObject) EJBLocalObject(javax.ejb.EJBLocalObject)

Example 4 with EJBLocalObject

use of javax.ejb.EJBLocalObject in project tomee by apache.

the class EntityContext method getEJBLocalObject.

public EJBLocalObject getEJBLocalObject() throws IllegalStateException {
    doCheck(Call.getEJBLocalObject);
    final ThreadContext threadContext = ThreadContext.getThreadContext();
    final BeanContext di = threadContext.getBeanContext();
    if (di.getLocalInterface() == null) {
        throw new IllegalStateException("EJB " + di.getDeploymentID() + " does not have a local interface");
    }
    final EjbObjectProxyHandler handler = new EntityEjbObjectHandler(di, threadContext.getPrimaryKey(), InterfaceType.EJB_LOCAL, new ArrayList<>(), di.getLocalInterface());
    try {
        final Class[] interfaces = new Class[] { di.getLocalInterface(), IntraVmProxy.class };
        return (EJBLocalObject) ProxyManager.newProxyInstance(interfaces, handler);
    } catch (final IllegalAccessException iae) {
        throw new InternalErrorException("Could not create IVM proxy for " + di.getLocalInterface() + " interface", iae);
    }
}
Also used : BeanContext(org.apache.openejb.BeanContext) ThreadContext(org.apache.openejb.core.ThreadContext) InternalErrorException(org.apache.openejb.InternalErrorException) IntraVmProxy(org.apache.openejb.core.ivm.IntraVmProxy) EJBLocalObject(javax.ejb.EJBLocalObject) EjbObjectProxyHandler(org.apache.openejb.core.ivm.EjbObjectProxyHandler)

Example 5 with EJBLocalObject

use of javax.ejb.EJBLocalObject in project Payara by payara.

the class EJBHashSet method contains.

/**
 * Returns <tt>true</tt> if this set contains the specified element.
 *
 * @param o element whose presence in this set is to be tested.
 * @return <tt>true</tt> if this set contains the specified element.
 */
public boolean contains(Object o) {
    // NOI18N
    logger.finest("---EJBHashSet.contains---");
    assertIsValid();
    assertInTransaction();
    helper.assertInstanceOfLocalInterfaceImpl(o);
    EJBLocalObject lo = (EJBLocalObject) o;
    return pcSet.contains(helper.convertEJBLocalObjectToPC(lo, pm, true));
}
Also used : EJBLocalObject(javax.ejb.EJBLocalObject)

Aggregations

EJBLocalObject (javax.ejb.EJBLocalObject)17 EJBObject (javax.ejb.EJBObject)6 EJBException (javax.ejb.EJBException)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 EntityBean (javax.ejb.EntityBean)2 BeanContext (org.apache.openejb.BeanContext)2 EjbContainerUtil (com.sun.ejb.containers.EjbContainerUtil)1 Method (java.lang.reflect.Method)1 Collection (java.util.Collection)1 HashSet (java.util.HashSet)1 List (java.util.List)1 CreateException (javax.ejb.CreateException)1 FinderException (javax.ejb.FinderException)1 RemoveException (javax.ejb.RemoveException)1 NamingException (javax.naming.NamingException)1 EntityManager (javax.persistence.EntityManager)1 Query (javax.persistence.Query)1 InternalErrorException (org.apache.openejb.InternalErrorException)1 ThreadContext (org.apache.openejb.core.ThreadContext)1 CmpContainer (org.apache.openejb.core.cmp.CmpContainer)1