Package javax.ejb

Examples of javax.ejb.Handle


      env.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.NamingContextFactory");
      InitialContext ctx = new InitialContext(env);
      StatefulSessionHome home = ( StatefulSessionHome ) ctx.lookup("ejbcts/StatefulSessionBean");
      StatefulSession bean = home.create("testSessionHandleNoDefaultJNDI");

      Handle beanHandle = bean.getHandle();
      ByteArrayOutputStream out = new ByteArrayOutputStream();
      ObjectOutputStream oos = new ObjectOutputStream(out);
      oos.writeObject(beanHandle);
      oos.flush();
      byte[] bytes = out.toByteArray();

      Properties sysProps = System.getProperties();
      Properties newProps = new Properties(sysProps);
      newProps.setProperty("java.naming.factory.initial", "badFactory");
      newProps.setProperty("java.naming.provider.url", "jnp://badhost:12345");
      System.setProperties(newProps);
      try
      {
         getLog().debug("Unserialize bean handle...");
         ByteArrayInputStream in = new ByteArrayInputStream(bytes);
         ObjectInputStream ois = new ObjectInputStream(in);
         beanHandle = (Handle) ois.readObject();
         bean = (StatefulSession) beanHandle.getEJBObject();
         bean.method1("Hello");
         getLog().debug("Called method1 on handle session bean");
      }
      finally
      {
View Full Code Here


      env.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.NamingContextFactory");
      InitialContext ctx = new InitialContext(env);
      StatefulSessionHome home = ( StatefulSessionHome ) ctx.lookup("ejbcts/BMTStatefulSessionBean");
      StatefulSession bean = home.create("testBMTSessionHandleNoDefaultJNDI");

      Handle beanHandle = bean.getHandle();
      ByteArrayOutputStream out = new ByteArrayOutputStream();
      ObjectOutputStream oos = new ObjectOutputStream(out);
      oos.writeObject(beanHandle);
      oos.flush();
      byte[] bytes = out.toByteArray();

      Properties sysProps = System.getProperties();
      Properties newProps = new Properties(sysProps);
      newProps.setProperty("java.naming.factory.initial", "badFactory");
      newProps.setProperty("java.naming.provider.url", "jnp://badhost:12345");
      System.setProperties(newProps);
      try
      {
         getLog().debug("Unserialize bean handle...");
         ByteArrayInputStream in = new ByteArrayInputStream(bytes);
         ObjectInputStream ois = new ObjectInputStream(in);
         beanHandle = (Handle) ois.readObject();
         bean = (StatefulSession) beanHandle.getEJBObject();
         bean.method1("Hello");
         getLog().debug("Called method1 on handle session bean");
      }
      finally
      {
View Full Code Here

    }

    public String getRemoteViaWrappedHandle() throws RemoteException {

        final IIOPBasicRemote object = home.create();
        final Handle handle = object.wrappedHandle().getHandle();
        Assert.assertEquals(HandleImplIIOP.class, handle.getClass());
        final IIOPBasicRemote newObject = (IIOPBasicRemote) PortableRemoteObject.narrow(handle.getEJBObject(), IIOPBasicRemote.class);
        return newObject.hello();
    }
View Full Code Here

        String value = session.getValue();
        Assert.assertEquals("123", value);

        EJBObject ejbObject = (EJBObject) session;

        Handle handle = session.getHandle();
        Assert.assertNotNull(handle);

        home.remove(handle);

        try {
View Full Code Here

        StatefulSession30 session = (StatefulSession30) 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 = (StatefulSession30) home.create();
        Assert.assertFalse(session.isIdentical(session1));
        Assert.assertTrue(session.isIdentical(session));
View Full Code Here

        Session30 session = (Session30) 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 = (Session30) home.create();
        Assert.assertTrue(session.isIdentical(session1));
    }
View Full Code Here

    public Handle returnHandle(final Handle data) {
        return data;
    }

    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");
View Full Code Here

    public Handle returnHandle(final Handle data) {
        return data;
    }

    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");
View Full Code Here

            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());
        }
View Full Code Here

        }
    }

    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());
        }
    }
View Full Code Here

TOP

Related Classes of javax.ejb.Handle

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.