j2ee overview
DESCRIPTION
J2EE Overview. Objectives. In this session, you will learn to: Identify the characteristics of different Java Platforms Identify the challenges of an enterprise application Describe J2EE architecture Define the role of various J2EE technologies. Java 2 Editions. - PowerPoint PPT PresentationTRANSCRIPT
J2EE Overview ver 1.0 Page 2© Wipro TechnologiesTalent Transformation
Objectives
In this session, you will learn to:
• Identify the characteristics of different Java Platforms
• Identify the challenges of an enterprise application
• Describe J2EE architecture
• Define the role of various J2EE technologies
J2EE Overview ver 1.0 Page 4© Wipro TechnologiesTalent Transformation
Issues in Enterprise Applications
• Transactions
• State management
• Multithreading
• Resource pooling
• Security
J2EE Overview ver 1.0 Page 5© Wipro TechnologiesTalent Transformation
Java 2 Platform, Enterprise Edition
J2EEJ2EE
RMI
JNDI
JDBC
JavaMail
Servlets JSP Java IDL
EJB
JMS
JTA
Connectors
XML
Java 2: Standard ed.
J2EE Overview ver 1.0 Page 7© Wipro TechnologiesTalent Transformation
J2EE
Services Java Technology
Web Servlets/ JSPs (HTML/ XML)
Database Access Java DataBase Connectivity (JDBC™)
Naming And Directory Java Naming and Directory Interface
Messaging Java Message Service (JMS)
Email Access JavaMail™
Protocol JavaIDL, Remote Method Invocation
(CORBA compatible)
Transaction Object Transaction Service (OTS),
Java Transaction Service (JTS),
Java Transaction API (JTA)
J2EE Overview ver 1.0 Page 8© Wipro TechnologiesTalent Transformation
Naming Services
• Provide J2EE components with access to a JNDI naming environment– J2EE component locates its environment naming context
using JNDI interfaces
J2EE Overview ver 1.0 Page 9© Wipro TechnologiesTalent Transformation
Java Naming and Directory Interface
• A standard for Naming and directory services
• EJB strictly relies on JNDI for looking up distributed components across the network
• e.g. Novell’s NDS and the internet standard LDAP– Each one is accessed differently
– Stores info in a proprietary way
• JNDI bridges the gap between different directory services: provides portable interface
J2EE Overview ver 1.0 Page 11© Wipro TechnologiesTalent Transformation
Transaction Scenario...
What’s Wrong with This Code?try {// Withdraw funds from account 1}catch (Exception e) {// If an error occurred, do not proceed.return;} }try {// Otherwise, deposit funds into account 2
}catch (Exception e) {// If an error occurred, do not proceed,// and redeposit the funds back into account 1.return;}
J2EE Overview ver 1.0 Page 12© Wipro TechnologiesTalent Transformation
Transaction Definition
• An atomic unit of work
• Can consist of multiple operations from multiple objects
• Example: withdrawing money from an account using an automatic teller machine
• Can support the following features:– Distribution across a network
– Two - phase commits
– Nested transactions
J2EE Overview ver 1.0 Page 13© Wipro TechnologiesTalent Transformation
Transaction Participants
• Resource has transactional state– Example: Database connection
• Resource manager can commit and rollback– Example: JDBC driver
• Application server assists in managing usage of transactional resources by beans– Example: EJB server
J2EE Overview ver 1.0 Page 14© Wipro TechnologiesTalent Transformation
Transaction Participants
• Transaction manager:– Controls state of transaction, two- phase commit
– Coordinates/ controls all resource managers within transaction
• Transactional application obtains a limited access to the transaction manager:– Client application
– Enterprise bean
J2EE Overview ver 1.0 Page 15© Wipro TechnologiesTalent Transformation
Transactions and the ACID Properties
• As we have seen, exceptions are not enough for enterprise computing– Code is non- deterministic
• Transactions guarantee determinism
• Transactions give you four virtues, called the ACID properties:– Atomicity
– Consistency
– Isolation
– Durability
J2EE Overview ver 1.0 Page 16© Wipro TechnologiesTalent Transformation
Transaction Services
• J2EE transactions are flat
• J2EE platform implicitly handles many transaction details
• A Transaction is a unit of work that makes a set of guarantees about its execution
J2EE Overview ver 1.0 Page 17© Wipro TechnologiesTalent Transformation
Java Transaction API (JTA) and Java Transaction Service (JTS)
• JTA: – High level transaction interface: EJB clients use JTA
– Required to perform transactions in Java
• JTS:– Low-level transaction interface: EJB uses behind the scene
– Makes possible multiple vendors to collaborate for distributed transactions
J2EE Overview ver 1.0 Page 18© Wipro TechnologiesTalent Transformation
Service Technology
• Provide access to database, transactions, naming and directory services and enterprise information systems
• JDBC API
• Java Transaction API and Service
• Java Naming and Directory Interface
• Connector Architecture
• Communication Techniques– Internet protocols
– RMI protocols
– OMG protocols
– Messaging technologies
J2EE Overview ver 1.0 Page 19© Wipro TechnologiesTalent Transformation
Introduction to RMI
• Distributed Computing
• RPC
• RMI
J2EE Overview ver 1.0 Page 20© Wipro TechnologiesTalent Transformation
Features of RMI
• Remote invocations of methods on objects in different JVM’s
• Simple to write reliable distributed applications
• RMI is transparent
J2EE Overview ver 1.0 Page 21© Wipro TechnologiesTalent Transformation
RMI Architecture
Client Program
Stub
RRL
Transport Layer
Server Program
Skeleton Layer
RRL
J2EE Overview ver 1.0 Page 22© Wipro TechnologiesTalent Transformation
Writing a Simple RMI program
• Write the Remote Object program//Product.javaimport java.rmi.*;import java.rmi.server.*;interface Product extends Remote{public String getDescription() throws RemoteException;}
J2EE Overview ver 1.0 Page 23© Wipro TechnologiesTalent Transformation
Writing a Simple RMI program
2) Write the Remote Server Program
//ProductImpl.javaimport java.rmi.*;import java.rmi.server.*;public class ProductImpl extends UnicastRemoteObject implements Product{ private String str;
public ProductImpl(String d) throws RemoteException{str = d;
}public String getDescription() throws RemoteException{
return "Product Name : "+str;}
J2EE Overview ver 1.0 Page 24© Wipro TechnologiesTalent Transformation
Writing a Simple RMI program
2) Write the Remote Server Program …contnd
public static void main(String a[]){ try{
ProductImpl p1= new ProductImpl("Washing Machine");ProductImpl p2= new ProductImpl("Microwave Oven");
Naming.rebind("wash",p1);Naming.rebind("oven",p2);
}catch(Exception e) {System.out.println("ERROR: "+e);e.printStackTrace();
}}}
J2EE Overview ver 1.0 Page 25© Wipro TechnologiesTalent Transformation
Writing a Simple RMI program
3) Write the Client program
import java.rmi.*;import java.rmi.server.*;public class ProductClient{
public static void main(String a[]){try{
Product c1=(Product)Naming.lookup("wash");Product c2=(Product)Naming.lookup("oven");System.out.println(c1.getDescription());System.out.println(c2.getDescription());
}catch(Exception e){System.out.println("Error: "+ e);}System.exit(0);}}
J2EE Overview ver 1.0 Page 26© Wipro TechnologiesTalent Transformation
JavaMail
• The JavaMail API allows your applications to use e-mail capabilities
• JavaMail defines a set of interfaces to which you write your application code, and those interfaces shield your code from the specific protocols or mail service implementations used
• Based on JavaBeans Activation Framework (JAF) to encapsulate message data and to handle interactions with that data
J2EE Overview ver 1.0 Page 27© Wipro TechnologiesTalent Transformation
Java Messaging Service
• JMS allows Java programs to exchange messages with other Java programs sharing a messaging system.
• Messaging systems are sometimes called Message-Oriented Middleware (MOM)
• JMS API enables communication that is :– Asynchronous
– Reliable
J2EE Overview ver 1.0 Page 28© Wipro TechnologiesTalent Transformation
Real Time Example
• Automobile manufacturer– The inventory component can send a message to the factory
component when the inventory level for a product goes below a certain level, so the factory can make more cars.
– The factory component can send a message to the parts components so that the factory can assemble the parts it needs.
– The parts components in turn can send messages to their own inventory and order components to update their inventories and order new parts from suppliers.
– Both the factory and parts components can send messages to the accounting component to update their budgets.
– The business publishes updated catalog items to its sales force and web site.
J2EE Overview ver 1.0 Page 29© Wipro TechnologiesTalent Transformation
JMS Architecture
• JMS provider – is a messaging product that
implements the JMS interfaces and provides administrative and control features
• Administered objects– pre-configured JMS objects
created by an administrator for the use of clients.
• JMS clients– the programs or components
written in the Java programming language that produce and consume messages.
• Messages– the objects that communicate
information between JMS clients.
J2EE Overview ver 1.0 Page 32© Wipro TechnologiesTalent Transformation
Enterprise JavaBeans
• Enterprise JavaBeans is an architecture for component- based distributed computing:– Customizable at deployment time
– Deployed on a compatible application server
– Portable to other application servers
• Enterprise Beans are components of distributed transaction - oriented enterprise applications
J2EE Overview ver 1.0 Page 33© Wipro TechnologiesTalent Transformation
Defining EJB Technology
• EJB servers provide core services to server components:– Transaction
– Security
– Concurrency
– Naming
– Persistence
• EJB technology enhances:– Simplified access to services
– Portability of components across server platforms
J2EE Overview ver 1.0 Page 34© Wipro TechnologiesTalent Transformation
Defining EJB Technology
• Is a server component specification (for vendors)
• Separates and defines integration of development stages:– Component creation
– Application assembly
– Application deployment
J2EE Overview ver 1.0 Page 36© Wipro TechnologiesTalent Transformation
EJB Programming Paradigm
• Declarative programming and customizing
J2EE Overview ver 1.0 Page 37© Wipro TechnologiesTalent Transformation
EJB Programming Paradigm
• Deploying
J2EE Overview ver 1.0 Page 38© Wipro TechnologiesTalent Transformation
EJB Architecture Overview
• Uniform client access whether local or remote
• Home object is a factory for EJBs
• EJB object is the remote object for accessing EJBs
J2EE Overview ver 1.0 Page 40© Wipro TechnologiesTalent Transformation
EJB Server
• Services:– Transaction support
– Data access
– System resource
– Namespace
• Industry support:– Application/ middleware servers
– Database servers
J2EE Overview ver 1.0 Page 41© Wipro TechnologiesTalent Transformation
EJB Container
• Can contain multiple Bean classes or homes– Often created using code generation by tools
– Is normally provided by EJB server vendor
• Is not visible to the client
• Is implemented in different ways by different vendors
J2EE Overview ver 1.0 Page 42© Wipro TechnologiesTalent Transformation
EJB Container
• Provides some standard services:– Persistence
– Transaction control
– Security
– EJB instance lifecycle management
– EJB instance identification
J2EE Overview ver 1.0 Page 43© Wipro TechnologiesTalent Transformation
Home Interface
• Factory interface for the bean:– Interface provided by EJB developer
– Class generated by vendor tool
• One factory class per bean class
• Factory instance is installed into the server’s naming service
J2EE Overview ver 1.0 Page 45© Wipro TechnologiesTalent Transformation
Remote Interface
• Interface is provided by bean developer.
• Implementation is provided by container tools, which include:– Stubs and skeletons
– The EJB Object
J2EE Overview ver 1.0 Page 46© Wipro TechnologiesTalent Transformation
EJB Object
• The EJB Object is a wrapper object that acts as a proxy to the EJB instance.– Interface provided by Bean developer
– Implementation class generated by vendor tool
• Each business method has a corresponding wrapper method in the EJB Object– Wrapper method implements container- provided services
J2EE Overview ver 1.0 Page 47© Wipro TechnologiesTalent Transformation
Stubs and Skeletons
• Stub is downloaded from server
• Communication between stub and skeleton can be proprietary, yet EJB code is still portable
J2EE Overview ver 1.0 Page 49© Wipro TechnologiesTalent Transformation
J2EE Components and Containers
J2EE Overview ver 1.0 Page 50© Wipro TechnologiesTalent Transformation
Summary
In this session, you learnt to:
• Identify characteristics of different Java Platforms
• Identify the challenges of an enterprise application
• Describe J2EE architecture
• Define the role of various J2EE technologies