Package javax.ejb

Examples of javax.ejb.Handle


            throw new RemoveException("The remove method is not allowed with an object which is not an handle."
                    + "Primary key is only used for entity 2.1x bean.");
        }

        // Ok, now the given arg is an Handle, get it.
        Handle handle = (Handle) args[0];

        // Get the EJBObject from this handle and call the remove method.
        EJBObject ejbObject = handle.getEJBObject();

        // removing
        ejbObject.remove();
    }
View Full Code Here


         Object arg = mi.getArguments()[0];
         if (arg instanceof Handle)
         {
            if (arg == null)
               throw new RemoteException("Null handle");
            Handle handle = (Handle) arg;
            EJBObject ejbObject = handle.getEJBObject();
            mi.setId(ejbObject.getPrimaryKey());
         }
         else
            mi.setId(arg);
View Full Code Here

         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

    */
   public void testSessionHandle()
         throws Exception
   {
      getLog().debug("+++ testSessionHandle()");
      Handle beanHandle = sessionBean.getHandle();
      ByteArrayOutputStream out = new ByteArrayOutputStream();
      ObjectOutputStream oos = new ObjectOutputStream(out);
      oos.writeObject(beanHandle);
      oos.flush();
      byte[] bytes = out.toByteArray();

      getLog().debug("Unserialize bean handle...");
      ByteArrayInputStream in = new ByteArrayInputStream(bytes);
      ObjectInputStream ois = new ObjectInputStream(in);
      beanHandle = (Handle) ois.readObject();
      StatelessSession theSession = (StatelessSession) beanHandle.getEJBObject();
      theSession.method1("Hello");
      getLog().debug("Called method1 on handle session bean");
   }
View Full Code Here

      during the home lookup and session creation.
      */
      Properties homeProps = new Properties();
      homeProps.setProperty("java.naming.factory.initial", "org.jboss.naming.NamingContextFactory");
      InitialContext ic = new InitialContext(homeProps);
      Handle beanHandle = sessionBean.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();
         StatelessSession theSession = (StatelessSession) beanHandle.getEJBObject();
         theSession.method1("Hello");
         getLog().debug("Called method1 on handle session bean");
      }
      finally
      {
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

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.