Search in sources :

Example 11 with EJBObject

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

the class StatefulPojoHandleTests method test01_getEJBObject.

// =================================
// Test handle methods
// 
public void test01_getEJBObject() {
    try {
        final EJBObject object = ejbHandle.getEJBObject();
        assertNotNull("The EJBObject is null", object);
        assertTrue("EJBObjects are not identical", object.isIdentical(ejbObject));
    } catch (final Exception e) {
        fail("Received Exception " + e.getClass() + " : " + e.getMessage());
    }
}
Also used : EJBObject(javax.ejb.EJBObject) NoSuchObjectException(java.rmi.NoSuchObjectException)

Example 12 with EJBObject

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

the class StatefulPojoHandleTests method setUp.

protected void setUp() throws Exception {
    super.setUp();
    final Object obj = initialContext.lookup("client/tests/stateful/BasicStatefulPojoHome");
    ejbHome = (BasicStatefulHome) obj;
    ejbObject = ejbHome.createObject("StatefulPojoHandleTests Bean");
    ejbHandle = ejbObject.getHandle();
}
Also used : EJBObject(javax.ejb.EJBObject)

Example 13 with EJBObject

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

the class StatefulRmiIiopTests method test40_returnEJBObject.

/*-------------------------------------------------*/
/*  EJBObject                                      */
/*-------------------------------------------------*/
public void test40_returnEJBObject() {
    try {
        final Object obj = initialContext.lookup("client/tests/stateful/EncBean");
        final EncStatefulHome home = (EncStatefulHome) obj;
        assertNotNull("The EJBHome returned from JNDI is null", home);
        final EncStatefulObject expected = home.create("test_40 StatefulBean");
        assertNotNull("The EJBObject created is null", expected);
        final EncStatefulObject actual = (EncStatefulObject) ejbObject.returnEJBObject(expected);
        assertNotNull("The EJBObject returned is null", actual);
        assertTrue("The EJBObejcts are not identical", expected.isIdentical(actual));
    } catch (final Exception e) {
        fail("Received Exception " + e.getClass() + " : " + e.getMessage());
    }
}
Also used : EJBObject(javax.ejb.EJBObject) RemoteException(java.rmi.RemoteException)

Example 14 with EJBObject

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

the class StatelessHandleTests method setUp.

protected void setUp() throws Exception {
    super.setUp();
    final Object obj = initialContext.lookup("client/tests/stateless/BasicStatelessHome");
    ejbHome = (BasicStatelessHome) obj;
    ejbObject = ejbHome.createObject();
    ejbHandle = ejbObject.getHandle();
}
Also used : EJBObject(javax.ejb.EJBObject)

Example 15 with EJBObject

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

the class EntityContext method getEJBObject.

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

Aggregations

EJBObject (javax.ejb.EJBObject)109 RemoteException (java.rmi.RemoteException)46 Handle (javax.ejb.Handle)28 EJBLocalObject (javax.ejb.EJBLocalObject)12 ObjectGraph (org.apache.openejb.test.object.ObjectGraph)12 EJBException (javax.ejb.EJBException)11 RemoveException (javax.ejb.RemoveException)9 SystemException (javax.transaction.SystemException)9 CreateException (javax.ejb.CreateException)8 NoSuchObjectLocalException (javax.ejb.NoSuchObjectLocalException)8 EncCmpObject (org.apache.openejb.test.entity.cmp.EncCmpObject)7 RmiIiopCmpObject (org.apache.openejb.test.entity.cmp.RmiIiopCmpObject)7 InvocationTargetException (java.lang.reflect.InvocationTargetException)6 MarshalledObject (java.rmi.MarshalledObject)6 FinderException (javax.ejb.FinderException)6 EncCmpHome (org.apache.openejb.test.entity.cmp.EncCmpHome)6 Test (org.junit.Test)5 NoSuchObjectException (java.rmi.NoSuchObjectException)4 ByteArrayInputStream (java.io.ByteArrayInputStream)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3