Previous Next vertical dots separating previous/next from contents/index/pdf

Overview: Enterprise JavaBeans and EJB Controls

To access the capabilities of an Enterprise JavaBean (EJB) without an EJB control, you must perform several preparatory operations. You must look up the EJB in the JNDI registry, obtain the EJB's home interface, obtain an EJB instance, and then finally invoke methods on the EJB's remote interface to perform tasks.

The EJB control relieves you of all of this preparatory work. Once you have created the EJB control, a web service, custom control or page flow can use the control to access the EJB's business methods directly. The EJB control manages communication with the EJB for you, including all JNDI lookup, interface discovery and EJB instance creation and management.

In short, EJB controls provide an alternative approach that makes it easy for you to use an existing, deployed EJB from within an application. EJB controls support interaction with two of the three types of EJBs, that is, session beans and entity beans. The EJB control does not support direct communication with message-driven EJBs.

Note. You can send requests for messages indirectly to message-driven EJBs using the JMS control instead. However, unlike the EJB control, the JMS control is not used to locate and reference an existing message-driven EJB. For more information, see JMS Control.

A short description of session and entity beans is provided below. To learn more about message-driven beans, J2EE, and EJBs, consult the J2EE programming book of your choice.

Session EJBs

A session EJB is used to execute business tasks for a client on the application server. Stateful session beans maintain conversational state when engaged by a client. That is, conversational state is used to keep track of data between method invocations and to ensure that the bean responds to the correct client. Stateless session beans do not use conversational state and the contract with a client only lasts for the duration of the method invocation. A stateless session EJB is not persistent, so when the client terminates, its session EJB disconnects and is no longer associated with the client.

Entity EJBs

An entity EJB represents a business object in a persistent storage mechanism. Some examples of business objects are customers, orders, and products. The persistent storage mechanism is a relational database. Typically, each entity bean has an underlying table in a relational database, and each instance of the bean corresponds to a row in that table. Unlike session beans, entity beans are persistent, allow shared access, have primary keys, and may participate in relationships with other entity beans.

EJB Interfaces

EJB 2.0 exposes four types of interfaces, called the local home interface, the local business interface (or simply, the local interface), the remote home interface, and the remote business interface (or simply, the remote interface). Client applications can obtain an instance of the EJB with which to communicate by using the remote home interface. The methods in the remote home interface are limited to those that create or find EJB instances. Once a client has an EJB instance, it can invoke methods of the EJB's remote business interface to do real work. The business interface directly accesses the business logic encapsulated in the EJB. Interactions between EJBs defined in the same Workshop for WebLogic application, as well as interactions between EJBs and web services, custom controls or page flows in the same Workshop for WebLogic application, can use the local interfaces instead, which provides a performance advantage over remote interfaces. In other words, the local home and business interfaces define the methods that can be accessed by other beans, EJB controls, web services, and page flows in the same Workshop for WebLogic application, while the remote home and business interfaces define the methods that can be accessed by other applications.

To create an EJB control to represent an EJB, you must know the names of the home and business interfaces. The name for the home interface is typically of the form com.mycompany.MyBeanNameHome or com.mycompany.MyBeanNameLocalHome, and the business interface is typically of the form com.mycompany.MyBeanName or com.mycompany.MyBeanNameLocal. The EJB control uses either the EJB's local interfaces or the remote interfaces. For more information about making an EJB control, see Creating a New EJB Control. To learn more about how EJB controls interact with session and entity EJBs, see Using an EJB Control.

Related Topics

Getting Started with EJB Project

EJB Control

Using WebLogic System Controls

Designing Conversational Web Services

 

Skip navigation bar   Back to Top