J2EE Architecture Overview

download J2EE Architecture Overview

of 33

Transcript of J2EE Architecture Overview

  • 8/3/2019 J2EE Architecture Overview

    1/33

    J2EE Architecture OverviewJ2EE Architecture Overview

  • 8/3/2019 J2EE Architecture Overview

    2/33

    Unit ObjectivesUnit 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 applicationsDescribe 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 platformDescribe the architecture of J2EE

    Understand the application model for J2EE applications

  • 8/3/2019 J2EE Architecture Overview

    3/33

    Web Browser

    Web Server

    File System

    HTTP Request

    HTTP Response

    Client Network Server

    Web Application EvolutionWeb Application Evolution StaticStatic

    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

  • 8/3/2019 J2EE Architecture Overview

    4/33

    Web Browser

    with JVM

    Web Server

    File System

    HTTP Request

    HTTP Response

    Client Network Server

    Web Application EvolutionWeb Application EvolutionAppletsApplets

    With static HTML, users see passive page presentationswhich are always the same

    Presentation can be improved with Java applets or other

    client-side programs

  • 8/3/2019 J2EE Architecture Overview

    5/33

    Network

    Web Browser

    Web Server

    File System

    HTTP RequestClient Server

    Web Server Plug-in

    Web Container

    Web Application EvolutionWeb Application Evolution ServletsServlets

    Applets cannot access data on back-end systems

    A Web container can provide server-side components (suchas servlets) to generate dynamic content

    Requests for

    dynamic

    resources

    Requests for

    staticresources

    HTTP

    Response

    Dynamic

    response

  • 8/3/2019 J2EE Architecture Overview

    6/33

    Request

    Response

    Web Container

    Servlet

    JavaServer Page

    JavaBean

    service(req,res)

    methods()

    methods()

    forward(req,res)

    RequestDispatcher

    service(req,res)

    Web Application EvolutionWeb Application Evolution JSP PagesJSP Pages

    Servlets give poor separation between business logic andpresentation logicUse JavaServer Pages and JavaBeans to improve separation

  • 8/3/2019 J2EE Architecture Overview

    7/33

    Web Application EvolutionWeb Application Evolution EJBsEJBs

    EJBs:

    Are available remotely over the network

    Encapsulate business rules, application-specific logic, andaccess to data

    Can be used by many different types of application

    concurrentlyRepresent a central repository of business logic

    WebBrowser

    Java

    Application

    HTTPServer

    EJBContainer

    WebContainer

  • 8/3/2019 J2EE Architecture Overview

    8/33

    Web Application EvolutionWeb Application Evolution ScalabilityScalability

    Business requirements often involve high availability

    Improved performance may be required as business grows

    Both these requirements can be achieved through scalingServers can provide redundancy in the system

    By sharing the load between servers, performance can be

    enhanced

    WebBrowser

    HTTP

    Server

    EJBContainer

    Web

    Container

    WebContainer

    EJB

    Container

  • 8/3/2019 J2EE Architecture Overview

    9/33

    The ModelThe Model--ViewView--Controller PatternController Pattern

    Model-View-Controller (MVC) is a design patternVery widely used and regarded as a core concept in J2EE

    development

    Various practical benefits (covered in more detail later)

    Promotes code reuseReduces development time

    The modelRepresents the underlying data and business logic in one place

    Contains no information about the user interface

    The viewThe user interface things the user can see and respond to

    Represent a window into the model there can be many of these

    The controllerConnects the model and the view

    Used to communicate between the model and view

    A fourth layer persistence is often added to the pattern

  • 8/3/2019 J2EE Architecture Overview

    10/33

    J2EE Server

    View

    Controller

    Database

    Model

    Persistence

    MVCMVCApplication to J2EEApplication to J2EE

    Web

    Browser

    Transfer

    Servlet Transfer

    EJB

    Transfer

    ResultJavaBean

    HTML

    Doc

    HTML

    Doc

    5

    2

    3

    4

    6

    7

    1

    Balance

    JSP

  • 8/3/2019 J2EE Architecture Overview

    11/33

    MVCMVC BenefitsBenefits

    Promotes code reuseThe 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 codingReduces development time

    The model, view, and controller can be developed in

    parallelMore maintainable

    The view can be changed without affecting the modelA Web page view can be changed to display a chart instead of a table

    with no change to the model

    The model can be changed without affecting the viewFor example, the way in which an insurance premium is calculated may

    change, but the interface to the business method remains the same

    Data can be moved without affecting the view or modelThe layering concept allows for more flexibility

  • 8/3/2019 J2EE Architecture Overview

    12/33

    J2EE IntroductionJ2EE Introduction

    The Java 2 Platform Enterprise Edition (J2EE) Specificationconsists of:

    The J2EE PlatformA standard platform of containers, services and communications

    The J2EE Compatibility Test SuiteTo verify that a J2EE platform product complies with the standard

    WebSphere Application Server 5.0 is J2EE 1.3 compatible

    WebSphere Application Server 6.0 is J2EE 1.4 compatible

    The J2EE Reference ImplementationFor prototyping J2EE applications and for providing an operational

    definition of the J2EE platform

    The J2EE BlueprintsBest practices for developing multitier, thin-client applications

    J2EE is developed using the Java Community Process

    Collaboration between major enterprise software vendors

    IBM actively contributes to the J2EE development process

  • 8/3/2019 J2EE Architecture Overview

    13/33

    J2EE ComponentsJ2EE Components

    J2EE defines four types of components which must be

    supported by any J2EE product

    AppletsGraphical Java components which typically execute within a browser

    Can provide a powerful user interface for other J2EE componentsApplication client components

    Java programs which execute on a client machine and access other

    J2EE components

    Web componentsServlets and JavaServer Pages

    These provide the controller and view functionality in J2EE

    Enterprise JavaBeansDistributed, transactional components for business logic and databaseaccess

    Component deployment can be managed using deployment

    descriptors (except applets)

    J2EE C i

  • 8/3/2019 J2EE Architecture Overview

    14/33

    J2EE ContainersJ2EE Containers

    J2EE defines four types of container. Containers manage the

    components they contain:

    Applet containerTypically provided by a browser, possibly using the Java Plug-in

    Application client containerA stand-alone Java Runtime Environment

    Web component containerProvided by a J2EE application server

    Enterprise bean (EJB) containerProvided by a J2EE application server

    J2EE components never interact with other J2EE

    components directlyThey depend on the run-time support of containers

    Interaction takes place using services provided by

    containers

    J2EE A hiJ2EE A hit t

  • 8/3/2019 J2EE Architecture Overview

    15/33

    J2EE ArchitectureJ2EE Architecture

    RMI-IIOP

    J2EE M ltiti M d lJ2EE M ltiti M d l

  • 8/3/2019 J2EE Architecture Overview

    16/33

    Enterprise

    Information

    Systems

    Tier

    J2EE Multitier ModelJ2EE Multitier Model

    Relational

    Databases

    Middle TierClient Tier

    Enterprise

    Resource

    PlanningSystems

    Legacy

    Applications

    EJB

    Container

    (EJBs)

    WebContainer

    (Servlets,

    JSPs,

    HTML)

    J2EE

    Services

    (JNDI, JMS,

    JavaMail)

    Java

    Client

    WebClient

    Web

    Client

    Firewall

    J2EE B fitJ2EE B fit

  • 8/3/2019 J2EE Architecture Overview

    17/33

    J2EE BenefitsJ2EE Benefits

    Standards

    A wide range of standard services, components, clients,

    and tools are supported

    Applications are portable across J2EE platforms

    DistributionProvides scalability for performance and availability

    Common services

    Most commonly required services are provided by J2EEservers

    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

    J2EE St d d S iJ2EE St d d S i O iO i

  • 8/3/2019 J2EE Architecture Overview

    18/33

    J2EE Standard ServicesJ2EE Standard Services --OverviewOverview

    The standard services provided in J2EE include the following:

    Hypertext Transfer Protocol (HTTP)

    Remote Method Invocation/Internet Inter-ORB Protocol (RMI-IIOP)

    Java Interface Definition Language (Java IDL)

    Java Transaction API (JTA)

    Java Message Service (JMS)

    JavaMail

    JavaBeans Activation Framework (JAF)

    Java API for XML Parsing (JAXP)Web Services (including JAX-RPC and SAAJ)

    J2EE Connector Architecture (JCA)

    Java Authentication and Authorization Service (JAAS)

    Java Authorization Service Provider Contract for Containers (JACC)Two services previously in J2EE now in J2SE in version 1.4:

    JDBC (relational database connectivity)

    JNDI (Java Naming and Directory Interface)

    J2SE Standard Ser icesJ2SE Standard Services JNDIJNDI

  • 8/3/2019 J2EE Architecture Overview

    19/33

    J2SE Standard ServicesJ2SE Standard Services --JNDIJNDI

    Java Naming and Directory Interface

    Standard Extension JNDI provides directory and naming

    functionality

    The API is independent of the directory

    implementation JNDI enables applications to discover

    and retrieve objects of any type

    JNDI is used to register EJBs and to

    access server-provided objects

    J2SE Standard ServicesJ2SE Standard Services JDBCJDBC

  • 8/3/2019 J2EE Architecture Overview

    20/33

    J2SE Standard ServicesJ2SE Standard Services --JDBCJDBC

    JDBC is an API that provides vendor-

    independent connectivity to a variety ofrelational databases

    JDBC functionality provides basic

    connectivity and core database-related

    classes

    The Standard Extension providesadditional functionality

    The Java Naming and Directory

    Interface (JNDI) can be used to

    manage data sources and connections

    Connection pooling can be provided bydatabase vendors to enhance

    performance, particularly for server

    applications

    Support for distributed transactions,

    including support for the standard two-

    phase commit protocol used by the

    Java Transaction API (JTA)

    J2EE Standard ServicesJ2EE Standard Services CommunicationsCommunications

  • 8/3/2019 J2EE Architecture Overview

    21/33

    J2EE Standard ServicesJ2EE Standard Services --CommunicationsCommunications

    Hypertext Transfer Protocol

    The HTTP client-side API isdefined by the java.netpackage

    The server-side API is defined bythe Servlet and JSP interfaces

    The client- and server-side APIsalso support HTTP over securesockets (HTTPS)

    RMI-IIOP

    Allows RMI-style programmingindependent of protocol

    Implementation supports boththe RMI protocol (JRMP) andCORBA IIOP

    Java IDL Allows J2EE components to

    invoke external CORBA objectsusing IIOP, which may be written

    in any language

    J2EE Standard ServicesJ2EE Standard Services JTAJTA

  • 8/3/2019 J2EE Architecture Overview

    22/33

    J2EE Standard ServicesJ2EE Standard Services --JTAJTA

    Java Transaction API Standard

    Extension JTA specifies interfaces between

    a transaction manager and the

    parties involved in a distributed

    transaction systemThe application, the resource

    manager, and the application

    server

    JTA is implementation-neutral For application developers, theUserTransaction interface is

    the key

    Application developers normally

    want to use container-managed

    transaction demarcation, instead

    of using JTA

    J2EE Standard ServicesJ2EE Standard Services - MessagingMessaging

  • 8/3/2019 J2EE Architecture Overview

    23/33

    J2EE Standard ServicesJ2EE Standard Services --MessagingMessaging

    Java Messaging Service Standard Extension

    The Java Message Service is a standard,vendor-neutral API used to access

    enterprise message systems

    Analogous to JDBC for databases

    Allows for the delivery of asynchronousmessages in an applicationThe JMS client sending the message does

    not have to wait until the message has been

    processedJavaMail 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

    J2EE Standard ServicesJ2EE Standard Services -- JAXPJAXP

  • 8/3/2019 J2EE Architecture Overview

    24/33

    J2EE Standard ServicesJ2EE Standard Services --JAXPJAXP

    Java API for XML Parsing (JAXP)

    JAXP enables applications to parseand transform XML documents

    Independent of XML processor

    implementation

    JAXP includes industry standard

    components DOM (Document Object Model)

    SAX (Simple API for XML Processing)

    XSLT (XML Style Language

    Transformations)

    JAXP adds additional functionalitybeyond these standards

    Java API for XML Remote Procedure

    Call (JAX-RPC)

    Enables Java applications

    incorporating XML-based RPCfunctionality according to the SOAP

    (Simple Object Access Protocol) 1.1

    specification

    Java API for XML Registries (JAX-R)

    APIs to access UDDI Registry

    J2EE Standard ServicesJ2EE Standard Services -- Web ServicesWeb Services

  • 8/3/2019 J2EE Architecture Overview

    25/33

    J2EE Standard ServicesJ2EE Standard Services --Web ServicesWeb Services

    Web Services now part of J2EE 1.4

    JAX-RPC 1.1

    JAX-R

    Web Services for J2EE specification (JSR 109)

    Standard deployment model of Web Servicesapplication within a J2EE Application Server

    WS-I Basic Profile 1.0Guidelines for interoperability in a heterogeneous

    environmentSAAJ 1.1 SOAP with attachments API for Java

    J2EE Standard ServicesJ2EE Standard Services -- ConnectorsConnectors

  • 8/3/2019 J2EE Architecture Overview

    26/33

    J2EE Standard ServicesJ2EE Standard Services --ConnectorsConnectors

    J2EE Connector Architecture (JCA)

    Allows resource adapters thatsupport access to Enterprise

    Information Systems (EIS) to be

    plugged into J2EE products

    Defines a connectionmanagement contract between a

    J2EE server and a resource

    adapter to allow connection

    pooling to EIS systems Defines a transaction

    management contract between

    the transaction manager and an

    EIS that supports transactionalaccessAlso supports transactions that

    are managed entirely by an EIS

    Defines a security contract that

    enables secure access to an EIS

    J2EE Standard ServicesJ2EE Standard Services -- JAASJAAS

  • 8/3/2019 J2EE Architecture Overview

    27/33

    J2EE Standard ServicesJ2EE Standard Services -JAASJAAS

    Java Authentication and Authorization Service

    (JAAS)JAAS can be used for two purposes:

    Authentication of users, to reliably and securely determine

    who is currently executing Java code, regardless of how

    the code is running Authorization of users to ensure they have the

    permissions required to do the actions performed

    JAAS authentication is pluggable Java applications using JAAS remain independent from

    underlying authentication technologies

    JAAS authorization extends the existing Java

    security architecture Access control can be based not just

    on what code is running, but also onwho is running it

    Java Authorization Service Provider Contract

    for Containers (JACC) Allows custom authorization service providers to be

    plugged into the Application Server

    J2EE Standard ServicesJ2EE Standard Services -- ContainersContainers

  • 8/3/2019 J2EE Architecture Overview

    28/33

    J2EE Standard ServicesJ2EE Standard Services ContainersContainers

    Different containers have different service requirements

    !!"!JAAS 1.0

    !!"!Web Services

    !!""JACC

    !!""JCA 1.5

    !!"!JAXP 1.1

    !!""JAF 1.0

    !!""JavaMail 1.3!!""JTA 1.0

    !!"!JMS 1.1

    "!""JSP 2.0"!""Servlet 2.4

    !! (client)"! (client)EJB 2.1

    EJBWebAppletAppl ClientOptional Package

    J2EE InteroperabilityJ2EE Interoperability

  • 8/3/2019 J2EE Architecture Overview

    29/33

    J2EE InteroperabilityJ2EE Interoperability

    The J2EE platform includes interoperability requirements

    J2EE may be used to integrate systemsApplications 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

    The interoperability requirements of J2EE make this

    possibleJ2EE applications can connect to legacy systems using CORBA or low-level socket interfaces

    J2EE applications can connect to other J2EE applications across

    multiple J2EE productsInteroperability is achieved through the use of standard

    protocols for communication and data transfer

    J2EE Platform RolesJ2EE Platform Roles

  • 8/3/2019 J2EE Architecture Overview

    30/33

    J2EE Platform RolesJ2EE Platform Roles

    J2EE defines the following roles

    J2EE product provider Implements a J2EE product that provides containers,

    APIs, and other features

    Application component provider

    Produces application building blocks (HTMLdocuments, EJBs, JSPs, and so forth)

    In many cases this role will be further subdivided

    Application assemblerTakes components developed by component

    providers and assembles them into complete a J2EE

    application

    DeployerDeploys, configures, and runs EJBs and Web

    applications System administrator

    Configures and administers the infrastructure

    Tool provider

    Provides application component development andpackaging tools

    J2EE ImplementationJ2EE Implementation

  • 8/3/2019 J2EE Architecture Overview

    31/33

    J2EE Implementationp

    The J2EE Compatibility Test Suite

    Includes over 15000 tests for J2EE 1.4

    Tests a candidate platform for J2EE compatibilityChecks that all the necessary operations (for example, in required

    APIs) are possibleChecks 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 platformsThe J2EE Reference Implementation

    Provides an operational definition of the J2EE platformThe purpose is to validate the specification and act as a reference for

    J2EE platform providersCan be used by developers to confirm portability

    Included as a binary with the J2EE Software Development

    Kit (free for development and testing)

    Unit SummaryUnit Summary

  • 8/3/2019 J2EE Architecture Overview

    32/33

    yy

    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 aJ2EE platform

    The architecture of J2EE

    The application model for J2EE applications

    CheckpointCheckpoint

  • 8/3/2019 J2EE Architecture Overview

    33/33

    pp

    1. Briefly describe the MVC pattern.

    2. What are the four J2EE containers?

    3. List the full names and purposes of the following J2EEservices: JCA

    JTA

    JAXP JMS