Package javax.ejb

Examples of javax.ejb.Handle


   }
   public String useSessionRef()
      throws RemoteException
   {
      log.info("useSessionRef");
      Handle handle = sessionRef.getHandle();
      return handle.toString();
   }
View Full Code Here


      try
      {
         StatefulSessionHome home = (StatefulSessionHome) sessionCtx.getEJBHome();
         StatefulSession bean = home.create(testName);
         bean.incCounter();
         Handle handle = bean.getHandle();
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         ObjectOutputStream oos = new ObjectOutputStream(baos);
         oos.writeObject(handle);
         this.statefulHandle = baos.toByteArray();
      }
View Full Code Here

      log.info("useStatefulSessionHandle");
      try
      {
         ByteArrayInputStream bais = new ByteArrayInputStream(statefulHandle);
         ObjectInputStream ois = new ObjectInputStream(bais);
         Handle handle = (Handle) ois.readObject();
         StatefulSession bean = (StatefulSession) handle.getEJBObject();
         bean.incCounter();
         int count = bean.getCounter();
         log.info("useStatefulSessionHandle, count="+count);
      }
      catch(Exception e)
View Full Code Here

   public void createSessionRef()
      throws RemoteException
   {
      log.info("createSessionRef");
      Handle handle = super.sessionCtx.getEJBObject().getHandle();
      this.sessionRef = new SessionRef(handle);
   }
View Full Code Here

   }
   public String useSessionRef()
      throws RemoteException
   {
      log.info("useSessionRef");
      Handle handle = sessionRef.getHandle();
      return handle.toString();
   }
View Full Code Here

   }

   public void testPassivationByTimeLocal()
   {
      StatefulSessionLocal sessionBean1 = null;
      Handle handle = null;
      try
      {
         Context ctx = new InitialContext();
         log.debug("+++ testPassivationByTime");
         StatefulSessionLocalHome sessionHome = ( StatefulSessionLocalHome ) ctx.lookup("ejbcts/StatefulSessionLocalBean");
         sessionBean1 = sessionHome.create("testPassivationByTimeLocal");   
         sessionBean1.ping();

       handle = sessionBean1.getHandle();

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

         // Validate that sessionBean1 was passivated and activated
         boolean passivated = sessionBean1.getWasPassivated();
         if (passivated == false) throw new EJBException("sessionBean1 WasPassivated");
         boolean activated = sessionBean1.getWasActivated();
         if (activated == false) throw new EJBException("sessionBean1 WasActivated");

         log.debug("Waiting 90 seconds for removal due to age...");
         Thread.sleep(90*1000);
      }
      catch (CreateException e)
      {
         throw new EJBException(e.toString());
      }
      catch (NamingException e)
      {
         throw new EJBException(e.toString());
      }
      catch (InterruptedException e)
      {
         throw new EJBException(e.toString());
      }

      try
      {
         sessionBean1.ping();
         throw new EJBException("Was able to ping for a removed session");
      }
      catch (NoSuchObjectLocalException expected)
      {
         log.debug("Session access failed as expected", expected);
      }

      try
      {
         handle.getEJBObject();
         throw new EJBException("Was able to getEJBObject for a removed session");
      }
      catch (RemoteException expected)
      {
         log.debug("Session access failed as expected", expected);
View Full Code Here

      getLog().debug(++test+"- "+"equals (another object) (true under same home)... " + statelessSession.equals(statelessSessionHome.create()));

      getLog().debug("***Testing the various local EJBObject class calls");

      getLog().debug(++test+"- "+"Get Handle ... ");
      Handle statelessHandle = statelessSession.getHandle();
      assertTrue("statelessHandle != null", statelessHandle != null);
      getLog().debug("OK");
      getLog().debug(++test+"- "+"Serialize handle and deserialize..");
      MarshalledObject mo = new MarshalledObject(statelessHandle);
      Handle handle2 = (Handle) mo.get();
      StatelessSession statelessSession2 = (StatelessSession) handle2.getEJBObject();
      assertTrue("statelessSession2 != null", statelessSession2 != null);
      getLog().debug("OK");
      getLog().debug(++test+"- "+"Calling businessMethodB on it...");
      getLog().debug(statelessSession2.callBusinessMethodB());
      getLog().debug(++test+"- "+"They should be identical..."+statelessSession.isIdentical(statelessSession2));
View Full Code Here

                     statefulSession.equals(statefulSessionHome.create("marc4")));

      getLog().debug("***Testing the various local EJBObject class calls");

      getLog().debug(++test+"- "+"Get Handle ... ");
      Handle statefulHandle = statefulSession.getHandle();
      assertTrue("statefulHandle != null", statefulHandle != null);
      getLog().debug("OK");
      getLog().debug(++test+"- "+"Serialize handle and deserialize....");
      MarshalledObject mo2 = new MarshalledObject(statefulHandle);
      Handle statefulHandle2 = (Handle) mo2.get();
      StatefulSession statefulSession2 = (StatefulSession) statefulHandle2.getEJBObject();
      assertTrue("statefulSession2 != null", statefulSession2 != null);
      getLog().debug("OK");
      getLog().debug(++test+"- "+"Calling businessMethodB on it..." +
                     statefulSession2.callBusinessMethodB());

      getLog().debug(++test+"- "+"They should be identical..." +
                     statefulSession.isIdentical(statefulSession2));

      getLog().debug(++test+"- "+"Calling StatefulSession.remove()...");
      statefulSession.remove();
      getLog().debug("ok");
      getLog().debug(++test+"- "+"Calling StatefulHome.remove(Handle) (this should fail)...");
      try
      {
         statefulSessionHome.remove(statefulSession2.getHandle());
         fail("statefulSessionHome.remove did not fail");
      }
      catch (Exception e)
      {
         getLog().debug("not found OK");
      }
      getLog().debug(++test+"- "+"Creating a 3rd bean and calling it...");
      StatefulSession ss3 = statefulSessionHome.create("marc3");
      getLog().debug(ss3.callBusinessMethodA());
      getLog().debug(++test+"- "+"Calling StatefulSession.remove(Handle) on a third bean...");
      Handle statefulHandle3 = ss3.getHandle();
      statefulSessionHome.remove(statefulHandle3);
      getLog().debug("OK");
      getLog().debug(++test+"- "+"I should not be able to remove it directly...");
      try {
         ss3.remove();
         fail("ss3.remove() did not fail");
      } catch (Exception e) {
         getLog().debug("OK");
      }

      getLog().debug(++test+"- "+"Creating a 4th bean using create<METHOD> and calling it...");
      StatefulSession ss4 = statefulSessionHome.createMETHOD("marc4", "address");
      getLog().debug(ss4.callBusinessMethodA());
      getLog().debug(++test+"- "+"Calling StatefulSession.remove(Handle) on a fourth bean...");
      Handle statefulHandle4 = ss4.getHandle();
      statefulSessionHome.remove(statefulHandle4);
   }
View Full Code Here

      getLog().debug("***Testing the various local EJBObject class calls");
      getLog().debug(++test+"- "+"Get Primary Key ... " +
                     enterpriseEntity.getPrimaryKey());

      getLog().debug(++test+"- "+"Get Handle ... ");
      Handle entityHandle = enterpriseEntity.getHandle();
      assertTrue("entityHandle != null", entityHandle != null);
      getLog().debug("OK");
      getLog().debug(++test+"- "+"Serialize handle and deserialize....");
      MarshalledObject mo3 = new MarshalledObject(entityHandle);
      Handle entityHandle3 = (Handle) mo3.get();
      EnterpriseEntity enterpriseEntity3 = (EnterpriseEntity) entityHandle3.getEJBObject();
      if (enterpriseEntity3 != null) getLog().debug("OK");
         getLog().debug(++test+"- "+"Calling businessMethodA on it...");
      getLog().debug(enterpriseEntity3.callBusinessMethodB());
      getLog().debug(++test+"- "+"They should be identical..."+enterpriseEntity.isIdentical(enterpriseEntity3));
      getLog().debug(++test+"- "+"Calling entityHome.remove(Handle)...");
View Full Code Here

      getLog().debug(++test+"- "+"MyObject ");
      MyObject obj = allTypes.getObject();
      getLog().debug("OK");

      getLog().debug(++test+"- "+"getting handle of stateful...");
      Handle sfHandle = allTypes.getStateful();
      getLog().debug("OK");

      getLog().debug(++test+"- "+"getting the bean back from the handle...");
      StatefulSession sfBean = (StatefulSession)sfHandle.getEJBObject();
      getLog().debug("OK");

      getLog().debug(++test+"- "+"comparing serialized handles...");
      assertTrue(Arrays.equals(new MarshalledValue(sfHandle).toByteArray(), new MarshalledValue(sfBean.getHandle()).toByteArray()));
      getLog().debug("OK");

      getLog().debug(++test+"- "+"calling business method A on stateful: ");
      getLog().debug("OK, result is " + sfBean.callBusinessMethodA());

      getLog().debug(++test+"- "+"adding the stateful bean as an object in AllTypes..");
      allTypes.addObjectToList(sfBean);
      getLog().debug("OK");

      getLog().debug(++test+"- "+"getting handle of stateless...");
      Handle slHandle = allTypes.getStateless();
      getLog().debug("OK");

      getLog().debug(++test+"- "+"getting the bean back from the handle...");
      StatelessSession slBean = (StatelessSession)slHandle.getEJBObject();
      getLog().debug("OK");

      getLog().debug(++test+"- "+"comparing serialized handles...");
      assertTrue(Arrays.equals(new MarshalledValue(slHandle).toByteArray(), new MarshalledValue(slBean.getHandle()).toByteArray()));
      getLog().debug("OK");

      getLog().debug(++test+"- "+"calling business method B on stateless: ");
      getLog().debug("OK, result is " + slBean.callBusinessMethodB());

      getLog().debug(++test+"- "+"adding the stateless bean as an object in AllTypes..");
      allTypes.addObjectToList(slBean);
      getLog().debug("OK");

      getLog().debug(++test+"- "+"getting handle of entity...");
      Handle eeHandle = allTypes.getEntity();
      getLog().debug("OK");

      getLog().debug(++test+"- "+"getting the bean back from the handle...");
      EnterpriseEntity eeBean = (EnterpriseEntity)eeHandle.getEJBObject();
      getLog().debug("OK");

      getLog().debug(++test+"- "+"comparing serialized handles...");
      assertTrue(Arrays.equals(new MarshalledValue(eeHandle).toByteArray(), new MarshalledValue(eeBean.getHandle()).toByteArray()));
      getLog().debug("OK");
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.