Package javax.ejb

Examples of javax.ejb.Handle


         getLog().debug("Reconstitute the bean...");
         bean = doEjbCreate(pk, BEAN_NAME);
         getLog().debug("OK");

         getLog().debug("Get Handle object...");
         Handle hn = bean.getHandle( );
         getLog().debug("OK");

         getLog().debug("Remove the bean using the handle...");
         home.remove(hn);
         getLog().debug("OK");
View Full Code Here


         getLog().debug("Get the bean's Primary Key...");
         pk = (AccountPK)bean.getPrimaryKey();
         getLog().debug("OK");

         getLog().debug("Get the bean's handle...");
         Handle hn = bean.getHandle();
         getLog().debug("OK");

         // Remove
         getLog().debug("Remove the bean...");
         bean.remove();
View Full Code Here

         home = (CtsBmpHome)bean.getEJBHome();
         assertTrue(home != null);
         getLog().debug("OK");

         getLog().debug("Obtain the HANDLE...");
         Handle han = bean.getHandle();
         assertTrue(han != null);
         getLog().debug("OK");

         getLog().debug("Obtain the primary key...");
         pk = (AccountPK)bean.getPrimaryKey();
View Full Code Here

         getLog().debug("Create a bean...");
         bean = doEjbCreate(pk, BEAN_NAME);
         getLog().debug("OK");

         getLog().debug("Get a Handle reference and serialize it...");
         Handle beanHandle = bean.getHandle();
         ByteArrayOutputStream out = new ByteArrayOutputStream();
         ObjectOutputStream sOut = new ObjectOutputStream(out);
         sOut.writeObject(beanHandle);
         sOut.flush();
         byte[] bytes = out.toByteArray();
         getLog().debug("OK");
         getLog().debug("Unserialize bean handle...");
         ByteArrayInputStream in = new ByteArrayInputStream(bytes);
         ObjectInputStream sIn = new ObjectInputStream(in);
         beanHandle = (Handle)sIn.readObject();
         getLog().debug("OK");

         getLog().debug("Use PortableRemoteObject to narrow result...");
         bean = (CtsBmp)PortableRemoteObject.narrow(beanHandle.getEJBObject(),
                                                    CtsBmp.class);
         getLog().debug("OK");

         getLog().debug("Check that new reference works...");
         assertTrue(bean.getPersonsName().trim().equals(BEAN_NAME));
View Full Code Here

      homeProps.setProperty("java.naming.factory.initial", "org.jboss.naming.NamingContextFactory");
      InitialContext ic = new InitialContext(homeProps);
      CtsBmpHome home = (CtsBmpHome) ic.lookup("ejbcts/BMPBean");
      AccountPK pk = new AccountPK(BEAN_PK_007);
      CtsBmp bean = doEjbCreate(pk, BEAN_NAME);
      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 = (CtsBmp) beanHandle.getEJBObject();
         String name = bean.getPersonsName();
         getLog().debug("getPersonsName: "+name);
      }
      finally
      {
View Full Code Here

            log.info("Creating a new stateful session");
            InitialContext ctx = new InitialContext();
            Context enc = (Context) ctx.lookup("java:comp/env");
            StatelessSessionHome localHome = (StatelessSessionHome) enc.lookup("ejb/StatefulEJB");
            localBean = localHome.create();
            Handle h = localBean.getHandle();
            SessionHandle wrapper = new SessionHandle(h);
            session.setAttribute("StatefulEJB", wrapper);
         }
         else
         {
View Full Code Here

      StatefulSessionHome sessionHome = ( StatefulSessionHome ) ctx.lookup("ejbcts/StatefulSessionBean");
      StatefulSession sessionBean1 = sessionHome.create("testPassivationByTime");   
      sessionBean1.method1("hello");

      getLog().debug("Retrieving handle for object");
      Handle handle = sessionBean1.getHandle();

      getLog().debug("Waiting 41 seconds for passivation...");
      Thread.sleep(41*1000);

      // Validate that sessionBean1 was passivated and activated
      boolean passivated = sessionBean1.getWasPassivated();
      assertTrue("sessionBean1 WasPassivated", passivated);
      boolean activated = sessionBean1.getWasActivated();
      assertTrue("sessionBean1 WasActivated", activated);

      getLog().debug("Waiting 90 seconds for removal due to age...");
      Thread.sleep(90*1000);

      try
      {
         handle.getEJBObject();
         fail("Was able to get the remote interface for a removed session");
      }
      catch (RemoteException expected)
      {
         getLog().debug("Handle access failed as expected", expected);
View Full Code Here

      Context ctx  = new InitialContext();
      StatefulSessionHome home = ( StatefulSessionHome ) ctx.lookup("ejbcts/StatefulSessionBean");
      StatefulSession bean = home.create("testCompareSerializeGetPK");   

      // Get the bean handle
      Handle hn = bean.getHandle();

      assertTrue(hn != null);

      // "Copy" the bean
      StatefulSession theOtherBean =
         ( StatefulSession ) javax.rmi.PortableRemoteObject.narrow(
            hn.getEJBObject(), StatefulSession.class);

      assertTrue(theOtherBean != null);
      assertTrue(bean.isIdentical(theOtherBean));
   }
View Full Code Here

      getLog().debug("Bean == 3?");
      assertTrue(bean.getCounter() == 3);
      getLog().debug("passes..");

      // Get handle and serialize
      Handle             beanHandle = bean.getHandle();
      FileOutputStream   out        = new FileOutputStream("abean.ser");
      ObjectOutputStream s          = new ObjectOutputStream(out);

      s.writeObject(beanHandle);
      s.flush();
View Full Code Here

      StatefulSession bean = null;
      getLog().debug("Resurrect bean from .ser file");
      FileInputStream   in         = new FileInputStream("abean.ser");
      ObjectInputStream s          = new ObjectInputStream(in);
      Handle beanHandle = ( Handle ) s.readObject();
      bean = ( StatefulSession ) beanHandle.getEJBObject();

      // Should still equal '3'?
      getLog().debug("Bean reanimated, still equal '3'? bean = "
                         + bean.getCounter());
      assertTrue(bean.getCounter() == 3);
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.