WF3815V05_J2EE

download WF3815V05_J2EE

of 27

Transcript of WF3815V05_J2EE

  • 8/8/2019 WF3815V05_J2EE

    1/27

    Welcome to:

    J2EE Platform Technologies

  • 8/8/2019 WF3815V05_J2EE

    2/27

    Unit Objectives

    After completing this unit, you should be able to:Discuss basic Java terminology

    Discuss the importance of the J2EE Platform

    Discuss the J2EE object model and WebSpheres

    implementationDiscuss component technologies

    Discuss service technologies

    Discuss communication technologies

  • 8/8/2019 WF3815V05_J2EE

    3/27

    What is Java?

    Java programs consist of classesClasses are composed of methods

    Methods perform tasks and may return information when

    finished

    Java Program Packaging:Related classes are grouped into Packages

    Classes and/or packages and associated resources are

    distributed in JAR or ZIP filesThe JVM classloader uses its classpath to locate classes

    For classes in JAR files, the JAR filename must be in the

    classpath

    For classes not in a JAR file, the class should be in a

    directory that matches the package name and the parent

    directory must be in the classpath

    Example: classpath=c:\WebSphere\AppServer\Java\

  • 8/8/2019 WF3815V05_J2EE

    4/27

    Java Components

    Java component types:Applications - stand-alone programs, run in own JVM.

    Applets - client side, run in a Web browser

    Servlets - server side, run in a Web container

    JavaBeans - reusable componentsEnterprise JavaBeans (EJBs) - reusable components,

    used for distributed applications, run in an EJB container

    Java Server Pages (JSPs) - Web pages with server sidescripting using Java, run in a Web container

  • 8/8/2019 WF3815V05_J2EE

    5/27

    What is J2EE 1.3?

    Java 2 Platform Enterprise EditionThe specification is at level 1.3

    Essentially it is.....

    an approach to designing, developing, assembling and

    deploying enterprise applicationsa platform with standardized tools and standard ways to

    exchange information

  • 8/8/2019 WF3815V05_J2EE

    6/27

  • 8/8/2019 WF3815V05_J2EE

    7/27

    Applet Container

    Applet

    J2SE

    Application Client

    Container

    ApplicationClient

    J2SE

    Web Container

    JSP

    J2SE

    Servlet

    EJB Container

    Enterprise

    Bean

    J2SE

    HTTP

    SSL

    HTTP

    SSL

    RMI/IIOP

    RMI/IIOP

    Client-SidePresentation

    Server-SidePresentation

    Server-SideBusiness Logic

    Database

    JMS JNDI

    RMI/IIOP

    JDBC

    JTA

    JavaMail

    JAFJMS JNDI

    RMI/IIOP

    JDBC JTA

    JavaMail

    JAFJMS JNDI

    RMI/IIOP

    JDBC

    J2EE Object Model

  • 8/8/2019 WF3815V05_J2EE

    8/27

    API Acronym WAS 5.0

    Enterprise JavaBeans EJB 2.0

    JDBC API JDBC 2.0

    Java Servlet --2.3

    JavaServer Pages JSP 1.2

    Java Message Service JMS 1.0.2

    Java Naming and Directory Interface JNDI 1.2

    Java Transaction API JTA 1.0

    JavaMailTM API -- 1.2

    JavaBeans Activation Framework JAF 1.0

    Java API for XML Processing XML 1.1

    J2EE Connector Architecture J2C/JCA 1.0

    Java Authentication and Authorization Service JAAS 1.0

    J2EE 1.3 APIs

  • 8/8/2019 WF3815V05_J2EE

    9/27

    J2EE Container

    Each component runs inside a container which is provided bythe J2EE platform provider.

    The container provides specific deployment and run-time

    services to the component (Life cycle, security, transactions,

    and so forth).What services are offered depends on the type of container.

  • 8/8/2019 WF3815V05_J2EE

    10/27

    J2EE

    Components

    Communication

    Services

    J2EE Platform Technologies

    ComponentsClient Side ComponentsApplets

    Application Clients

    Server Side ComponentsEJBs

    Web Components (Servlets, JSP)

    Services

    Functions utilized by J2EE componentsAPIs implemented by J2EE platform provider (WebSphere

    Application Server)

    CommunicationEnable communication between collaborating components

    Provided by containers

  • 8/8/2019 WF3815V05_J2EE

    11/27

    Client Side Components - Applets

    GUI components that normally execute in a Web browserCan also execute in other applications or devices that support

    the applet programming model

    Typically used to provide a user interface to J2EE

    applications

    AppletContainer

    Applet

    J2SE

    Application

    ClientContainer

    ApplicationClient

    J2SE

    JNDI

    JMS

    R

    MI/IIOP

    JDBC

    Web Container

    JSP

    J2SE

    JND

    I

    JMS

    RMI/I

    IOP

    JDB

    C

    Servlet

    JTA

    Java

    Mail

    JAF

    EJB Container

    EnterpriseBean

    J2SE

    JNDI

    JM

    S

    RMI/IIOP

    JDB

    C

    JTA

    Java

    Mail

    JAF

    HTTP

    SSL

    HTTP

    SSL

    RMI/IIOP

    RMI/IIOP

    Database

  • 8/8/2019 WF3815V05_J2EE

    12/27

    Client Side Components - Application Clients

    Java Programming Language programsTypically GUI programs

    Have access to all the services on the J2EE middle tier

    AppletContainer

    Applet

    J2SE

    ApplicationClientContainer

    ApplicationClient

    J2SE

    JNDI

    JMS

    R

    MI/IIOP

    JDBC

    Web Container

    JSP

    J2SE

    JND

    I

    JMS

    RMI/I

    IOP

    JDB

    C

    Servlet

    JTA

    Java

    Mail

    JAF

    EJB Container

    EnterpriseBean

    J2SE

    JNDI

    JM

    S

    RMI/IIOP

    JDB

    C

    JTA

    Java

    Mail

    JAF

    HTTP

    SSL

    HTTP

    SSL

    RMI/IIOP

    RMI/IIOP

    Database

  • 8/8/2019 WF3815V05_J2EE

    13/27

    Server-Side Components - Servlets

    Servlets are Java classes that allow application logic to be

    embedded in HTTP request-response process

    J2EE 1.3 requires:

    Servlet 2.3 specification (fully supported by WebSphere

    Application Server V5.0)

    AppletContainer

    Applet

    J2SE

    ApplicationClientContainer

    ApplicationClient

    J2SE

    JNDI

    JMS

    R

    MI/IIOP

    JDBC

    Web Container

    JSP

    J2SE

    JND

    I

    JMS

    RMI/I

    IOP

    JDB

    C

    Servlet

    JTA

    Java

    Mail

    JAF

    EJB Container

    EnterpriseBean

    J2SE

    JNDI

    JM

    S

    RMI/IIOP

    JDB

    C

    JTA

    Java

    Mail

    JAF

    HTTP

    SSL

    HTTP

    SSL

    RMI/IIOP

    RMI/IIOP

    Database

  • 8/8/2019 WF3815V05_J2EE

    14/27

    Server Side Components - Java Server Pages (JSP)

    HTML document:

    Embedded JSP specific tags

    Inline Java Code

    On the server, JSP Page is parsed and compiled into a Java

    ServletWebSphere Application Server V5.0 fully supports JSP 1.2

    AppletContainer

    Applet

    J2SE

    ApplicationClientContainer

    ApplicationClient

    J2SE

    JNDI

    JMS

    R

    MI/IIOP

    JDBC

    Web Container

    JSP

    J2SE

    JND

    I

    JMS

    RMI/I

    IOP

    JDB

    C

    Servlet

    JTA

    Java

    Mail

    JAF

    EJB Container

    EnterpriseBean

    J2SE

    JNDI

    JM

    S

    RMI/IIOP

    JDB

    C

    JTA

    Java

    Mail

    JAF

    HTTP

    SSL

    HTTP

    SSL

    RMI/IIOP

    RMI/IIOP

    Database

  • 8/8/2019 WF3815V05_J2EE

    15/27

    Server Side Components - Enterprise JavaBeans (EJB)

    Entity Beans Session Beans Message-driven

    Beans

    Enterprise JavaBeansEnterprise JavaBeans

    Container-Managed

    PersistenceBean-Managed Persistence

    Stateful

    Stateless

    S Sid C E i J B (EJB)

  • 8/8/2019 WF3815V05_J2EE

    16/27

    Server Side Components - Enterprise JavaBeans (EJB)

    !An example for a Session Bean

    1. Client uses JNDI to find EJB Home

    2. Client uses EJB Home create method to create a session EJB3. The local EJB Home tells the container to create a remote EJB component

    4. The container returns the EJB Object stub to the client

    5. The client then calls local methods on the EJB Object, which are forwarded to the

    remote EJB

    EJB Home

    EJB Object

    Enterprise

    Bean

    EJBHome

    Stub

    EJB

    Object

    Stub

    remote

    client

    container

    EJB server's JVM

    client's JVM

    IIOP

    JNDI

    E tit B

  • 8/8/2019 WF3815V05_J2EE

    17/27

    Entity Beans

    Represent data

    Bean Managed Persistence (BMP)

    the programmer controls data access

    the beans contain the code to store and retrieve data.

    Container Managed Persistence (CMP)the EJB container handles all aspects of data access

    the programmer can concentrate on business logic.

    Entity Beans

    Container-Managed

    Persistence

    Bean-Managed Persistence

    S i B

  • 8/8/2019 WF3815V05_J2EE

    18/27

    Session Beans

    Represent some kind of action

    Stateless

    useful for simple transactions where all information to

    complete the transaction is present at the same time

    high performance and reusableused for single-stage transaction management.

    Stateful

    multiple stages are required to perform the transaction

    Session Beans

    Stateful

    Stateless

  • 8/8/2019 WF3815V05_J2EE

    19/27

    Services: JNDI

  • 8/8/2019 WF3815V05_J2EE

    20/27

    Services: JNDI

    JNDI allows components to store and retrieve named Java

    objects

    J2EE 1.3 requires JNDI 1.2 level

    WebSphere Application Server 5.0 provides an integrated

    JNDI 1.2 compliant name serviceContainers provide two levels of naming schemes:

    "Local", read-only, accessible to components

    "Global", the actual JNDI namespaceLocal names are "bound" to their global counterparts at

    deployment

    JNDI: Binding Example

  • 8/8/2019 WF3815V05_J2EE

    21/27

    }

    ProcessCustomer

    Session Bean

    Customer

    Entity Bean

    Exam

    Entity Bean

    Context initialC = new InitialContext();

    .....

    Object pHomeObject =initialC.lookup("java:comp/env/ejb/Exam")

    ExamHome eHome = (ExamHome)

    PortableRemoteObject.narrow(...);

    Exam exam = eHome.create();

    Boolean passed = exam.grade();

    EJB-refs

    ejb/Customer

    ejb/Exam

    JNDI name

    com/ibm/samples/CustomerHome

    JNDI name

    com/ibm/samples/ExamHome

    Bindings

    Calling

    Calling

    JNDI: Binding Example

    Services: Transactions

  • 8/8/2019 WF3815V05_J2EE

    22/27

    Services: Transactions

    JTA is the API and JTS is the implementation

    JTA is an implementation-neutral interface to distributed

    transactions

    J2EE 1.3 requires JTA level 1.0

    Implemented by combining WebSphere and a JDBC driverthat supports JTA

    Services: JDBC

  • 8/8/2019 WF3815V05_J2EE

    23/27

    ApplicationJDBC Driver

    DriverManager

    Database

    Services: JDBC

    Provides vendor-independent database connectivity

    Provides a generic way to query and update relational tables

    and translate the results into Java datatypes

    JDBC 2.0 is the current level of the specification

    A JDBC driver makes it possible to do three things:Establish a connection to a database

    Send queries and update statements to the data source

    Process the results

    Services: Connector Architecture (J2C)

  • 8/8/2019 WF3815V05_J2EE

    24/27

    Resource Adapter for

    the EIS IMS

    J2EE Component

    J2EE Component

    J2EE Component

    Provided by EIS vendor

    or Third Party vendor

    Common

    Client

    Interface

    API

    EIS(IMS)

    Resource Adapter for

    the EIS CICS EIS

    (CICS)

    Resource Adapter forthe EIS SAP EIS

    (SAP)

    J2EE Server Runtime

    Included with

    WebSphere

    Services: Connector Architecture (J2C)

    Communications: JMS

  • 8/8/2019 WF3815V05_J2EE

    25/27

    Communications: JMS

    JMS - Java Messaging Service

    Reliable interface for asynchronously sending and receivingmessage

    Standard, vendor-neutral API used to access enterprise message

    systemsCore functionality for the implementation of Message-driven

    Beans

    Message-driven Beans consume messages from queues and

    topics that are sent by a JMS client

    EJB Container

    Message DrivenBean

    Business

    Bean

    Application Server

    Queue

    J2EE Component or

    JMS Application

    JMS message

    Communications: RMI and RMI/IIOP

  • 8/8/2019 WF3815V05_J2EE

    26/27

    Communications: RMI and RMI/IIOP

    RMI - Remote Method Invocation

    Specific to Java and only allows objects programmed in

    Java to interact remotely

    Uses a JRMP (Java Remote Messaging Protocol) for

    communicationRMI/IIOP

    Turns local method call into remote method calls

    EJB clients use RMI/IIOP to communicate with other EJBsJ2EE 1.3 supports RMI/IIOP level 1.0

    Unit Summary

  • 8/8/2019 WF3815V05_J2EE

    27/27

    Unit Summary

    Discussed the J2EE object model and how WebSphere

    implements it.

    Discussed how WebSphere implements parts of J2EE 1.3

    specification.

    Discussed the following technologies of J2EE:Component technologies

    Service technologies

    Communication technologies