session EJB object. Note that this process is (Web hosting companies)
session EJB object. Note that this process is not as fault tolerant as using the handle or primary key of an entity object. If the EJB server goes down or crashes, the stateful session bean will be lost and the handle will be useless. It s also possible for the session bean to time out, which would cause the container to remove it from service so that it is no longer available to the client. Changes to the container technology can invalidate both handles and primary keys. If you think your container technology might change, be careful to take this limitation into account. Primary keys obtain EJB objects by providing unique identification of instances in persistent data stores. A change in the persistence mechanism, however, can impact the integrity of the key. HomeHandle The javax.ejb.HomeHandle is similar in purpose to javax.ejb.Handle. Just as the Handle is used to store and retrieve references to remote EJB objects, the HomeHandle is used to store and retrieve references to remote EJB homes. In other words, the HomeHandle can be stored and later used to access an EJB home s remote reference the same way that a Handle can be serialized and later used to access an EJB object s remote reference. The following code shows how the HomeHandle can be obtained, serialized, and used. // Obtain cabin 100. Context jndiContext = getInitialContext(); Object ref = jndiContext.lookup(”CabinHome”); CabinHomeRemote home = (CabinHomeRemote) PortableRemoteObject.narrow(ref,CabinHomeRemote.class); // Serialize the HomeHandle for the cabin bean. HomeHandle homeHandle = home.getHomeHandle(); FileOutputStream fos = new FileOutputStream(”handle.ser”); ObjectOutputStream outStream = new ObjectOutputStream(fos); outStream.writeObject(homeHandle); outStream.flush(); fos.close(); homeHandle = null; // Deserialize the HomeHandle for the cabin bean. FileInputStream fis = new FileInputStream(”handle.ser”); ObjectInputStream inStream = new ObjectInputStream(fis); homeHandle = (HomeHandle)inStream.readObject(); fis.close(); EJBHome home = homeHandle.getEJBHome(); CabinHomeRemote home2 = (CabinHomeRemote) PortableRemoteObject.narrow(home,CabinHomeRemote.class); Copyright (c) 2001 O’Reilly & Associates
Have all the commercials and ads about web hosting companies given you headache? Relax now.Our recommendation is web hosting comparisons.