Introduction to Java EE
Enterprise Application Development
Introduction to Java EE
Outline
Enterprise Applications
What is Java EE
EJBs
A brief technical look at EJBs
Java EE APIs
Page 2
Introduction to Java EE
Enterprise Applications
Applications designed to solve problems encountered by
large enterprises
Used by large corporations, governments, etc.
Useful for even small organizations in an increasingly
networked world
Large-scale Scalable
Reliable Secure
Page 3
Introduction to Java EE
Multi-Tiered Architecture
Functionality of application separated into isolated
functional areas called tiers
3-tiered architecture:
Client tier - client program makes requests to middle tier
Middle tier - handles client requests by processing
application data (business logic business tier)
Data tier - persistent data store
(database / legacy system / etc.)
Page 4
Introduction to Java EE
Multi-Tiered Architecture
Page 5
Introduction to Java EE
Enterprise Applications
Business
Logic
Standalon
e
Network
Network Communication
Communication
Web
Mobile
Client
PLSQL
Client
Client Session
Session Management
Management
Load
Load Balancing
Balancing
Middle Tier
Failover
Failover
In addition to business logic, we have to implement the
other middle-tier services (middleware)
Page 6
Very Complex
Needs technical expertise
Time consuming
Very costly
Tables
Database
Database Connectivity
Connectivity
Authentication
Authentication // Security
Security
Pooling
Pooling // Caching
Caching
Transaction
Transaction Management
Management
Database
Introduction to Java EE
Enterprise Applications
this
y
l
n
o
o
We d
Network
Network Communication
Communication
Client
Client Session
Session Management
Management
Business
Logic
Authentication
Authentication // Security
Security
Pooling
Pooling // Caching
Caching
Transaction
Transaction Management
Management
Database
Database Connectivity
Connectivity
Load
Load Balancing
Balancing
Failover
Failover
Java EE
Page 7
Introduction to Java EE
Java Technology
Programming Language + Platform.
3 Platforms of the Java programming language:
1.
Java Platform, Standard Edition (Java SE)
2.
Java Platform, Micro Edition (Java ME)
3.
Java Platform, Enterprise Edition (Java EE)
Page 8
Introduction to Java EE
Java Technology Java SE
1. Java Platform, Standard Edition (Java SE)
When you think of Java programming language, you think of
Java SE
API
Provides core functionality of Java
Basic types and objects
Input/Output
Networking
Security
GUI development
Database access
XML processing
JVM
Page 9
Development
tools,
deployment
technologies,
other class
libraries
Introduction to Java EE
Java Technology Java ME
2. Java Platform, Micro Edition (Java ME)
API
Cut-down version of Java SE APIs
Basic types and objects
Input/Output
Networking
GUI development
Database access
A small footprint JVM
Page 10
Introduction to Java EE
Java Technology Java EE
3. Java Platform, Enterprise Edition (Java EE)
API
Java EE
For developing and running large-scale,
multi-tiered, scalable, reliable and
secure enterprise applications
API
Java SE
Provides core functionality of Java
Basic types and objects
Input/Output
Networking
Security
GUI development
Database access
XML processing
JVM
Page 11
Development Model
Runtime environments
(containers)
Development tools,
Deployment
Technologies,
other class libraries
Introduction to Java EE
Multi-Tiered Applications
JavaEE Application
Server
Web application
Web browser
Business
Logic
Database
Standalone
Application
Client tier
Page 12
Middle tier
Data tier
Introduction to Java EE
Multi-Tiered Applications...
JavaEE Application
Server
Web application
Web browser
Servlets / JSP
Web Container
Business EJBs
Logic
Database
Standalone
Application
Client tier
Page 13
EJB Container
Business Logic
Middle tier
Data tier
Introduction to Java EE
EJB - Enterprise Java Beans
Session
Beans
Customer
Order
Manager
Inventory
Manager
Customer
Order
OrderNo: 1532
Customer
Order
OrderNo: 1533
Project
Activity
Manager
Inventory
Part
PartNo: BP03
EJB Container
Page 14
Entity Beans
Incoming
Customer
Order
Receiver
Message
Driven Beans
Introduction to Java EE
EJB - Enterprise Java Beans
A managed object
1. Encapsulates business logic
We write them!
2. Container manages the rest
Page 15
Availability across network
Transactions control
Security
Resource Management
We dont bother!
that contains
business logic and
live business data
of an enterprise application.
source: www.developer.com
Introduction to Java EE
Removed in EJB 3.0 !
Types of EJBs
Session Beans
Customer
Order
Manager
Implements Business Logic
Provides Service Methods
Ex:
// business operations
newCustomerOrder()
updateDeliveryAddress()
reserveCustomerOrder()
Internally uses Entity Beans to
deal with data.
Page 16
Replaced with POJO and Java Persistence API
Entity Beans
Customer
Order
Order No: 1003
A bean (class) represents an Entity
An instance represents an instance of
that entity (i.e. directly maps to a row
in corresponding table)
Purely represents data; does not
contain business logic
Ex:
getAmount()
//just getters
setAmount(amount) //and
setters!
Container synchronizes instance data
with database
Persists as long as the record lasts
Introduction to Java EE
Types of EJBs
Session Beans
Customer
Order
Manager
1. Stateless Session Beans
Does not remember state
2. Statefull Session Beans
Remembers state
Entity Beans
Customer
Order
Order No: 1003
1. Container Managed Persistence (CMP)
Container handles persistence
2. Bean Managed Persistence (BMP)
We handle persistence by writing SQL
code
3. Singleton Session Beans
Removed in EJB 3.0 !
Replaced with POJO and Java Persistence API
Page 17
Introduction to Java EE
A Simple Example
A user queries the total
amount of customer
order 1468
Customer Order
Manager
Standalone
Application
Get an instance of
CustomerOrderManager
session bean
Call its method:
calculateTotal (1468)
Customer
Order
Order No: 1468
public int calculateTotal(String orderNo){
Customer
Order Line
Order No: 1468
1.
Get Entity Bean instance of
Customer Order 1468
2.
Get its CustomerOrderLine bean
instances by calling
customerOrder.getLines()
Customer
Order Line
3.
Sum the amounts
customerOrderLine.getAmount()
Line No: 2
4.
}
Return total amount
Display result
Line No: 1
Order No: 1468
Customer
Order Line
Order No: 1468
Line No: 3
Page 18
Middle tier
Database
Introduction to Java EE
A Simple Example
A user queries the total amount
of a customer order
Customer
Order
Order No: 1003
Customer
Order Line
Order No: 1003
Line No: 1
Standalone
Application
Customer
Order Line
Customer Order
Manager
Order No: 1003
Line No: 2
Get an instance of
CustomerOrderMan
ager session bean
Call its
calculateTotalAmou
nt(R2918)
Customer
Order Line
Order No: 1003
Display result
Line No: 3
Database
Page 19
Introduction to Java EE
Java EE Application Model + APIs
Applications,
Applets
Client
Business
Partner / Other
System
IIOP
Web
Application
Mobile
Application
Web Browser
WSDL/SOAP/UDDI
Mobile Device
HTTP
HTTP
JNDI
JTA
Java RMI-IIOP
JAXP
Web Container
JAX-RPC
Servlets
JSPs
JAAS
EJBs
EJB Container
JDBC
JAX-RPC
JMS
JavaMail
Connectors
SQL
Back end
Database
Page 20
JCA
Proprietary Protocol
Existing System
Existing
System //
Legacy
Legacy System
System
Java EE
Application
Server
WSDL/
SOAP/
UDDI
Business
Partner / Other
System
SMTP/
POP3/
IMAP
Message
Oriented
Middleware
Email
Introduction to Java EE
JNDI
Java Naming and Directory Interface
Utilized by J2EE applications to locate resources and
objects in portable fashion
Applications use symbolic names to find object references to
resources via JNDI
The symbolic names and object references have to be
configured by system administrator when the application is
deployed.
Introduction to Java EE
What is a Servlet?
Java objects which extend the functionality of a HTTP
server
Dynamic contents generation
Better alternative to CGI, NSAPI, ISAPI, etc.
Efficient
Platform and server independent
Session management
Java-based
Introduction to Java EE
Servlet vs. CGI
Request CGI1
Request CGI1
Request CGI2
Request CGI2
Request CGI1
Request CGI1
Request Servlet1
Request Servlet1
Request Servlet2
Request Servlet2
Request Servlet1
CGI
CGI
Based
Based
Webserver
Webserver
Child for CGI1
Child for CGI1
Child for CGI2
Child for CGI2
Child for CGI1
Child for CGI1
Servlet
Servlet Based
Based Webserver
Webserver
Servlet1
Servlet1
JVM
JVM
Servlet2
Servlet2
Introduction to Java EE
What is JSP Technology?
Enables separation of business logic from presentation
Presentation is in the form of HTML or XML/XSLT
Business logic is implemented as Java Beans or custom
tags
Better maintainability, reusability
Extensible via custom tags
Builds on Servlet technology
Introduction to Java EE
JEE API References
RMI-IIOP (read as "RMI over IIOP") denotes the Java remote method invocation
(RMI) interface over the Internet Inter-Orb Protocol (IIOP), which delivers Common
Object Request Broker Architecture (CORBA) distributed computing capabilities to
the Java 2 platform. Java RMI-IIOP was developed by Sun Microsystems and IBM,
combining the best features of Java RMI technology with the best features of CORBA
technology.
The Java Naming and Directory Interface (JNDI) is a Java API for a directory service
that allows Java software clients to discover and look up data and objects via a name.
Like all Java APIs that interface with host systems, JNDI is independent of the
underlying implementation. Additionally, it specifies a service provider interface (SPI)
that allows directory service implementations to be plugged into the framework. The
implementations may make use of a server, a flat file, or a database; the choice is up
to the vendor.
JavaServer Pages (JSP) is a Java technology that allows software developers to
create dynamically generated web pages, with HTML, XML, or other document types,
in response to a Web client request. The technology allows Java code and certain predefined actions to be embedded into static content.
Servlets are Java programming language objects that dynamically process requests
and construct responses. The Java Servlet API allows a software developer to add
dynamic content to a Web server using the Java platform.
Page 25
Introduction to Java EE
JEE API References...
Java API for XML-based RPC (JAX-RPC) allows a Java application to invoke a Javabased Web Service with a known description while still being consistent with its WSDL
description. It can be seen as Java RMIs over Web services. JAX-RPC 2.0 was renamed
to JAX-WS 2.0 (Java API for XML Web Services).
JDBC (Java Database Connectivity) is an API for the Java programming language that
defines how a client may access a database. It provides methods for querying and
updating data in a database. JDBC is oriented towards relational databases.
The Java Transaction API (JTA) is one of the Java EE APIs allowing distributed
transactions to be done across multiple XA resources.
The Java API for XML Processing or JAXP (pronounced jaks-p), is one of the Java XML
programming APIs. It provides the capability of validating and parsing XML documents.
Java Authentication and Authorization Service, or JAAS, pronounced "Jazz", is a Java
security framework for user-centric security to augment the Java code-based security.
Page 26
Introduction to Java EE
JEE API References...
Java EE Connector Architecture (JCA) is a Java-based technology solution for
connecting application servers and enterprise information systems (EIS) as part of
enterprise application integration (EAI) solutions. While JDBC is specifically used to
connect Java EE applications to databases, JCA is a more generic architecture for
connection to legacy systems (including databases).
The Java Message Service (JMS) API is a Java Message Oriented Middleware
(MOM) API for sending messages between two or more clients.
JavaMail is a Java API used to receive and send email via SMTP,POP3 and IMAP.
Page 27