Fang Fang 05172005

Embed Size (px)

Citation preview

  • 8/4/2019 Fang Fang 05172005

    1/21

    J2EE Architecture and Design Patterns

    Student: Fang FangAdvisor: Dr. Glen Qin

    Date: 05/14/2005

  • 8/4/2019 Fang Fang 05172005

    2/21

    Agenda

    Introduction to Architecture

    J2EE Architecture Diagram

    Distributed Programming Serviced

    Modular-Based Development

    J2EE Application Deliverable

    J2EE Standards

    Patterns Arose from Architecture

    Gang of Four Patterns

    Q & A

  • 8/4/2019 Fang Fang 05172005

    3/21

    Introduction to Arthitecture

    Architecture is the overall structure of a system, and it cancontain subsystems that interface with other subsystems

    Architecture versus Design (level of details)

    Architecture considers bunch of *abilities

    CapabilityAvailability

    ReliabilityManageability and FlexibilityPerformanceScalabilityExtensibility, Validity, ReusabilitySecurity

  • 8/4/2019 Fang Fang 05172005

    4/21

    J2EE Application I J2EE Application II

    Client tier

    Web tier

    Business tier

    EIS tier

    Clientmachine

    J2EEServer

    machine

    DataBaseServer

    machine

    ApplicationClient

    Dynamic HTMLpages

    JSP/Servlet

    EnterpriseBeans

    DatabaseDatabase

    EnerpriseBeans

    Multi-tiered J2EE applications

  • 8/4/2019 Fang Fang 05172005

    5/21

    Distributes Programming Services

    Naming and Registration (JNDI)

    Remote Method Invocation (RMI)

    Protocols

    Distributed Object Frameworks

    Between user interface and business tiers HTTP, RMI, CORBA, DCOM, JMS

    Between business and persistence tiers JDBC, IDL to COM bridge, JMS,plain socket, native APIs via JNIembedded in resource adapters

    - CORBA- Native Language Integration- Java/RMI- DCOM

    XML

  • 8/4/2019 Fang Fang 05172005

    6/21

    EJB Distributed Nature (I)

    EJB Container

    BeanEJBObject

    EJBHome

    RemoteStub

    Home Stub

    Client

  • 8/4/2019 Fang Fang 05172005

    7/21

    EJB Distributed Nature (II)

  • 8/4/2019 Fang Fang 05172005

    8/21

    J2EE Modular-Based Development

    Presentation tier developer

    Bean provider

    Application assembler

    Component provider

    Application server provider

    EJB container provider

    Staff be categories into different roles:

  • 8/4/2019 Fang Fang 05172005

    9/21

    J2EE Application Deliverable

    Web archive(.war)

    web.xml

    EJB archive(.jar)

    ejb-jar.xml

    Client archive(.car)

    application-client.xml

    Enterprise archive (.ear)application.xml

  • 8/4/2019 Fang Fang 05172005

    10/21

    Deployment Descriptor Sample

    ...

    This role represents everyone who is allowed full accessto the Cabin EJB.everyone

    everyoneCabinEJB*

    CabinEJB*

    Required

  • 8/4/2019 Fang Fang 05172005

    11/21

    J2EE Standards

    CTS

    J2EE SDK

    Contains following specs

    Together with below's offerings

    EJB spec

    Servlet spec

    JSP spec

  • 8/4/2019 Fang Fang 05172005

    12/21

    Patterns Arose from Architecture andAnthropology - Christopher Alexander

    Is quality objective?

    How do we get good quality repeatedly?

    Look for the commonalities

    ...especially commonality in the features of the problem tobe solved

  • 8/4/2019 Fang Fang 05172005

    13/21

    Moving from Architectural to SoftwareDesign Patterns

    Adapting Alexander for software

    The Gang of Four did the early work on design patterns(Gamma, Helm, Johnson, Vlissides)

  • 8/4/2019 Fang Fang 05172005

    14/21

    Key Features of Patterns

    Item Description-------------------------------------------------------------------------------------------------------------Name All patterns have a unique name that identifies them

    Intent The purpose of the patternProblem The problem that the pattern is trying to solveSolution How the pattern provides a solution to the problem in the context

    in which it shows upParticipants The entities involved in the patternand collaboratorsConsequences The consequences of using the pattern. Investigates the forces at

    play in the patternImplementation How the pattern can be implementedGeneric structure A standard diagram that shows a typical structure for the pattern

  • 8/4/2019 Fang Fang 05172005

    15/21

    Enumerate GoF Patterns

    Structural Patterns

    AdapterBridgeCompositeDecoratorFacade

    FlyweightProxy

    Behavioral Patterns

    Chain of ResponsibilityCommandInterpreterIteratorMediator

    MementoObserverStateStrategyTemplate MethodVisitor

    Creational Patterns

    Abstract FactoryBuilderFactory MethodPrototypeSingleton

  • 8/4/2019 Fang Fang 05172005

    16/21

    Abstract Factory Pattern

    Provide an interface for creating families of related or dependentobjects without specifying their concrete classes." - GoF

    Solution

    A Switch to Control Which Driver to Use

    class ApControl {. . .

    public void doDraw() {. . .switch (RESOLUTION) {

    case LOW:// use lrdd

    case HIGH:// use hrdd

    }}

    public void doPrint() {. . .switch (RESOLUTION) {

    case LOW:// use lrpd

    case HIGH:// use hrpd

    }}

    }

    Problem class ApControl {. . .

    public void doDraw() {. . .myDisplayDriver.draw();

    }public void doPrint() {. . .myPrintDriver.print();

    }}

    abstract class ResFactory {abstract public DisplayDriver getDispDrvr();abstract public PrintDriver getPrtDrvr();

    }

    class LowResFact extends ResFactory {public DisplayDriver getDispDrvr() {

    return new LRDD();}

    public PrintDriver getPrtDrvr() {return new LRPD();

    }}class HighResFact extends ResFactory {...}

  • 8/4/2019 Fang Fang 05172005

    17/21

    The Facade Pattern

    Provide a unified interface to a set of interfaces in a subsystem.Facade defines a higher-level interface that makes the subsystemeasier to use. - GoF

    Problem Solution

  • 8/4/2019 Fang Fang 05172005

    18/21

    Stragegy Pattern

    Solution

    Define a family of algorithms, encapsulate each one, and makethem interchangeable. Strategy lets the algorithm varyindependently from clients that use it. - GoF

    Problem

  • 8/4/2019 Fang Fang 05172005

    19/21

    J2EE Best Practice MVC Pattern (I)

    Model

    Controller

    View

    Represents the application data along with methods thatoperate on that data.

    Displays that data to the user.

    Translates user actions such as mouse movement and keyboardinput and dispatches operations on the Model.

  • 8/4/2019 Fang Fang 05172005

    20/21

    J2EE Best Practice MVC Pattern (II)

    Http request

    or post

    Response

    Forward

    Dispatch

    Update

    Extract

    Client browser

    Controller(action servlet)

    Businesslogic

    Model(server sideJavaBean/EJB)

    View(JSP page)

  • 8/4/2019 Fang Fang 05172005

    21/21

    Q & A

    Thank you!!