Overview: Enterprise JavaBeans and EJB3 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 an EJB instance, and then finally invoke methods on the EJB's business 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.

In short, EJB controls provide an alternative approach that makes it easy for you to use an existing, deployed EJB from within an application. The EJB3 control only supports interaction with Session type beans.

A short description of session is provided below.

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.

EJB Interfaces

EJB 3.0 exposes two types of interfaces, the local business interface (or simply, the local 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 interface. 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 application, as well as interactions between EJBs and web services, custom controls or page flows in the same Workshop application, can use the local interfaces instead, which provides a performance advantage over remote interfaces. In other words, the local and business interfaces define the methods that can be accessed by other beans, EJB controls, web services, and page flows in the same Workshop application, while the remote and business interfaces define the methods that can be accessed by other applications.

To create an EJB3 control to represent an EJB, you must know the name of the business interface, which 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 EJB3 Control. To learn more about how EJB3 controls interact with session EJBs, see Using an EJB3 Control.


Still need help? Post a question on the Workshop newsgroup.