Search in sources :

Example 1 with HomeHandle

use of javax.ejb.HomeHandle in project wildfly by wildfly.

the class ReferenceAnnotationDescriptorTestCase method testStateless21Interfaces.

@Test
public void testStateless21Interfaces() throws Exception {
    InitialContext jndiContext = new InitialContext();
    Session30Home home = (Session30Home) jndiContext.lookup("java:module/Session30!" + Session30Home.class.getName());
    Assert.assertNotNull(home);
    EJBMetaData metadata = home.getEJBMetaData();
    Assert.assertNotNull(metadata);
    Assert.assertEquals(Session30.class.getName(), metadata.getRemoteInterfaceClass().getName());
    HomeHandle homeHandle = home.getHomeHandle();
    Assert.assertNotNull(homeHandle);
    EJBHome ejbHome = homeHandle.getEJBHome();
    Assert.assertNotNull(ejbHome);
    metadata = ejbHome.getEJBMetaData();
    Assert.assertNotNull(metadata);
    Assert.assertEquals(Session30.class.getName(), metadata.getRemoteInterfaceClass().getName());
    Session30 session = home.create();
    Assert.assertNotNull(session);
    ejbHome = session.getEJBHome();
    Assert.assertNotNull(ejbHome);
    Handle handle = session.getHandle();
    Assert.assertNotNull(handle);
    EJBObject ejbObject = handle.getEJBObject();
    Assert.assertNotNull(ejbObject);
    ejbHome = ejbObject.getEJBHome();
    Assert.assertNotNull(ejbHome);
    Handle handle1 = ejbObject.getHandle();
    Assert.assertNotNull(handle1);
    Session30 session1 = home.create();
    Assert.assertTrue(session.isIdentical(session1));
}
Also used : EJBMetaData(javax.ejb.EJBMetaData) EJBHome(javax.ejb.EJBHome) EJBObject(javax.ejb.EJBObject) HomeHandle(javax.ejb.HomeHandle) InitialContext(javax.naming.InitialContext) Session30(org.jboss.as.test.integration.ejb.ejb2.reference.global.Session30) HomeHandle(javax.ejb.HomeHandle) Handle(javax.ejb.Handle) Test(org.junit.Test)

Example 2 with HomeHandle

use of javax.ejb.HomeHandle in project wildfly by wildfly.

the class ReferenceAnnotationDescriptorTestCase method testStateful21Interfaces.

@Test
public void testStateful21Interfaces() throws Exception {
    InitialContext jndiContext = new InitialContext();
    StatefulSession30Home home = (StatefulSession30Home) jndiContext.lookup("java:module/StatefulSession30!" + StatefulSession30Home.class.getName());
    Assert.assertNotNull(home);
    EJBMetaData metadata = home.getEJBMetaData();
    Assert.assertNotNull(metadata);
    Assert.assertEquals(StatefulSession30.class, metadata.getRemoteInterfaceClass());
    HomeHandle homeHandle = home.getHomeHandle();
    Assert.assertNotNull(homeHandle);
    EJBHome ejbHome = homeHandle.getEJBHome();
    Assert.assertNotNull(ejbHome);
    metadata = ejbHome.getEJBMetaData();
    Assert.assertNotNull(metadata);
    Assert.assertEquals(StatefulSession30.class, metadata.getRemoteInterfaceClass());
    StatefulSession30 session = home.create();
    Assert.assertNotNull(session);
    ejbHome = session.getEJBHome();
    Assert.assertNotNull(ejbHome);
    Handle handle = session.getHandle();
    Assert.assertNotNull(handle);
    EJBObject ejbObject = handle.getEJBObject();
    Assert.assertNotNull(ejbObject);
    ejbHome = ejbObject.getEJBHome();
    Assert.assertNotNull(ejbHome);
    Handle handle1 = ejbObject.getHandle();
    Assert.assertNotNull(handle1);
    StatefulSession30 session1 = home.create();
    Assert.assertFalse(session.isIdentical(session1));
    Assert.assertTrue(session.isIdentical(session));
}
Also used : EJBMetaData(javax.ejb.EJBMetaData) EJBHome(javax.ejb.EJBHome) EJBObject(javax.ejb.EJBObject) HomeHandle(javax.ejb.HomeHandle) InitialContext(javax.naming.InitialContext) HomeHandle(javax.ejb.HomeHandle) Handle(javax.ejb.Handle) Test(org.junit.Test)

Example 3 with HomeHandle

use of javax.ejb.HomeHandle 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(javax.ejb.EJBMetaData) HomeHandle(javax.ejb.HomeHandle) List(java.util.List) HomeHandle(javax.ejb.HomeHandle) Handle(javax.ejb.Handle)

Example 4 with HomeHandle

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

the class Cmp2HomeHandleTests method Xtest02_copyHandleByMarshalledObject.

public void Xtest02_copyHandleByMarshalledObject() {
    try {
        final MarshalledObject obj = new MarshalledObject(ejbHomeHandle);
        final HomeHandle copy = (HomeHandle) obj.get();
        assertNotNull("The HomeHandle copy is null", copy);
        final EJBHome home = copy.getEJBHome();
        assertNotNull("The EJBHome is null", home);
    } catch (final Exception e) {
        fail("Received Exception " + e.getClass() + " : " + e.getMessage());
    }
}
Also used : EJBHome(javax.ejb.EJBHome) MarshalledObject(java.rmi.MarshalledObject) HomeHandle(javax.ejb.HomeHandle)

Example 5 with HomeHandle

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

the class Complex2HomeHandleTests method Xtest02_copyHandleByMarshalledObject.

public void Xtest02_copyHandleByMarshalledObject() {
    try {
        final MarshalledObject obj = new MarshalledObject(ejbHomeHandle);
        final HomeHandle copy = (HomeHandle) obj.get();
        assertNotNull("The HomeHandle copy is null", copy);
        final EJBHome home = copy.getEJBHome();
        assertNotNull("The EJBHome is null", home);
    } catch (final Exception e) {
        fail("Received Exception " + e.getClass() + " : " + e.getMessage());
    }
}
Also used : EJBHome(javax.ejb.EJBHome) MarshalledObject(java.rmi.MarshalledObject) HomeHandle(javax.ejb.HomeHandle)

Aggregations

HomeHandle (javax.ejb.HomeHandle)11 EJBHome (javax.ejb.EJBHome)8 ByteArrayInputStream (java.io.ByteArrayInputStream)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 ObjectInputStream (java.io.ObjectInputStream)3 ObjectOutputStream (java.io.ObjectOutputStream)3 MarshalledObject (java.rmi.MarshalledObject)3 EJBMetaData (javax.ejb.EJBMetaData)3 Handle (javax.ejb.Handle)3 EJBObject (javax.ejb.EJBObject)2 InitialContext (javax.naming.InitialContext)2 Test (org.junit.Test)2 List (java.util.List)1 DeploymentRepository (org.jboss.as.ejb3.deployment.DeploymentRepository)1 Session30 (org.jboss.as.test.integration.ejb.ejb2.reference.global.Session30)1 AbstractEJBMetaData (org.jboss.ejb.client.AbstractEJBMetaData)1 EJBHandle (org.jboss.ejb.client.EJBHandle)1 EJBHomeHandle (org.jboss.ejb.client.EJBHomeHandle)1 EJBLocator (org.jboss.ejb.client.EJBLocator)1 EJBMetaDataImpl (org.jboss.ejb.client.EJBMetaDataImpl)1