EJB

EJB Projects

EJB Project 1

EJB Examples

EJB EXAMPLE

adplus-dvertising
When we using Session Beans?
Previous Home Next

Session beans are used to write a business logic, In this Session beans implement in a business logic, maintain a conversation state for the client, and model back-end processes or user tasks that perform one or more business operations.

Typical examples include the following:

  • A Session Bean in a human resources application that creates a new employee and assigns the employee to a particular department
  • A Session Bean in an expense reporting application that creates a new expense report
  • A Session Bean in an order entry application that creates a new order for a particular customer
  • A Session Bean that manages the contents of a shopping cart in an e-commerce application
  • A Session Bean that leverages transaction services in an EJB 3 container (removing the need for an application developer to write the transaction support)
  • A Session Bean used to address deployment requirements when the client applications are not colocated on the same server
  • A session bean that leverages the security support provided by the container on the component or method level
  • Session beans can be used in traditional 2-tier or 3-tier architectures with professional/ rich client applications, or in 3-tier web-based applications.
  • These applications can be deployed in different logical and physical tier combinations. In the next section, you will investigate some of the possible combinations.

3-Tier Architecture with Rich Client:

A typical architecture for a session bean in 3 tiers. The 3-tier architectute is a utilized with a rich client front-end application that has some data entry screens used by end users like customer service representatives, bank tellers, and so on. and these client applications can be developed basically using Java Swing technology with the Java Platform, Standard Edition (Java SE), or they can be plain old Java objects (POJOs) that are run from the command line.

The end user launches the client application from his desktop, enters some data, and triggers an event by pressing some user interface component such as a Submit button.

The general workflow may look something like this:

The User action is establishes a connection to the Session bean running in the EJB container using remote method invocation (RMI).

The client application is invokes one or more business methods in the session bean.

The Session bean processes the request and validates data—by interacting with databases, enterprise applications, legacy systems, and so on—to perform a certain business operation or task.

The session bean finally sends a response back to the client application, either through data collections or simple objects that contain acknowledgment messages.

3-Tier Architecture for a Web Application:

This architecture is typically front-ended by a web application and it's running in the browser of a desktop or laptop machine. These days, other types of client devices, such as PDAs, cell phones, and telnet devices, are also being used to run these applications.

The web application running in a browser or mobile device renders the user interface (data entry screens, Submit buttons, etc.) using web technologies such as JavaServer Pages (JSP), JavaServer Faces (JSF), or Java Servlets.

Typical user actions, such as entering search criteria or adding certain items to the web application shopping cart, will invoke/call session beans running in an EJB container via one of the aforementioned web technologies. Once the session bean gets invoked, it processes the request and sends a response back to the web application, which formats the response as required, and then sends the response on to the requesting client device (browser, PDA, telnet, etc.).

Previous Home Next