Local Versus Remote EJB Clients

   

Local Versus Remote EJB Clients

An EJB client is an object that needs to interact with an enterprise bean in order for the bean to perform some service on behalf of the client. This interaction is in the form of the client invoking operations on the bean's component interface. The component interface of an enterprise bean defines the methods that are available for clients to invoke.

With earlier versions of the EJB specification, only invocations on a remote interface were defined. However, with the release of version 2.0, there are two types of EJB component interfaces, local and remote. Depending on your applications needs and requirements; you may choose to expose your enterprise beans to local clients, remote clients, or, in some cases, both.

Local EJB Clients

Local clients are always located within the same Java Virtual Machine (JVM) as the enterprise bean. The client can invoke methods on the bean, just as it would on any other Java object using normal Java method call semantics. However, exposing an enterprise bean to a local client does have a few drawbacks in terms of losing location transparency. This is due to the fact that a local client and the enterprise bean that it accesses must always be collocated. Collocated means that an enterprise bean and its local client must be deployed within the same JVM. However, using local clients can have positive impacts on the performance of your application. The arguments and results of method calls for local clients are passed by reference, rather than by value. This reduces the amount of network latency and overhead required to copy the arguments and results for the method's invocations. Generally, a local client of an enterprise bean will be another enterprise bean.

Remote EJB Clients

A remote client to an enterprise bean does not have to be located within the same JVM to access the methods of the bean. It can, and usually does, reside in a different JVM on another physical machine. The remote client does not care about the physical location of the bean that it accesses. This is sometimes referred to as location transparency.

The remote client can be another enterprise bean residing in the same or different location, or it also can be a Web application, applet, or Java console program. The remote client can even be a non-Java program, such as a CORBA application written in C++. The client uses a special remote protocol to access the enterprise bean that is much different than the normal semantics that a local client uses. The next section describes this remote protocol in detail.



Special Edition Using Enterprise JavaBeans 2.0
Special Edition Using Enterprise JavaBeans 2.0
ISBN: 0789725673
EAN: 2147483647
Year: 2000
Pages: 223

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net