|1600 PMP mock questions||1400 CAPM mock questions||800 SCJP 6 mock questions||600 OCAJP 7 mock questions||590 OCPJP 7 mock questions||556 SCWCD 5 mock questions||500 OCEJWCD 6 mock questions||pdfDownload (java,struts, hibernet etc)|
EJB interview questions
!!! EJB interview questions !!!
What is handle and why it is used in EJB?
The handle mechanism allows a client application to maintain a reference to an EJB object. A handle object may be obtained by calling the getHandle() method on the reference to an EJB object. The main interest is that the handle class implements java.io.serializable interface, which means that a handle may be serialized. This allows the client to store the handle, or to pass it to another process. The handle may then be deserialized and used to obtain the reference to the EJB object, by calling the getEJBObject() method.
Handles on session bean objects are valid until the session bean object exists, i.e. their life time is limited to that of the client. Handles on entity bean objects are valid during the complete life time of the entity bean object; this means that such handles may be used by different clients and stored for a long time; the EJB server holding the entity bean objects may be stopped and restarted, the handle will still be valid.
If we consider the entity bean object of the example above (a2), the way to obtain a handle on this object is the following (the handle class is defined in the javax.ejb package):
Handle h = a2.getHandle();The handle object may then be serialized and stored in a file:
ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream("handlefile"));
Then, a client can read the handle, and retrieve the referenced object:
ObjectInputStream in = new ObjectInputStream(new FileInputStream("handlefile"));
Handle h = (Handle) in.readObject();
Account a = (Account)PortableRemoteObject.narrow(h.getEJBObject(),
The EJB Specification allows the client to obtain a handle for the home interface. This allows the client to store a reference to an entity bean's home interface in stable storage. The client code must use the javax.rmi.PortableRemoteObject.narrow(...) method to convert the result of the getEJBHome() method invoked on a handle to the home interface type
Reviews and Comments
PMP, CAPM, PMI is a registered certification mark of the Project Management Institute, Inc
Copyright © www.techfaq360.com 2016