javax.ejb.Handle Java Examples

The following examples show how to use javax.ejb.Handle. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SingletonRmiIiopTests.java    From tomee with Apache License 2.0 6 votes vote down vote up
public void test50_returnHandle() {
    try {
        final Object obj = initialContext.lookup("client/tests/singleton/EncBean");
        final EncSingletonHome home = (EncSingletonHome) obj;
        assertNotNull("The EJBHome returned from JNDI is null", home);

        final EncSingletonObject object = home.create();
        assertNotNull("The EJBObject created is null", object);

        final Handle expected = object.getHandle();
        assertNotNull("The EJBObject Handle returned is null", expected);
        assertNotNull("The EJBObject in the Handle is null", expected.getEJBObject());

        final Handle actual = ejbObject.returnHandle(expected);
        assertNotNull("The EJBObject Handle returned is null", actual);
        assertNotNull("The EJBObject in the Handle is null", actual.getEJBObject());

        final EJBObject exp = expected.getEJBObject();
        final EJBObject act = actual.getEJBObject();

        assertTrue("The EJBObjects in the Handles are not identical", exp.isIdentical(act));
    } catch (final Exception e) {
        fail("Received Exception " + e.getClass() + " : " + e.getMessage());
    }
}
 
Example #2
Source File: StatefulRmiIiopTests.java    From tomee with Apache License 2.0 6 votes vote down vote up
public void test50_returnHandle() {
    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 object = home.create("test_50 StatefulBean");
        assertNotNull("The EJBObject created is null", object);

        final Handle expected = object.getHandle();
        assertNotNull("The EJBObject Handle returned is null", expected);
        assertNotNull("The EJBObject in the Handle is null", expected.getEJBObject());

        final Handle actual = ejbObject.returnHandle(expected);
        assertNotNull("The EJBObject Handle returned is null", actual);
        assertNotNull("The EJBObject in the Handle is null", actual.getEJBObject());

        final EJBObject exp = expected.getEJBObject();
        final EJBObject act = actual.getEJBObject();

        assertTrue("The EJBObjects in the Handles are not identical", exp.isIdentical(act));
    } catch (final Exception e) {
        fail("Received Exception " + e.getClass() + " : " + e.getMessage());
    }
}
 
Example #3
Source File: BmpRmiIiopTests.java    From tomee with Apache License 2.0 6 votes vote down vote up
public void test50_returnHandle() {
    try {
        final Object obj = initialContext.lookup("client/tests/entity/bmp/EncBean");
        final EncBmpHome home = (EncBmpHome) obj;
        assertNotNull("The EJBHome returned from JNDI is null", home);

        final EncBmpObject object = home.create("test_50 BmpBean");
        assertNotNull("The EJBObject created is null", object);

        final Handle expected = object.getHandle();
        assertNotNull("The EJBObject Handle returned is null", expected);
        assertNotNull("The EJBObject in the Handle is null", expected.getEJBObject());

        final Handle actual = ejbObject.returnHandle(expected);
        assertNotNull("The EJBObject Handle returned is null", actual);
        assertNotNull("The EJBObject in the Handle is null", actual.getEJBObject());

        final EJBObject exp = expected.getEJBObject();
        final EJBObject act = actual.getEJBObject();

        assertTrue("The EJBObjects in the Handles are not identical", exp.isIdentical(act));
    } catch (final Exception e) {
        fail("Received Exception " + e.getClass() + " : " + e.getMessage());
    }
}
 
Example #4
Source File: Cmp2RmiIiopTests.java    From tomee with Apache License 2.0 6 votes vote down vote up
public void test50_returnHandle() {
    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 EncCmpObject object = home.create("test_50 CmpBean");
        assertNotNull("The EJBObject created is null", object);

        final Handle expected = object.getHandle();
        assertNotNull("The EJBObject Handle returned is null", expected);
        assertNotNull("The EJBObject in the Handle is null", expected.getEJBObject());

        final Handle actual = ejbObject.returnHandle(expected);
        assertNotNull("The EJBObject Handle returned is null", actual);
        assertNotNull("The EJBObject in the Handle is null", actual.getEJBObject());

        final EJBObject exp = expected.getEJBObject();
        final EJBObject act = actual.getEJBObject();

        assertTrue("The EJBObjects in the Handles are not identical", exp.isIdentical(act));
    } catch (final Exception e) {
        fail("Received Exception " + e.getClass() + " : " + e.getMessage());
    }
}
 
Example #5
Source File: Complex2HandleTests.java    From tomee with Apache License 2.0 6 votes vote down vote up
public void Xtest03_copyHandleBySerialize() {
    try {
        final ByteArrayOutputStream baos = new ByteArrayOutputStream();
        final ObjectOutputStream oos = new ObjectOutputStream(baos);
        oos.writeObject(ejbHandle);
        oos.flush();
        oos.close();
        final ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
        final ObjectInputStream ois = new ObjectInputStream(bais);
        final Handle copy = (Handle) ois.readObject();

        final EJBObject object = copy.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());
    }
}
 
Example #6
Source File: Cmp2HandleTests.java    From tomee with Apache License 2.0 6 votes vote down vote up
public void Xtest03_copyHandleBySerialize() {
    try {
        final ByteArrayOutputStream baos = new ByteArrayOutputStream();
        final ObjectOutputStream oos = new ObjectOutputStream(baos);
        oos.writeObject(ejbHandle);
        oos.flush();
        oos.close();
        final ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
        final ObjectInputStream ois = new ObjectInputStream(bais);
        final Handle copy = (Handle) ois.readObject();

        final EJBObject object = copy.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());
    }
}
 
Example #7
Source File: StatelessRmiIiopTests.java    From tomee with Apache License 2.0 6 votes vote down vote up
public void test50_returnHandle() {
    try {
        final Object obj = initialContext.lookup("client/tests/stateless/EncBean");
        final EncStatelessHome home = (EncStatelessHome) obj;
        assertNotNull("The EJBHome returned from JNDI is null", home);

        final EncStatelessObject object = home.create();
        assertNotNull("The EJBObject created is null", object);

        final Handle expected = object.getHandle();
        assertNotNull("The EJBObject Handle returned is null", expected);
        assertNotNull("The EJBObject in the Handle is null", expected.getEJBObject());

        final Handle actual = ejbObject.returnHandle(expected);
        assertNotNull("The EJBObject Handle returned is null", actual);
        assertNotNull("The EJBObject in the Handle is null", actual.getEJBObject());

        final EJBObject exp = expected.getEJBObject();
        final EJBObject act = actual.getEJBObject();

        assertTrue("The EJBObjects in the Handles are not identical", exp.isIdentical(act));
    } catch (final Exception e) {
        fail("Received Exception " + e.getClass() + " : " + e.getMessage());
    }
}
 
Example #8
Source File: CmpRmiIiopTests.java    From tomee with Apache License 2.0 6 votes vote down vote up
public void test50_returnHandle() {
    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 EncCmpObject object = home.create("test_50 CmpBean");
        assertNotNull("The EJBObject created is null", object);

        final Handle expected = object.getHandle();
        assertNotNull("The EJBObject Handle returned is null", expected);
        assertNotNull("The EJBObject in the Handle is null", expected.getEJBObject());

        final Handle actual = ejbObject.returnHandle(expected);
        assertNotNull("The EJBObject Handle returned is null", actual);
        assertNotNull("The EJBObject in the Handle is null", actual.getEJBObject());

        final EJBObject exp = expected.getEJBObject();
        final EJBObject act = actual.getEJBObject();

        assertTrue("The EJBObjects in the Handles are not identical", exp.isIdentical(act));
    } catch (final Exception e) {
        fail("Received Exception " + e.getClass() + " : " + e.getMessage());
    }
}
 
Example #9
Source File: Unknown2HandleTests.java    From tomee with Apache License 2.0 6 votes vote down vote up
public void Xtest03_copyHandleBySerialize() {
    try {
        final ByteArrayOutputStream baos = new ByteArrayOutputStream();
        final ObjectOutputStream oos = new ObjectOutputStream(baos);
        oos.writeObject(ejbHandle);
        oos.flush();
        oos.close();
        final ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
        final ObjectInputStream ois = new ObjectInputStream(bais);
        final Handle copy = (Handle) ois.readObject();

        final EJBObject object = copy.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());
    }
}
 
Example #10
Source File: StatelessRmiIiopTests.java    From tomee with Apache License 2.0 5 votes vote down vote up
public void test52_returnNestedHandle() {
    try {
        final Object obj = initialContext.lookup("client/tests/stateless/EncBean");
        final EncStatelessHome home = (EncStatelessHome) obj;
        assertNotNull("The EJBHome returned from JNDI is null", home);

        final EncStatelessObject object = home.create();
        assertNotNull("The EJBObject created is null", object);

        final Handle expected = object.getHandle();
        assertNotNull("The EJBObject Handle returned is null", expected);
        assertNotNull("The EJBObject in the Handle is null", expected.getEJBObject());

        final ObjectGraph graph = ejbObject.returnObjectGraph(new ObjectGraph(expected));
        assertNotNull("The ObjectGraph is null", graph);

        final Handle actual = (Handle) graph.getObject();
        assertNotNull("The EJBObject Handle returned is null", actual);
        assertNotNull("The EJBObject in the Handle is null", actual.getEJBObject());

        final EJBObject exp = expected.getEJBObject();
        final EJBObject act = actual.getEJBObject();

        assertTrue("The EJBObjects in the Handles are not identical", exp.isIdentical(act));

    } catch (final Exception e) {
        fail("Received Exception " + e.getClass() + " : " + e.getMessage());
    }
}
 
Example #11
Source File: BmpRmiIiopTests.java    From tomee with Apache License 2.0 5 votes vote down vote up
public void test54_returnHandleArray() {
    try {
        final Object obj = initialContext.lookup("client/tests/entity/bmp/EncBean");
        final EncBmpHome home = (EncBmpHome) obj;
        assertNotNull("The EJBHome returned from JNDI is null", home);

        final EncBmpObject object = home.create("test_54 BmpBean");
        assertNotNull("The EJBObject created is null", object);

        final Handle[] expected = new Handle[3];
        for (int i = 0; i < expected.length; i++) {
            expected[i] = object.getHandle();
            assertNotNull("The EJBObject Handle returned is null", expected[i]);
        }

        final Handle[] actual = (Handle[]) ejbObject.returnHandleArray(expected);
        assertNotNull("The Handle array returned is null", actual);
        assertEquals(expected.length, actual.length);

        for (int i = 0; i < expected.length; i++) {
            assertNotNull("The EJBObject Handle returned is null", actual[i]);
            assertNotNull("The EJBObject in the Handle is null", actual[i].getEJBObject());
            assertTrue("The EJBObjects in the Handles are not equal", expected[i].getEJBObject().isIdentical(actual[i].getEJBObject()));
        }

    } catch (final Exception e) {
        fail("Received Exception " + e.getClass() + " : " + e.getMessage());
    }
}
 
Example #12
Source File: StatelessRmiIiopTests.java    From tomee with Apache License 2.0 5 votes vote down vote up
public void test51_returnHandle() {
    try {
        final Handle actual = ejbObject.returnHandle();
        assertNotNull("The EJBObject Handle returned is null", actual);
        assertNotNull("The EJBObject in the Handle is null", actual.getEJBObject());

    } catch (final Exception e) {
        fail("Received Exception " + e.getClass() + " : " + e.getMessage());
    }
}
 
Example #13
Source File: StatefulRmiIiopTests.java    From tomee with Apache License 2.0 5 votes vote down vote up
public void test54_returnHandleArray() {
    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 object = home.create("test_54 StatefulBean");
        assertNotNull("The EJBObject created is null", object);

        final Handle[] expected = new Handle[3];
        for (int i = 0; i < expected.length; i++) {
            expected[i] = object.getHandle();
            assertNotNull("The EJBObject Handle returned is null", expected[i]);
        }

        final Handle[] actual = (Handle[]) ejbObject.returnHandleArray(expected);
        assertNotNull("The Handle array returned is null", actual);
        assertEquals(expected.length, actual.length);

        for (int i = 0; i < expected.length; i++) {
            assertNotNull("The EJBObject Handle returned is null", actual[i]);
            assertNotNull("The EJBObject in the Handle is null", actual[i].getEJBObject());
            assertTrue("The EJBObjects in the Handles are not equal", expected[i].getEJBObject().isIdentical(actual[i].getEJBObject()));
        }

    } catch (final Exception e) {
        fail("Received Exception " + e.getClass() + " : " + e.getMessage());
    }
}
 
Example #14
Source File: StatefulRmiIiopTests.java    From tomee with Apache License 2.0 5 votes vote down vote up
public void test53_returnNestedHandle2() {
    try {
        final ObjectGraph graph = ejbObject.returnNestedHandle();
        assertNotNull("The ObjectGraph is null", graph);

        final Handle actual = (Handle) graph.getObject();
        assertNotNull("The EJBObject Handle returned is null", actual);
        assertNotNull("The EJBObject in the Handle is null", actual.getEJBObject());
    } catch (final Exception e) {
        fail("Received Exception " + e.getClass() + " : " + e.getMessage());
    }
}
 
Example #15
Source File: StatefulRmiIiopTests.java    From tomee with Apache License 2.0 5 votes vote down vote up
public void test52_returnNestedHandle() {
    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 object = home.create("test_52 StatefulBean");
        assertNotNull("The EJBObject created is null", object);

        final Handle expected = object.getHandle();
        assertNotNull("The EJBObject Handle returned is null", expected);
        assertNotNull("The EJBObject in the Handle is null", expected.getEJBObject());

        final ObjectGraph graph = ejbObject.returnObjectGraph(new ObjectGraph(expected));
        assertNotNull("The ObjectGraph is null", graph);

        final Handle actual = (Handle) graph.getObject();
        assertNotNull("The EJBObject Handle returned is null", actual);
        assertNotNull("The EJBObject in the Handle is null", actual.getEJBObject());

        final EJBObject exp = expected.getEJBObject();
        final EJBObject act = actual.getEJBObject();

        assertTrue("The EJBObjects in the Handles are not identical", exp.isIdentical(act));

    } catch (final Exception e) {
        fail("Received Exception " + e.getClass() + " : " + e.getMessage());
    }
}
 
Example #16
Source File: StatefulRmiIiopTests.java    From tomee with Apache License 2.0 5 votes vote down vote up
public void test51_returnHandle() {
    try {
        final Handle actual = ejbObject.returnHandle();
        assertNotNull("The EJBObject Handle returned is null", actual);
        assertNotNull("The EJBObject in the Handle is null", actual.getEJBObject());

    } catch (final Exception e) {
        fail("Received Exception " + e.getClass() + " : " + e.getMessage());
    }
}
 
Example #17
Source File: BmpRmiIiopTests.java    From tomee with Apache License 2.0 5 votes vote down vote up
public void test51_returnHandle() {
    try {
        final Handle actual = ejbObject.returnHandle();
        assertNotNull("The EJBObject Handle returned is null", actual);
        assertNotNull("The EJBObject in the Handle is null", actual.getEJBObject());

    } catch (final Exception e) {
        fail("Received Exception " + e.getClass() + " : " + e.getMessage());
    }
}
 
Example #18
Source File: SingletonRmiIiopTests.java    From tomee with Apache License 2.0 5 votes vote down vote up
public void test53_returnNestedHandle2() {
    try {
        final ObjectGraph graph = ejbObject.returnNestedHandle();
        assertNotNull("The ObjectGraph is null", graph);

        final Handle actual = (Handle) graph.getObject();
        assertNotNull("The EJBObject Handle returned is null", actual);
        assertNotNull("The EJBObject in the Handle is null", actual.getEJBObject());
    } catch (final Exception e) {
        fail("Received Exception " + e.getClass() + " : " + e.getMessage());
    }
}
 
Example #19
Source File: StatelessRmiIiopTests.java    From tomee with Apache License 2.0 5 votes vote down vote up
public void test53_returnNestedHandle2() {
    try {
        final ObjectGraph graph = ejbObject.returnNestedHandle();
        assertNotNull("The ObjectGraph is null", graph);

        final Handle actual = (Handle) graph.getObject();
        assertNotNull("The EJBObject Handle returned is null", actual);
        assertNotNull("The EJBObject in the Handle is null", actual.getEJBObject());
    } catch (final Exception e) {
        fail("Received Exception " + e.getClass() + " : " + e.getMessage());
    }
}
 
Example #20
Source File: StatelessRmiIiopTests.java    From tomee with Apache License 2.0 5 votes vote down vote up
public void test54_returnHandleArray() {
    try {
        final Object obj = initialContext.lookup("client/tests/stateless/EncBean");
        final EncStatelessHome home = (EncStatelessHome) obj;
        assertNotNull("The EJBHome returned from JNDI is null", home);

        final EncStatelessObject object = home.create();
        assertNotNull("The EJBObject created is null", object);

        final Handle[] expected = new Handle[3];
        for (int i = 0; i < expected.length; i++) {
            expected[i] = object.getHandle();
            assertNotNull("The EJBObject Handle returned is null", expected[i]);
        }

        final Handle[] actual = (Handle[]) ejbObject.returnHandleArray(expected);
        assertNotNull("The Handle array returned is null", actual);
        assertEquals(expected.length, actual.length);

        for (int i = 0; i < expected.length; i++) {
            assertNotNull("The EJBObject Handle returned is null", actual[i]);
            assertNotNull("The EJBObject in the Handle is null", actual[i].getEJBObject());
            assertTrue("The EJBObjects in the Handles are not equal", expected[i].getEJBObject().isIdentical(actual[i].getEJBObject()));
        }

    } catch (final Exception e) {
        fail("Received Exception " + e.getClass() + " : " + e.getMessage());
    }
}
 
Example #21
Source File: SingletonRmiIiopTests.java    From tomee with Apache License 2.0 5 votes vote down vote up
public void test51_returnHandle() {
    try {
        final Handle actual = ejbObject.returnHandle();
        assertNotNull("The EJBObject Handle returned is null", actual);
        assertNotNull("The EJBObject in the Handle is null", actual.getEJBObject());

    } catch (final Exception e) {
        fail("Received Exception " + e.getClass() + " : " + e.getMessage());
    }
}
 
Example #22
Source File: SingletonRmiIiopTests.java    From tomee with Apache License 2.0 5 votes vote down vote up
public void test52_returnNestedHandle() {
    try {
        final Object obj = initialContext.lookup("client/tests/singleton/EncBean");
        final EncSingletonHome home = (EncSingletonHome) obj;
        assertNotNull("The EJBHome returned from JNDI is null", home);

        final EncSingletonObject object = home.create();
        assertNotNull("The EJBObject created is null", object);

        final Handle expected = object.getHandle();
        assertNotNull("The EJBObject Handle returned is null", expected);
        assertNotNull("The EJBObject in the Handle is null", expected.getEJBObject());

        final ObjectGraph graph = ejbObject.returnObjectGraph(new ObjectGraph(expected));
        assertNotNull("The ObjectGraph is null", graph);

        final Handle actual = (Handle) graph.getObject();
        assertNotNull("The EJBObject Handle returned is null", actual);
        assertNotNull("The EJBObject in the Handle is null", actual.getEJBObject());

        final EJBObject exp = expected.getEJBObject();
        final EJBObject act = actual.getEJBObject();

        assertTrue("The EJBObjects in the Handles are not identical", exp.isIdentical(act));

    } catch (final Exception e) {
        fail("Received Exception " + e.getClass() + " : " + e.getMessage());
    }
}
 
Example #23
Source File: SingletonRmiIiopTests.java    From tomee with Apache License 2.0 5 votes vote down vote up
public void test54_returnHandleArray() {
    try {
        final Object obj = initialContext.lookup("client/tests/singleton/EncBean");
        final EncSingletonHome home = (EncSingletonHome) obj;
        assertNotNull("The EJBHome returned from JNDI is null", home);

        final EncSingletonObject object = home.create();
        assertNotNull("The EJBObject created is null", object);

        final Handle[] expected = new Handle[3];
        for (int i = 0; i < expected.length; i++) {
            expected[i] = object.getHandle();
            assertNotNull("The EJBObject Handle returned is null", expected[i]);
        }

        final Handle[] actual = (Handle[]) ejbObject.returnHandleArray(expected);
        assertNotNull("The Handle array returned is null", actual);
        assertEquals(expected.length, actual.length);

        for (int i = 0; i < expected.length; i++) {
            assertNotNull("The EJBObject Handle returned is null", actual[i]);
            assertNotNull("The EJBObject in the Handle is null", actual[i].getEJBObject());
            assertTrue("The EJBObjects in the Handles are not equal", expected[i].getEJBObject().isIdentical(actual[i].getEJBObject()));
        }

    } catch (final Exception e) {
        fail("Received Exception " + e.getClass() + " : " + e.getMessage());
    }
}
 
Example #24
Source File: RmiIiopBmpBean.java    From tomee with Apache License 2.0 5 votes vote down vote up
public Handle returnHandle() throws javax.ejb.EJBException {
    Handle data = null;

    try {
        final InitialContext ctx = new InitialContext();

        final EncBmpHome home = (EncBmpHome) ctx.lookup("java:comp/env/bmp/rmi-iiop/home");
        final EncBmpObject object = home.create("Test03 BmpBean");
        data = object.getHandle();

    } catch (final Exception e) {
        throw new javax.ejb.EJBException(e);
    }
    return data;
}
 
Example #25
Source File: RmiIiopCmp2Bean.java    From tomee with Apache License 2.0 5 votes vote down vote up
public Handle returnHandle() {
    Handle data = null;

    try {
        final InitialContext ctx = new InitialContext();

        final EncCmpHome home = (EncCmpHome) ctx.lookup("java:comp/env/cmp/rmi-iiop/home");
        final EncCmpObject object = home.create("Test03 CmpBean");
        data = object.getHandle();

    } catch (final Exception e) {
        throw new EJBException(e);
    }
    return data;
}
 
Example #26
Source File: RmiIiopCmpBean.java    From tomee with Apache License 2.0 5 votes vote down vote up
public Handle returnHandle() throws javax.ejb.EJBException {
    Handle data = null;

    try {
        final InitialContext ctx = new InitialContext();

        final EncCmpHome home = (EncCmpHome) ctx.lookup("java:comp/env/cmp/rmi-iiop/home");
        final EncCmpObject object = home.create("Test03 CmpBean");
        data = object.getHandle();

    } catch (final Exception e) {
        throw new javax.ejb.EJBException(e);
    }
    return data;
}
 
Example #27
Source File: RmiIiopStatefulBean.java    From tomee with Apache License 2.0 5 votes vote down vote up
public Handle returnHandle() throws javax.ejb.EJBException {
    Handle data = null;

    try {
        final InitialContext ctx = new InitialContext();

        final EncStatefulHome home = (EncStatefulHome) ctx.lookup("java:comp/env/stateful/rmi-iiop/home");
        final EncStatefulObject object = home.create("Test03 StatefulBean");
        data = object.getHandle();

    } catch (final Exception e) {
        throw new javax.ejb.EJBException(e);
    }
    return data;
}
 
Example #28
Source File: RmiIiopStatelessBean.java    From tomee with Apache License 2.0 5 votes vote down vote up
public Handle returnHandle() throws javax.ejb.EJBException {
    Handle data = null;

    try {
        final InitialContext ctx = new InitialContext();

        final EncStatelessHome home = (EncStatelessHome) ctx.lookup("java:comp/env/stateless/rmi-iiop/home");
        final EncStatelessObject object = home.create();
        data = object.getHandle();

    } catch (final Exception e) {
        throw new javax.ejb.EJBException(e);
    }
    return data;
}
 
Example #29
Source File: RmiIiopSingletonBean.java    From tomee with Apache License 2.0 5 votes vote down vote up
public Handle returnHandle() throws javax.ejb.EJBException {
    Handle data = null;

    try {
        final InitialContext ctx = new InitialContext();

        final EncSingletonHome home = (EncSingletonHome) ctx.lookup("java:comp/env/singleton/rmi-iiop/home");
        final EncSingletonObject object = home.create();
        data = object.getHandle();

    } catch (final Exception e) {
        throw new javax.ejb.EJBException(e);
    }
    return data;
}
 
Example #30
Source File: CrossClassLoaderProxyTestObject.java    From tomee with Apache License 2.0 5 votes vote down vote up
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);
    }