Understanding EJB Roles

The EJB specification defines different roles in the development, assembly, and deployment of enterprise applications. The EJB architecture simplifies the development of complex business systems by dividing this process into six distinct roles, each with a specific task and objectives. These six roles address application development, infrastructure services, and deployment issues. Figure 1.5 illustrates the different roles involved in developing and deploying EJB components and applications.

Figure 1.5. The EJB roles and their responsibilities.


In the next few sections, we will discuss these roles in more detail.

Application Development Roles

The task of building large component-based applications is typically divided into developing new components followed by the assembly of those components with existing reusable components. Some of the existing components could be components-off-the-shelf (COTS). The EJB architecture makes a clear distinction between the EJB developer (bean provider) and application assembler, even when, as in many cases, these two roles are combined and performed by one person or team.

EJB Developer (Bean Provider)

The EJB developer is typically a domain expert with knowledge of the business rules, such as the financial or pharmaceutical industry. The EJB developer implements the business logic represented by the EJB's business methods, and defines the EJB's interfaces and deployment descriptor. The EJB developer defines a client view of an EJB. The client view is unaffected by the container and server in which the EJB is deployed. This ensures that both the EJBs and their clients can be deployed in multiple execution environments without code changes or recompilation.

Application Assembler

The application assembler is a domain expert who assembles an application from many building blocks (such as EJBs, servlets, JSP, applets, and Java clients) to complete the application. An assembler is primarily concerned with the interfaces to EJBs (the home and remote interfaces) and with the EJB's deployment descriptor. The assembler is responsible for configuring both the security and transactional aspects of the EJBs in the deployment descriptor.

Infrastructure Roles

The infrastructure roles address the container, application server, and deployment tools. These tasks are typically provided by a vendor with expertise in distributed infrastructures and services who implements a platform that facilitates the development of distributed applications and provides a runtime environment for these applications.

EJB Container and Server Provider

This is an expert in distributed systems, transactions, and security who provides deployment tools for EJBs and runtime support for these deployed instances. A container is a runtime system for one or multiple EJBs that provide common services such as transaction, security, and lifecycle management. A container includes code and a tool that generates code particular to a particular enterprise bean. It also provides tools to deploy an EJB and a means for the container to monitor and manage the application.

Deployment Roles

The EJB specification makes a clear distinction between the deployment roles because the cost of application deployment is much higher than application development.

Deployer

The deployer (a new word for most dictionaries) adapts an application, composed of a number of EJBs, to a target operation environment by setting the properties and behaviors of the EJB. For example, the deployer sets properties in the deployment descriptor that determine transaction and security policies. The deployer also integrates the application with existing enterprise monitoring and management software. The deployer must be familiar with both the application operational requirements and the application server environment.

System Administrator

The system administrator configures and administers the enterprise applications and infrastructure, including the application server, networking, databases, and Web servers. The administrator monitors the running application and takes appropriate actions in the event that the application behaves abnormally. Typically, an administrator uses enterprise monitoring and management tools that are connected to the application by the deployer through the hooks provided by the container.

Note

A traditional application programmer now becomes an EJB developer and, possibly, an application assembler. These tasks enable the programmer to focus on the business problem and business logic. The deployer defines and sets the deployment policies when installing the EJB. The complexity of implementing mechanisms for executing the deployment policies is delegated to the container provider. Although distributed applications remain complex, the application programmer's job becomes easier because much of the complexity is addressed by EJB server and container providers.


The various roles are not always performed by different people. In large applications, different individuals or teams might execute each of the roles. In some scenarios, such as small applications, a single person might perform multiple roles. During your 21-day journey of learning EJB, you'll execute multiple roles such as enterprise bean provider, application assembler, deployer, and system administrator. You'll use the EJB container and server provided by BEA's WebLogic Server or the JBoss organization's open source code application server, JBoss.

Deployment Process

The efforts involved in developing and deploying an EJB require the following multi-step process:

1.
Define all business methods in the component interface. This can be either a remote or local interface, depending on the design strategy you implement. A remote interface enables you to make your applications distributed in nature. A local interface allows access to the EJB from the same JVM.

2.
Define the home interface of your EJB, which includes all the life-cycle management methods of the EJB, such as creation, location, and removal of the EJB.

3.
Implement the business methods in the bean class. Other callback methods might be required for some types of EJB.

4.
Create your EJB's deployment descriptor, which allows for the declaration of the EJB type, and transaction and security attributes.

5.
Compile your EJB classes and interfaces.

6.
Package the compiled EJB objects into a JAR file along with the deployment descriptor.

7.
Deploy the EJB into the EJB container.

For all the examples in this book, we provide a script to carry out all the steps from 5–7. In addition, we provide a script to run the EJB client we develop in each day of our journey to learn EJB.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.38.92