Discuss this tutorial. Printable version (PDF).
Go to Contents page. Go to previous page. Go up a level. Go to next page.

 

Design


As described in the Concepts section, local interfaces can improve the performance of an EJB-based application, but there are trade-offs. Up-front planning is essential, taking into account deployment scenarios, evaluating the need for component reuse, deciding which interfaces will be local, which will be remote. Also, local and remote interfaces use different calling semantics: remote interfaces pass parameters by value, while local interfaces pass them by reference. Clients must be designed and built accordingly.

OTN developers identified several areas where local interfaces could be used in the FBS 10g. In this application, AlertsBean, PreferencesBean, TradeDetails, and PortfolioBean are targets of a container-managed relationship with UserAccount. UserAccount is a local entity bean that has 1:N relationships with Alerts, Preferences, TradeDetails, and Portfolio records. (For more information about container-managed relationships, see the Using Container-Manged Relationships tutorial.) Therefore, per the EJB specification, the beans must expose local interfaces. They must also reside in the same EJB JAR file. This design, in addition to meeting the requirements for container-managed relationships, improves the performance of the application because local method calls are generally faster than remote calls.

Other factors can influence the choice of local or remote interfaces. In addition to container-managed relationships, beans that are tightly-coupled logically are good candidates for local interfaces. In the FBS 10g, a Preference bean is always associated with a User bean, so it makes sense to co-locate them and have them enable access via local interfaces. Another factor is the type of client. If a bean is only going to be accessed by Web components or other beans, consider local interfaces; otherwise, implement remote interfaces because they enable access from anywhere. Similarly, if the application design calls for beans distributed across multiple servers, go with remote interfaces. If you're not certain about where a bean will be deployed or how it will be accessed, choose remote interfaces to keep your options open.

Finally, a bean can expose both remote and local interfaces, but such implementations are rare. To watch a viewlet that shows how the FBS 10g uses local interfaces, browse to:


Discuss this tutorial. Printable version (PDF).
Go to Contents page. Go to previous page. Go up a level. Go to next page.
E-mail this page
Printer View Printer View
Oracle Is The Information Company About Oracle | Oracle RSS Feeds | Careers | Contact Us | Site Maps | Legal Notices | Terms of Use | Privacy