J2EE Architecture Overview
J2EE Architecture Overview
Unit Objectives
Why is this topic important? Servlets and JSP technology are important parts of J2EE In this unit you see how Servlets and JSP fit into the wider picture After completing this unit, you should be able to: Understand the stages in the development of Web applications Describe the model-view-controller (MVC) design pattern Understand the importance of MVC in J2EE applications Describe the components, containers, and services provided by a J2EE platform Describe the architecture of J2EE Understand the application model for J2EE applications
HTTP Response
Organizations want to make their information available to as many people in the world as possible This can be achieved by using the Web, delivering the information as static HTML pages
Server
HTTP Response
Dynamic response
Web Container
Applets cannot access data on back-end systems A Web container can provide server-side components (such as servlets) to generate dynamic content
Web Container
methods()
Servlet
JavaBean
methods()
forward(req,res)
RequestDispatcher
service(req,res)
JavaServer Page Servlets give poor separation between business logic and presentation logic Use JavaServer Pages and JavaBeans to improve separation
EJBs: Are available remotely over the network Encapsulate business rules, application-specific logic, and access to data Can be used by many different types of application concurrently Represent a central repository of business logic
HTTP Server
Web Container
EJB Container
Business requirements often involve high availability Improved performance may be required as business grows Both these requirements can be achieved through scaling Servers can provide redundancy in the system By sharing the load between servers, performance can be enhanced
The model
Represents the underlying data and business logic in one place Contains no information about the user interface
The view
The user interface things the user can see and respond to Represent a window into the model there can be many of these
The controller
Connects the model and the view Used to communicate between the model and view
Model
Transfer EJB Transfer Result JavaBean 3
7
HTML HTML Doc Doc
View
Persistence
MVC Benefits
Promotes code reuse The purpose of the model is to provide business logic and data access in one place This logic can be reused in many applications at the same time without the need for any extra coding Reduces development time The model, view, and controller can be developed in parallel More maintainable The view can be changed without affecting the model
A Web page view can be changed to display a chart instead of a table with no change to the model
J2EE Introduction
The Java 2 Platform Enterprise Edition (J2EE) Specification consists of: The J2EE Platform
A standard platform of containers, services and communications
J2EE is developed using the Java Community Process Collaboration between major enterprise software vendors IBM actively contributes to the J2EE development process
J2EE Components
J2EE defines four types of components which must be supported by any J2EE product Applets
Graphical Java components which typically execute within a browser Can provide a powerful user interface for other J2EE components
Web components
Servlets and JavaServer Pages These provide the controller and view functionality in J2EE
Enterprise JavaBeans
Distributed, transactional components for business logic and database access
J2EE Containers
J2EE defines four types of container. Containers manage the components they contain: Applet container
Typically provided by a browser, possibly using the Java Plug-in
J2EE components never interact with other J2EE components directly They depend on the run-time support of containers Interaction takes place using services provided by containers
J2EE Architecture
RMI-IIOP
Middle Tier
EJB Container (EJBs)
Firewall
J2EE Benefits
Standards A wide range of standard services, components, clients, and tools are supported Applications are portable across J2EE platforms Distribution Provides scalability for performance and availability Common services Most commonly required services are provided by J2EE servers Component model Good separation of development responsibilities Good reuse of code and opportunities to share logic between applications Interoperability Integration with other systems using standard protocols
JTA is implementation-neutral For application developers, the UserTransaction interface is the key Application developers normally want to use container-managed transaction demarcation, instead of using JTA
JavaMail Standard Extension and JAF JavaMail is used to add e-mail capability to applications Includes classes which encapsulate common mail functions and protocols Uses the JavaBeans Activation Framework to encapsulate message data
JAXP adds additional functionality beyond these standards Java API for XML Remote Procedure Call (JAX-RPC) Enables Java applications incorporating XML-based RPC functionality according to the SOAP (Simple Object Access Protocol) 1.1 specification Java API for XML Registries (JAX-R) APIs to access UDDI Registry
Applet " " " " " " " " " " " "
Web ! (client) ! ! ! ! ! ! ! ! ! ! !
J2EE Interoperability
The J2EE platform includes interoperability requirements J2EE may be used to integrate systems
Applications written in different languages, like C++ or Visual Basic Applications running on different platforms, such as PCs or UNIX workstations Stand-alone Java-based applications that are not directly supported by J2EE
Interoperability is achieved through the use of standard protocols for communication and data transfer
Application assembler
Takes components developed by component providers and assembles them into complete a J2EE application
Deployer
Deploys, configures, and runs EJBs and Web applications
System administrator
Configures and administers the infrastructure
Tool provider
Provides application component development and packaging tools
J2EE Implementation
The J2EE Compatibility Test Suite Includes over 15000 tests for J2EE 1.4 Tests a candidate platform for J2EE compatibility
Checks that all the necessary operations (for example, in required APIs) are possible Checks that the behavior of the APIs meets the specification Checks end-to-end compatibility by performing operations on J2EE components and back-end systems and checking the results
Ensures portability between platforms The J2EE Reference Implementation Provides an operational definition of the J2EE platform
The purpose is to validate the specification and act as a reference for J2EE platform providers
Can be used by developers to confirm portability Included as a binary with the J2EE Software Development Kit (free for development and testing)
Unit Summary
This unit covered the following topics: The stages in the development of Web applications The model-view-controller (MVC) design pattern The importance of MVC in J2EE applications The components, containers, and services provided by a J2EE platform The architecture of J2EE The application model for J2EE applications
Checkpoint
1. Briefly describe the MVC pattern. 2. What are the four J2EE containers? 3. List the full names and purposes of the following J2EE services:
JCA JTA JAXP JMS