Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


How to Utilize EJB 2.0 Local References-2 : Page 2




Building the Right Environment to Support AI, Machine Learning and Deep Learning

Two Kinds of References
To access enterprise beans from other enterprise beans, a special mechanism is provided by the container. This mechanism allows a bean provider to refer to the homes of other enterprise beans using "logical" names called EJB references. These references are special entries declared in the application's deployment descriptor that is then used by the container to construct the enterprise bean's environment. In the deployment descriptor, the Deployer binds the EJB references used in the enterprise bean code to the homes of other enterprise beans that the bean needs to access.

Before the EJB 2.0 Specification, there was only one way to reference one enterprise bean from another. That was to use the bean's remote interface, which requires a remote procedure call across the network, just like a normal EJB client. If several beans are collaborating to fill a particular transaction, then the expense of marshalling and unmarshalling the necessary objects across the network can become quite substantial.

With the 2.0 Specification, a new kind of bean interface was defined that would allow beans in the same container to refer to each other directly, without the network overhead of the remote interface. This new mechanism is called a local interface. A local interface is a standard Java interface that does not inherit from RMI. An enterprise bean can be defined as having a local interface, a remote interface, or both.

Specifying a Local Reference for a Bean
A local reference is specified in the same manner that a traditional remote reference is specified - the deployment descriptor. In fact, the deployment descriptor elements for a local reference mirror exactly the elements for a remote reference.

The code snippet below is a look at a typical remote reference:

	<description>This is a Product entity</description>

The code snippet below is a look at a local reference for the same bean:

	<description>This is a Product entity</description>

Here's a quick look at what each of these elements is used for:



The top-level, containing element


An optional element used to provide a comments


The logical name used with the referencing beans code to refer to this reference


The Java type expected by the enterprise bean


The fully qualified class name for the referenced beans local home interface


The fully qualified class name for the referenced beans local interface


An optional element that can be used to create a greater degree of decoupling between the two enterprise beans


Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date