Learning Center
Plans & pricing Sign in
Sign Out

J2EE Architecture and Design Patterns


									J2EE Architecture and Design Patterns
Introduction to Arthitecture

●   Architecture is the overall structure of a system, and it can
    contain subsystems that interface with other subsystems
●   Architecture versus Design (level of details)
●   Architecture considers bunch of *abilities

    Manageability and Flexibility
    Extensibility, Validity, Reusability
Multi-tiered J2EE applications

  J2EE Application I   J2EE Application II

     Application        Dynamic HTML                     Client
     Client             pages            Client tier     machine

                          JSP/Servlet    Web tier        J2EE
     Enerprise                           Business tier
     Beans                Beans

     Database             Database       EIS tier
Distributes Programming Services

    ●   Naming and Registration (JNDI)
    ●   Remote Method Invocation (RMI)
    ●   Protocols
        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 JNI
                                                    embedded in resource adapters
●   Distributed Object Frameworks
        - CORBA
        - Native Language Integration
        - Java/RMI
        - DCOM
●   XML
EJB Distributed Nature (I)

                          EJB Container
Client                                    Bean
         Home Stub
EJB Distributed Nature (II)
       J2EE Modular-Based Development

aff be categories into different roles:
          ●   Presentation tier developer
          ●   Bean provider
          ●   Application assembler
          ●   Component provider
          ●   Application server provider
          ●   EJB container provider
J2EE Application Deliverable

                  Enterprise archive (.ear)

    Web archive           EJB archive         Client archive
    (.war)                (.jar)              (.car)
    web.xml               ejb-jar.xml         application-client.xml
Deployment Descriptor Sample

            This role represents everyone who is allowed full access
            to the Cabin EJB.
 J2EE Standards

   Contains following specs
     ●   EJB spec
     ●   Servlet spec
     ●   JSP spec

Together with below's offerings
     ●   CTS
     ●   J2EE SDK
Key Features of Patterns

Item                           Description
Name                          All patterns have a unique name that identifies them
Intent                        The purpose of the pattern
Problem                       The problem that the pattern is trying to solve
Solution                      How the pattern provides a solution to the problem in the context
                              in which it shows up
Participants                 The entities involved in the pattern
and collaborators
Consequences                  The consequences of using the pattern. Investigates the forces at
                              play in the pattern
Implementation                How the pattern can be implemented
Generic structure             A standard diagram that shows a typical structure for the pattern
Enumerate GoF Patterns

Creational Patterns   Structural Patterns   Behavioral Patterns

Abstract Factory      Adapter               Chain of Responsibility
Builder               Bridge                Command
Factory Method        Composite             Interpreter
Prototype             Decorator             Iterator
Singleton             Facade                Mediator
                      Flyweight             Memento
                      Proxy                 Observer
                                            Template Method
    Abstract Factory Pattern
       “Provide an interface for creating families of related or dependent
        objects without specifying their concrete classes." - GoF
           Problem                        Solution                   class ApControl {
                                                                       . . .
                                                                       public void doDraw() {
                                                                         . . .
A Switch to Control Which Driver to Use                                  myDisplayDriver.draw();
class ApControl {                                                      public void doPrint() {
  . . .                                                                  . . .
  public void doDraw() {                                                 myPrintDriver.print();
    . . .                                                              }
    switch (RESOLUTION) {                                            }
      case LOW:
        // use lrdd                                                  abstract class ResFactory {
      case HIGH:                                                       abstract public DisplayDriver getDispDrvr();
        // use hrdd                                                    abstract public PrintDriver getPrtDrvr();
    }                                                                }
  public void doPrint() {                                            class LowResFact extends ResFactory {
    . . .                                                               public DisplayDriver getDispDrvr() {
    switch (RESOLUTION) {                                                 return new LRDD();
      case LOW:                                                         }
        // use lrpd                                                     public PrintDriver getPrtDrvr() {
      case HIGH:                                                          return new LRPD();
        // use hrpd                                                     }
    }                                                                }
  }                                                                  class HighResFact extends ResFactory {
}                                                                    ...
The Facade Pattern

●   “Provide a unified interface to a set of interfaces in a subsystem.
    Facade defines a higher-level interface that makes the subsystem
    easier to use.” - GoF
       Problem                             Solution
J2EE Best Practice – MVC Pattern (I)

  ●   Model
      Represents the application data along with methods that
      operate on that data.

  ●    View
      Displays that data to the user.

  ●    Controller
      Translates user actions such as mouse movement and keyboard
      input and dispatches operations on the Model.
J2EE Best Practice – MVC Pattern (II)

                         Controller                      Business
          Http request   (action servlet)                logic
          or post

   Client browser                Forward                     Update

           Response       View                          Model
                          (JSP page)                    (server side
                                              Extract   JavaBean/EJB)
●   Q&A
●   Thank you!!

To top