Q&A

Q1:How many Java classes and interfaces must you write to create an EJB?
A1: The EJB writer must define a remote (or business) interface, a home interface, and the bean implementation itself.
Q2:Why does an EJB run inside a container?
A2: The container provides many services to the EJB, including distribution, lifecycle, naming/registration, transaction management, security/authentication, and persistence. If the container did not exist, you would have to write all the code to interact with these services yourself.
Q3:What issues are there in passing an object as part of a remote method call?
A3: To be passed as an argument or return type, an object must be either serializable or remote. If it is neither of these, an error will occur at runtime. If an object is defined as serializable, a new copy will be created and passed/returned. This can add to the overhead of making the method call, but it is a very useful tool when trying to cut down the amount of network traffic between clients and EJBs (as you will see later on Day 18).
Q4:Most of the deployment descriptor information is straightforward, but what is the difference between a <resource-ref> and an <env-entry>, and what sort of information is contained in each type of entry?
A4: A <resource-ref> is part of a deployment descriptor that defines an external resource used by a J2EE component. The <resource-ref> will define a name and type for a resource together with other information for the container. To access a resource defined in a <resource-ref>, you would use JNDI to look up its name (for example java:comp/env/jdbc/Agency).

An <env-entry>, on the other hand, contains information that is intended only for the EJB itself. It will define a name, a class type and a value. The contents of <env-entry> elements are usually strings. Again, you would use JNDI to look up its name (for example java:comp/env/AgencyName).

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.179.59