You are on page 1of 70

J2EE Fundamentals

Technology Consulting
Pramati Technologies
Agenda
• The Changing Landscape
• Introduction to J2EE
• J2EE Components
• Containers
• Services
• Connectors
• JMS
• J2EE 1.2 Vs J2EE 1.3
The Changing Landscape

The Desktop Application


The Client-Server Application Client Client

Internet LAN
Web
Server
Database
Server
Rising Complexity
state mgmt
distributed txn
load balancing
failure recovery
multi-thread
connection mgmt
high availability
Application complexity

security

shared db
concurrency

single user

Desktop Network Enterprise apps Web apps


…Raises New Questions ….
• How many users can concurrently use the
system?
• How many objects can be instantiated in a given
time-frame?
• How many transactions can be processed per
second?
New questions surround system scalability
and transaction throughput
… Which Multi-tier May Answer
• Simplify the enterprise application scenario
• Remodel application development in three tiers
– Tier I: Presentation Logic Layer
– Tier II: Business Logic Layer
– Tier III: Data Access Logic Layer
• Move business and data access logic to
same/separate servers
• Keep only presentation logic on Client
Moving to the Server Helps…
• “Power” components no more limited by client capability
• Pooling, sharing of scarce resources now possible from
server-side
• Replication and distribution of application
• High scalability
• Design efficiency only limit to performance
• Support hundreds to millions of concurrent users
– Incremental support from server-side for increasing number of
concurrent users
… But New Challenges Appear
• Multi-threading
• Resource sharing
• Replication
• Load balancing
• Multi-tier applications more difficult to build than
client-server
• Compatibility with widely heterogeneous
middleware services
Enter Application Server
what is an application server ?
• Sits in the middle tier
• Automates complex multi-tier features
• Manages, recycles scarce system resources
– processes, threads, memory, db links, network sessions
• Load balances to share processing across multiple systems
• Access to infrastructure services
– naming/directory, txn, persistence, security
• Specific runtime environment
Where it Fits in!

Client Client

Internet LAN
Web
Server
Application Database
Server Server
Multi-tier Revisited

• Fat client to thin client Presentation


Presentation Logic
Logic

– move business and data access logic to server, Client

– use client to store and run only presentation logic

• Next generation client server Business


Business Logic
Logic
– scalability Data
Data Access
Access Logic
Logic
– performance
– reliability
– Client
reusability
– flexibility Presentation
Presentation Logic
Logic
Business
Business Logic
Logic
Data
Data Access
Access Logic
Logic
Emergence of Standards

• Proprietary Application Servers


• E-Commerce, E-Business Market drive
• Standards come along
– Java 2 platform, Enterprise Edition (J2EE)
• Compliance gains importance
• Standards emerge as Winner
J2EE - Platform for developing
multi-tier enterprise applications.
• Breaks the barriers between existing
enterprise systems.
• Unified standard wraps and embraces
existing resources required by multi-tier
applications
• Component-based model
Why components

• Re-usable parts Presentation


Presentation Logic
Logic
Client
• Collaborative environment
• Focuses skill-sets Application Server

• Lowers development costs Business


Business Logic
Logic
– Lends itself to rapid recasting Data
Data Access
Access Logic
Logic
Client

Presentation
Presentation Logic
Logic
Business
Business Logic
Logic
Data
Data Access
Access Logic
Logic
J2EE Architecture
J2EE application model

• Divides enterprise applications into three


fundamental parts:
– Components
– Containers
– Connectors
J2EE components
• A J2EE component is a self-contained functional
unit that is assembled into a J2EE application and
communicates with other components
• Types
– Client components (web browsers, applets, applications)
– Web components (servlets, jsps)
– Business components (ejbs)
Web Components
• Servlets and JSPs
• a software entity that provides a response to a
request.
• typically generates the user interface for a Web-
based application.
Web Components - Servlet

• A program that extends the functionality of


a Web server.
• receive a request from a client, dynamically
generate the response
Web Components - JSP
• Provides an extensible way to generate
dynamic content for a Web client.
• A JSP page contains
– Template data to format the Web document.
– JSP elements and scriptlets to generate the dynamic
content in the Web document.
• Extensible through the development of
custom actions, which are encapsulated in
tag libraries.
Client Components

• Applets and application clients


• Execute in their own Java virtual machine.
Business Components - EJB
• Server-side technology for developing and
deploying components containing the business
logic of an enterprise application.
• scalable, transactional, and multi-user secure
• Can be of three types
– Session Beans
– Entity Beans
– Message Driven Beans
Session Beans
• provide some service on behalf of a client and usually
exists only for the duration of a single client-server
session.
• performs operations such as calculations or accessing a
database for the client.
• Represents business processes
• Can be of two types
– Stateless
– Stateful
Entity Beans
• Persistent object that represents data maintained
in a data store;
• Focus is data-centric.
• entity bean, its primary key, and any remote
references survive container crashes
• Can be of two types
– Container Managed Persistence
– Bean Managed Persistence
Message Driven Beans

• A message-driven bean is an asynchronous


message consumer.
• Invoked by the container as a result of the
arrival of a JMS message.
What makes it Portable ?

• Code written in Java


• Written to standards
• XML based component descriptors
• Can be deployed on any J2EE
implementation
Containers

• Containers provide the runtime support for


J2EE application components.
• Component are installed in their containers
during deployment
• Interface between a component and the
low-level platform-specific functionality
that supports the component
Containers

• Provided by a J2EE Product Provider


• specification defines a set of standard
services that each J2EE product must
support. J2EE containers provide the APIs
that application components use to access
these services.
EJB Container
• EJB 2.0 implementation
• Full Life Cycle Support for all bean types
– Stateful and Stateless session beans
– Entity beans with container and bean managed persistence
• Resource management
• Concurrency control
• Transaction and security semantics
• Bean Pooling
Web Container
• Controlled environment to run servlets, JSPs,
htmls etc
• Web engine
• Servlet engine
• JavaServer Pages compiler
• Plug-in web container to popular web servers
Web Container

• Performance Optimizations to provide high


scalability and concurrent usage.
• Provides network services (by which requests
and responses are sent), decodes requests, and
formats responses.
• support HTTP as a protocol for requests and
responses,
J2EE Services
• Services provided are
– JAAS (Java Authorization and Authentication Service)
– JTA (Java Transaction API)
– JNDI (Java Naming and Directory Service)
– RMI-IIOP
– JDBC (Java DataBase Connectivity)
– JMS (Java Message Service)
– JavaMail
– JAXP (Java API for XML Parsing)
– J2EE™ Connector Architecture
Naming Services
• provide application clients, enterprise beans, and
Web components with access to a JNDI naming
environment.
• naming environment allows a component to be
customized without the need to access or change
the component’s source code.
• container implements the component’s
environment, provides it to the component as a
JNDI naming context.
Naming Services
• Tech details
– A component creates a javax.naming.InitialContext
object
– looks up the environment naming context in InitialContext
under the name java:comp/env.
– object should be named within a subcontext of the naming
environment according to the type of the object.
– For example
• EJBs are named within the subcontext java:comp/env/ejb
• JDBC DataSource references in the subcontext
java:comp/env/jdbc.
Deployment Services
• Allow components and applications to be
customized at the time they are packaged and
deployed.
• J2EE applications are deployed as a set of nested
units.
• Each unit contains a deployment descriptor
– an XML-based text file whose elements declaratively describe
how to assemble and deploy the unit into a specific environment.
Deployment
– contain many elements related to customizing J2EE platform
services such as transactions and security.
Deployment Services

Deployment Units
• Enterprise JavaBeans modules
– contain class files for enterprise beans and an EJB deployment descriptor.
– packaged as JAR files
• Web modules
– contain JSP files, class files for servlets, GIF and HTML files, and a Web
deployment descriptor.
– Web modules are packaged as WAR files
• Application client modules
– contain class files and an application client deployment descriptor
– packaged as JAR files
Transaction Services
• Transactions – ACID property
– Atomicity
– Consistency
– Isolation
– Durability
• J2EE transactions are flat
• J2EE platform implicitly handles many transaction
details,
– Transaction propagation
– coordinating among multiple transaction managers.
Transaction Services

EJB Transactions
• Bean Managed Transaction Demarcation
– EJB manages all aspects of transaction
• Container Managed Transaction Demarcation
– Container container handles transaction management
– based on the Application Assembler’s deployment instructions
• Entity Beans can use only Container Managed
Transaction Demarcation
Security Services

• Ensure that resources are accessed only by


users authorized to use them.
• Access control involves two steps:
– Authentication
– Authorization
Security Services

Security Methodologies
• Declarative security
• Programmatic security
Security Services
• Authentication
– entity must establish its identity through authentication.
– typically does so by providing authentication data
– entity that can be authenticated is called a principal.
– principal can be a user or another program
• Types of Authentication
– Basic
– Digest
– Form Based
– Certificate
Security Services
• Authorization
– system determines whether the principal is authorized to access
resources based on the security policies
• Security role - logical grouping of users that is
defined by an Application Component Provider or
Application Assembler.
• Each security role is mapped by a Deployer to
principals in the deployment environment.
• Control access to an enterprise bean’s methods by
specifying the method-permission
Service Technologies
• JDBC API
– provides database-independent connectivity between the
J2EE platform and a wide range of tabular data sources.
– Perform connection and authentication to a database
server
– Manage transactions
– Move SQL statements to a database engine for
preprocessing and execution
– Execute stored procedures
– Inspect and modify the results from Select statements
Service Technologies

• Java Transaction API (JTA)


– allows applications to access transactions in a
manner independent of specific implementations.
• Java Transaction Service (JTS)
– specifies the implementation of a transaction
manager which supports JTA
Service Technologies

• JNDI
– Provides naming and directory functionality.
– JNDI is independent of any specific implementations,
applications can use JNDI to access existing naming
and directory services.
• Connector Architecture
– Standard API for connecting the J2EE platform to
enterprise information systems
Communication Technologies

• Internet protocols – TCP/IP, HTTP, SSL


• Remote method invocation protocols –
RMI, JRMP
• Object Management Group protocols - IIOP
• Messaging technologies – JMS, JavaMail
• Data formats – HTML, Image, JAR, Class,
XML
Interoperability

Requirements
• J2EE applications to connect to legacy systems using
CORBA or low-level Socket interfaces.
• J2EE applications to connect to other J2EE applications
across multiple J2EE products, whether from different
Product Providers or from the same Provider, and multiple
J2EE platforms.
Interoperability
Connectors
C
O
Application N
N
Server E
C
T
O
R IBM
S

Database
Connectors - salient features
• Connectors sit beneath the J2EE platform
• Define a portable service API to plug into existing
enterprise vendor offerings
• Provide standard client API
Where it all fits together ?
Platform Roles

• J2EE Product Provider


• Application Component Provider
• Application Assembler
• Deployer
• System Administrator
• Tools Provider
How the Roles Collaborate

Create Assemble Deploy

Bean System
Assembler Deployer
Developer Administrator

Container
Provider

Tools
Provider
J2EE Product Provider

• Implementer and supplier of a J2EE product


that includes the component containers, J2EE
platform APIs etc.
• Free to implement interfaces that are not
specified by this specification
• Must provide application deployment and
management tools.
Application Component Provider

• Multiple roles for Application Component


Providers
– HTML document designers
– document programmers
– enterprise bean developers
• Use tools to produce J2EE applications and
components.
Application Assembler
• Takes a set of components developed by
Application Component Providers and
assembles them into a complete J2EE
application (.ear) file.
• Responsible for providing assembly
instructions describing external
dependencies of the application that the
Deployer must resolve in the deployment
process.
Deployer

• Responsible for deploying web applications


and Enterprise Java Beans components into
a specific operational environment.
• Responsibilities include
– Installation of application on server
– Configuration of application
– Execution of newly installed application
System Administrator

• Responsible for the configuration and


administration of the enterprise’s computing
and networking infrastructure.
• Uses runtime monitoring and management
tools provided by the J2EE Product
Provider to accomplish these tasks.
Tools Provider

• Provides tools used for the


– Development
– Packaging
– Assembling
– Deployment
J2EE Application Life Cycle
Application Assembly & Deployment

• Provide scalable and modular application


assembly, and portable deployment of J2EE
applications into any J2EE product.
Application Assembly & Deployment
JMS
• Standard API for messaging
• Common way for Java programs to create,
send, receive and read an enterprise messaging
system’s messages.
• Asynchronous processing
• Two messaging models
– Point to Point Model
– Publish Subscribe Model
JMS

Point-to-Point Messaging Model

Application Queue Application

JMS

Send Receive
JMS

Publish/Subscribe Messaging Model

Application
Application Topic

Application
JMS

Publish Subscribe
JMS

• A JMS application is composed of


– JMS Clients - java language programs that send and
receive messages.
– Messages - communicate information between its
clients.
– JMS Provider - messaging system that implements JMS
in addition to the other administrative functionality
– Administered Objects - preconfigured JMS objects
created by an administrator for the use of clients.
J2EE 1.2 Vs J2EE 1.3
• J2EE 1.3 requires J2SE 1.3.x
• JMS provider supporting both Topics and Queues is
required.
• All referenced specifications are updated to reference
their most recent versions.
– EJB 2.0
– JSP 1.2
– Servlet 2.3
• Added the following required APIs: JAXP 1.0, JCX 1.0,
JAAS 1.0.
• Requiring support for previous versions as well.
Where J2EE is headed ….

• Management and Deployment Standards


– Security APIs
– Deployment APIs
– Management APIs
• Web Services
Thank You

You might also like