Search in sources :

Example 1 with EJBMetaData

use of jakarta.ejb.EJBMetaData in project tomee by apache.

the class CrossClassLoaderProxyTestObject method testRemoteInterface.

public void testRemoteInterface() throws Exception {
    assertNotNull("widgetHome", widgetHome);
    // assertTrue("home should be an instance of WidgetHome", home instanceof CrossClassLoaderProxyTest.WidgetHome);
    // CrossClassLoaderProxyTest.WidgetHome widgetHome = (CrossClassLoaderProxyTest.WidgetHome)home;
    final Object object = widgetHome.create();
    assertNotNull("widgetHome.create()", object);
    assertTrue("object should be an instance of WidgetRemote", object instanceof CrossClassLoaderProxyTest.WidgetRemote);
    final CrossClassLoaderProxyTest.WidgetRemote widget = (CrossClassLoaderProxyTest.WidgetRemote) object;
    // Do a business method...
    final Stack<CrossClassLoaderProxyTest.Lifecycle> lifecycle = widget.getLifecycle();
    assertNotNull("lifecycle", lifecycle);
    assertNotSame("is copy", lifecycle, CrossClassLoaderProxyTest.WidgetBean.lifecycle);
    // Check the lifecycle of the bean
    final List expected = Arrays.asList(CrossClassLoaderProxyTest.Lifecycle.values());
    assertEquals(join("\n", expected), join("\n", lifecycle));
    // verify home ejb meta data
    final EJBMetaData metaData = widgetHome.getEJBMetaData();
    assertTrue("metaData.getEJBHome() should be an instance of WidgetHome", metaData.getEJBHome() instanceof CrossClassLoaderProxyTest.WidgetHome);
    assertEquals(CrossClassLoaderProxyTest.WidgetHome.class, metaData.getHomeInterfaceClass());
    assertEquals(CrossClassLoaderProxyTest.WidgetRemote.class, metaData.getRemoteInterfaceClass());
    // verify home handle
    final HomeHandle homeHandle = widgetHome.getHomeHandle();
    assertTrue("homeHandle.getEJBHome() should be an instance of WidgetHome", homeHandle.getEJBHome() instanceof CrossClassLoaderProxyTest.WidgetHome);
    // verify ejb object getHome
    assertTrue("widget.getEJBHome() should be an instance of WidgetHome", widget.getEJBHome() instanceof CrossClassLoaderProxyTest.WidgetHome);
    // verify ejb object handle
    final Handle objectHandle = widget.getHandle();
    assertTrue("objectHandle.getEJBObject() should be an instance of WidgetHome", objectHandle.getEJBObject() instanceof CrossClassLoaderProxyTest.WidgetRemote);
}
Also used : EJBMetaData(jakarta.ejb.EJBMetaData) HomeHandle(jakarta.ejb.HomeHandle) List(java.util.List) HomeHandle(jakarta.ejb.HomeHandle) Handle(jakarta.ejb.Handle)

Example 2 with EJBMetaData

use of jakarta.ejb.EJBMetaData in project tomee by apache.

the class RmiIiopBmpBean method returnEJBMetaData.

public EJBMetaData returnEJBMetaData() throws jakarta.ejb.EJBException {
    EJBMetaData data = null;
    try {
        final InitialContext ctx = new InitialContext();
        final EncBmpHome home = (EncBmpHome) ctx.lookup("java:comp/env/bmp/rmi-iiop/home");
        data = home.getEJBMetaData();
    } catch (final Exception e) {
        throw new jakarta.ejb.EJBException(e);
    }
    return data;
}
Also used : EJBMetaData(jakarta.ejb.EJBMetaData) EJBException(jakarta.ejb.EJBException) InitialContext(javax.naming.InitialContext) RemoveException(jakarta.ejb.RemoveException) EJBException(jakarta.ejb.EJBException) RemoteException(java.rmi.RemoteException)

Example 3 with EJBMetaData

use of jakarta.ejb.EJBMetaData in project tomee by apache.

the class CmpRmiIiopTests method test46_returnEJBMetaData.

public void test46_returnEJBMetaData() {
    try {
        final EJBMetaData actual = ejbObject.returnEJBMetaData();
        assertNotNull("The EJBMetaData returned is null", actual);
        assertEquals(actual.getHomeInterfaceClass(), actual.getHomeInterfaceClass());
        assertEquals(actual.getRemoteInterfaceClass(), actual.getRemoteInterfaceClass());
    } catch (final Exception e) {
        fail("Received Exception " + e.getClass() + " : " + e.getMessage());
    }
}
Also used : EJBMetaData(jakarta.ejb.EJBMetaData) RemoteException(java.rmi.RemoteException)

Example 4 with EJBMetaData

use of jakarta.ejb.EJBMetaData in project tomee by apache.

the class CmpRmiIiopTests method test49_returnEJBMetaDataArray.

public void test49_returnEJBMetaDataArray() {
    try {
        final Object obj = initialContext.lookup("client/tests/entity/cmp/EncBean");
        final EncCmpHome home = (EncCmpHome) obj;
        assertNotNull("The EJBHome returned from JNDI is null", home);
        final EJBMetaData[] expected = new EJBMetaData[3];
        for (int i = 0; i < expected.length; i++) {
            expected[i] = home.getEJBMetaData();
            assertNotNull("The EJBMetaData returned is null", expected[i]);
        }
        final EJBMetaData[] actual = (EJBMetaData[]) ejbObject.returnEJBMetaDataArray(expected);
        assertNotNull("The EJBMetaData array returned is null", actual);
        assertEquals(expected.length, actual.length);
        for (int i = 0; i < actual.length; i++) {
            assertNotNull("The EJBMetaData returned is null", actual[i]);
            assertEquals(expected[i].getHomeInterfaceClass(), actual[i].getHomeInterfaceClass());
            assertEquals(expected[i].getRemoteInterfaceClass(), actual[i].getRemoteInterfaceClass());
        }
    } catch (final Exception e) {
        fail("Received Exception " + e.getClass() + " : " + e.getMessage());
    }
}
Also used : EJBMetaData(jakarta.ejb.EJBMetaData) EJBObject(jakarta.ejb.EJBObject) RemoteException(java.rmi.RemoteException)

Example 5 with EJBMetaData

use of jakarta.ejb.EJBMetaData in project tomee by apache.

the class Cmp2RmiIiopTests method test46_returnEJBMetaData.

public void test46_returnEJBMetaData() {
    try {
        final EJBMetaData actual = ejbObject.returnEJBMetaData();
        assertNotNull("The EJBMetaData returned is null", actual);
        assertEquals(actual.getHomeInterfaceClass(), actual.getHomeInterfaceClass());
        assertEquals(actual.getRemoteInterfaceClass(), actual.getRemoteInterfaceClass());
    } catch (final Exception e) {
        fail("Received Exception " + e.getClass() + " : " + e.getMessage());
    }
}
Also used : EJBMetaData(jakarta.ejb.EJBMetaData) RemoteException(java.rmi.RemoteException)

Aggregations

EJBMetaData (jakarta.ejb.EJBMetaData)56 RemoteException (java.rmi.RemoteException)40 EJBObject (jakarta.ejb.EJBObject)18 ObjectGraph (org.apache.openejb.test.object.ObjectGraph)18 EJBException (jakarta.ejb.EJBException)12 InitialContext (javax.naming.InitialContext)12 RemoveException (jakarta.ejb.RemoveException)10 ObjectNotFoundException (jakarta.ejb.ObjectNotFoundException)7 EncCmpHome (org.apache.openejb.test.entity.cmp.EncCmpHome)3 EncCmpObject (org.apache.openejb.test.entity.cmp.EncCmpObject)3 RmiIiopCmpObject (org.apache.openejb.test.entity.cmp.RmiIiopCmpObject)3 CreateException (jakarta.ejb.CreateException)2 Handle (jakarta.ejb.Handle)1 HomeHandle (jakarta.ejb.HomeHandle)1 List (java.util.List)1