You are on page 1of 24

Web Component Development with Servlets

Objectives

In this session, you will learn to:


Identify characteristics of Enterprise Java Beans technology,
for EJB 3.0 specification
Identify the use of annotations
Define the Java Platform, Enterprise Edition (Java EE)
Examine the Java EE application architecture
Examine the EJB application creation process
Compare the Java EE application development with traditional
enterprise application development

1
Web Component Development with Servlets
EJB 3.0 Specification

Enterprise JavaBeans (EJB) is defined as a server-side


component framework that builds enterprise-class
distributed component applications in Java.
You can create scalable, reliable, transactional, secure, and
multi-user distributed applications by using EJB.
EJB is designed to support application portability and
reusability across any vendor’s enterprise middleware
services.
The new EJB3.0 API offers ample of simplification over the
previous version EJB API.
Web Component Development with Servlets

Prior to EJB 3.0

The following list briefly describes some of the general EJB


2.x implementation artifact:
Enterprise bean class
EJB object
Remote interface
Local interface
Home interface
Deployment descriptor
Vendor-specific files
The Ejb-jar file

3
Web Component Development with Servlets
EJB 3.0 Enterprise Bean

EJB 3.0 beans are the Plain Old Java Object (POJO) styled
beans as opposed to pre-EJB 3.0 enterprise beans that
used to constitute multiple Java classes and interface per
EJB component.
EJB 3.0 bean has all its code contained in a single Java
class.
EJB 3.0 enterprise bean provides a single business
interface for both local and remote clients.
EJB 3.0 bean provides a bean class that provides definitions
of only the business interface.
EJB 3.0 bean does not have a home interface.
A message-driven bean, in EJB 3.0, doesn’t need a
business interface.

4
EJB 3.0 Enterprise Bean (Contd.)
The bean provider is not required, in EJB 3.0, to implement
the component interface regardless of whether it is needed
or not.
The bean class does not have to implement the component
interfaces, javax.ejb.SessionBean for a session bean or
javax.ejb.MessageDrivenBean for a message-driven bean.

5
Annotations

The use of annotation is one of the most important features


of EJB 3.0 specification.
They have been added to the java language in Java Service
Request 175 (JSR) and made available since the release of
Java 5 platform.
Annotation is defined as the metadata that consists of the
additional definition that can be attached inside your source
file.
They can be used as an alternative to the standard XML
deployment descriptor files.
Java annotations provide information about the code in the
code itself. They are complied and type-checked. They can
be accessed at the runtime by using Java reflection, but
cannot perform computation.

6
Annotations (Contd.)

Annotations can be applied to various elements of the Java


code such as methods, variables, constructors, package
declarations, and so on.
Annotations begin with an @ sign followed by the
annotation name which in turn is followed by annotation
data.
You can use annotations if:
The metadata you are applying changes the design of the
class.
The metadata changes the design of code interacting with the
class.

7
Annotations (Contd.)

Benefits of using annotations in Java:


Annotations are compiled by Java language compiler,
therefore no external tools are required.
Annotations are potable, because the metadata is
standardized.
Annotations on a class can be kept in a class file and retained
for accessing at the runtime.
Drawbacks of annotations:
Annotation cannot form an inheritance hierarchy like interfaces
and classes.
Annotation data member types are restricted to primitive types,
String, Class, enum, annotation types, and arrays of the
preceding types.
You must access permission on the code, to annotate it.

8
Introducing the Java Platform Enterprise Edition (Java EE)

Java EE is the standard for developing portable, robust,


scalable, and secure server-side Java applications.
The Java EE platform consists:
A set of specifications.
Java EE 5 Software Development Kit (Java EE 5 SDK).
Commercial and open source Java EE application servers and
tools.
Java EE components and applications.
Examining the Java EE Application Architecture

The key features of the component-container architecture


are:
Separation of application specific functionality and application
generic functionality.
Components consist of application specific functionality.
Containers consist of the generic functionality common to all
enterprise applications.
Containers provide an execution environment for components.
Containers provide services for components.
Examining the Java EE Application Architecture (Contd.)

The following figure shows the component-container


architecture.

11
Examining the Java EE Application Architecture (Contd.)

The following figure shows the Java EE containers


associated with the Java EE platform.

12
Examining the Java EE Application Architecture (Contd.)

The following table lists the containers, components and the


machines that host the containers.
Container Component Type Container Host

EJB container EJBs EJB container is part of the Java EE


application server.
Web container Servlets and EJB container is part of the Java EE
JavaServer application server.
Pages (JSP™)
Applet Applets Applet container can be a web browser or
container other application that supports the applet
programming model. The applet container is
hosted on a client machine.

Application Application client Application client container is hosted by the


client component client machine.
container
Web browser Web pages Web browser is hosted by the client
machine.
13
Examining the Java EE Application Architecture (Contd.)

The following figure shows the Java EE application


architecture with the inclusion of the application
function-specific components.

14
Examining Java EE Container Services

Java EE services can be grouped into the following


categories:
Deployment-based- Deployment based services might include:
Persistence.
Transaction.
Security.
Injection.
Inherent services- Inherent services include:
Life-cycle.
Threading.
Remote object communication, such as RMI and CORBA.
Examining Java EE Container Services (Contd.)

Vendor-specific functionality- Vendor-specific functionality can


include clustering, which addresses:
Scalability.
Failover.
Load balancing.
API-based services- The supporting services and APIs that are
included in the Java EE platform are:
Java DataBase Connectivity™ (JDBC™) API for database
connectivity
JNDI API
RMI over Internet Inter-Object Request Broker (ORB) Protocol
(IIOP) and the interface definition language (IDL) for the Java
application
JavaMail API and JavaBeans™ Activation Framework (JAF) API
Java EE Connector Architecture
JMS API

16
Examining Java EE Container Services (Contd.)

JMS API
JTA
Java Authentication and Authorization Service (JAAS)
Java API for XML Processing (JAXP)
Web services integration features
JMX
Timer services

17
Examining Java EE Container Services (Contd.)

The following figure shows the accessibility of important


API-based services with Java EE containers.

18
Examine the EJB Application Creation Process

Adhere to the following steps to create an EJB application:


1. Use your preferred object oriented methodology to analyze the
business problem.
2. Analyze the inter-tier communications requirements.
3. Use entity classes to model the persistence data.
4. Use session beans and synchronous service façade.
5. Use the JMS API and message-driven beans.
6. Create the client.
7. Assemble and package the application.
8. Deploy the server-side components.
9. Package and distribute the client.
Examine the EJB Application Creation Process (Contd.)

The following figure shows the creation of Java EE


components and their assembly into Java EE modules.
Comparing Java EE Application Development With Traditional Enterprise Application Development

Java EE platform:
Provides strict separation of the application components from
the general services and infrastructure.
Helps the developers to focus on the application business
logic.
Comparing Java EE Application Development With Traditional Enterprise Application Development (Contd.)

The following figure shows the advantages of using


server-provided services.

22
Summary

In this session, you learned that:


Enterprise JavaBeans (EJB) is defined as a server-side
component framework that builds enterprise-class distributed
component applications in Java.
EJB 3.0 beans are the POJO styled beans as opposed to
pre-EJB 3.0 enterprise beans that used to constitute multiple
Java classes per EJB.
The home interface and the component interface are
eliminated from EJB 3.0 enterprise bean.
Annotation, defined as the metadata, consists of the additional
definition that can be attached to an element within the code to
help further explain.
Summary (Contd.)

Annotations can be applied to various elements of the Java


code such as:
Methods
Variables
Constructors
Package declarations
Java EE is the industry standard for developing portable,
robust, scalable, and secure server-side Java applications.
The Java EE component model relies on both container-based
and platform services.
Java EE services can be grouped into the following categories:
Deployment-based
Inherent services
Vendor-specific functionality
API-based services

24

You might also like