| Sign In/My Account | View Cart |
J2EE Application Deployment Considerations
Pages: 1, 2, 3
It is common understanding that remote calls are more expensive and take longer to execute than local calls. During a remote procedure call, the local proxy objects must make copies of all of the arguments and transport them over the wire, through RMI, to the remote objects, resulting in increased network traffic and slower response time.
Consider the scenario where the user issues a command through a web page, which in turn invokes the servlet, followed by the processing of the business method in the session bean and entity bean. At least four network operations may occur, two of which are remote EJB calls:

Figure 5. Remote Call Sequence in a Typical Business Operation
In the case where a session bean may call other session beans or multiple entity beans, additional remote calls will be made. If performance is a top priority concern, adjustments must be made in the architecture and design to reduce the number of remote calls or reduce the cost of a remote call.
There are multiple ways to address this performance problem:
If the access interfaces are too fine-grained, it results in excessive network traffic and high latency. One must investigate the architecture and design to ensure the right level of granularity is being used. There are several J2EE design patterns that can control granularity. The two most famous are transfer object and Session Facade. Since the focus of our discussion is on deployment and packaging, please refer to the J2EE Blueprints web site to learn more about these patterns.
J2EE 1.3 introduces the concept of local enterprise beans. This will allow an entity bean to expose a local interface, thus allowing parameters to be passed by reference rather than by value. However, in order for a session bean to access local enterprise beans, the local enterprise beans must be packaged in the same EAR file as the session bean. There are two ways to achieve this:
Some J2EE application servers (e.g., BEA WebLogic) may optimize remote calls between beans (see the WebLogic Reference Document on Classloading) into local calls if the beans are in the same enterprise application. This is especially beneficial if one session bean may call multiple session beans or entity beans. There are drawbacks with this approach as well:
Another area where we should consider is the location of common resources
and libraries. One rule of thumb is that a resource should go together with
the J2EE modules that use it. However, if you have the case where a common
resource is being used by several modules, you may want to place it where it is
accessible by all of the modules. In addition, it is a bad practice to put
resources in your system CLASSPATH as they may cause conflict with
other J2EE modules deploying in the same container. This will also limit your
options in terms of hot deployment.