J2EE Architecture - PowerPoint

Document Sample
J2EE Architecture - PowerPoint Powered By Docstoc
					Session 3

       J2EE Architecture
   The J2EE technologies can be broadly classified into four
    different categories:
      Client-side technologies

      Component technologies

      Service technologies

      Communication technologies

   Component technologies include:
      Servlets

      Java Server Pages

      Enterprise JavaBeans

           Session Beans

           Entity Beans

   Service Technologies include:
      Java Database Connectivity

      Java Transaction API and Service
                                                     J2EE/ Session 3/Slide 2 of 49
   Review Contd…
     Java Naming and Directory Interface
 Transaction - A transaction is a group of operations that are
  carried out as a single unit on records stored in a database.
  The group must have a set of characteristics in order to be
  considered as transactional.
 ACID properties include
    Atomic

    Consistent

    Isolated

    Durable

 The Java Naming and Directory Interface, JNDI in short, is a
  naming service.
 A naming service associates a name with an object, so that
  clients can locate the object using the specified name.Session 3/Slide 3 of 49
    Review Contd…
   A directory service on the other hand, allows attributes as well
    as names to be associated with objects.
   Internet Protocols include: HTTP, TCP/IP, SSL
   Remote Object Protocols include:
      RMI and RMI-IIOP

      Java IDL

      JMS

      JavaMail

   XML or Extensible Markup Language is the most popular tool to
    distribute structured information over the Internet.
   XML is used for structured information management.
   XML can also be used to create customized views of data .
    XML documents come in two flavors – well formed and valid.
   J2EE deployment descriptors are written in XML based on
    predefined DTDs
                                                      J2EE/ Session 3/Slide 4 of 49
    The Objectives…
   Describe the architecture in software
   Explain the J2EE architecture
   Describe the J2EE units
   Explain the benefits of the J2EE architecture
   Describe the J2EE application scenario

                                       J2EE/ Session 3/Slide 5 of 49
         Client-Server Architecture
           CLIENT                                            SERVER
Business Logic

                 Presentation Logic

                  Clear division between Application and Data
     Entire processing load on client             Server acts as traffic controller

                                  2-Tier Architecture

                                                                   J2EE/ Session 3/Slide 6 of 49
   Client-Server: The Drawbacks

                   Business logic present on each client

               Client waits longer for response

         Business logic + presentation logic bundled together-
         therefore scalability problems

     Load on server and network as all clients send request to 1 server

Tiny change to application— entire application has to be changed, and
the clients upgraded

                                                     J2EE/ Session 3/Slide 7 of 49
       3-Tier Architecture
                   MIDDLE TIER/

Presentation          Business
                       Logic                         DATA

               Receives request for
               data, retrieves it, and
               returns it to client

                                         J2EE/ Session 3/Slide 8 of 49
    3-Tier Architecture: the benefits
Business logic shared between clients; same data returned by data &
application tier –presented differently on different clients

   Business logic can be changed without impacting clients

     Middle tier can be hidden behind firewall
         Maximum use of available system resources

            Parts of architecture can be rewritten without rewriting
            whole app

                                                     J2EE/ Session 3/Slide 9 of 49
      Traditional n-Tier Architecture

Application Logic= Presentation logic + Business Logic
        (No physical demarcation between the two)

      Infrastructure services provide additional functionalities required by
      application, such as messaging services and transactional services.

                                                               J2EE/ Session 3/Slide 10 of 49
    Traditional n-Tier Architecture:
    The Characteristics

Business logic and presentation logic in same module

Database connectivity through same module

Scalability low

Business logic difficult to update

Client & Server – stateless communication

Business logic unaware of different client identities

Client has to maintain state
                                                        J2EE/ Session 3/Slide 11 of 49
    Traditional n-Tier Architecture:
    The Characteristics

Business logic and presentation logic in same module

Database connectivity through same module
              Major Drawback:
Scalability low
 Middle Tier contains ONE Application Object.
 Therefore, for different types of needs, different
Business logic difficult to update
 application objects need to be created; these
 objects may stateless communication
Client & Server –not be able to communicate with
 each other
Business logic unaware of different client identities

Client has to maintain state
                                                       J2EE/ Session 3/Slide 12 of 49
      Overcoming the drawbacks -
      Improving the system

Middle Tier contains one     Extend the middle tier to
App object                   create one more layer

For different types of       Allow multiple application
needs-different app          objects to reside on the
objects required             server

Different application        Use interfaces to
objects may not be able to   communicate between
communicate with each        application objects
                                            J2EE/ Session 3/Slide 13 of 49
Component n-tier Architecture

                       Component A

                       Component B                            Database

                       Component C

Application object broken into components that can communicate
with each other, through interfaces

                                                   J2EE/ Session 3/Slide 14 of 49
    Component Based n-Tier
                    Comp A

                    Comp B

                    Comp C

   Component objects maintain identity and encapsulate
    remote methods
   Components can be designed to maintain session
    state on server
   Business logic can be modified without affecting
    other logic
   Components can leverage their container context for
                                           J2EE/ Session 3/Slide 15 of 49
Layered Architecture

          Component A   D
          Component B   L              Database
          Component C
                            JDBC-ODBC Bridge,
                            J2EE/ Session 3/Slide 16 of 49
  Layered Architecture
               Comp A   D
               Comp B   L
                        E      Database
               Comp C   A

Layering achieves system flexibility in 3 ways
          Operations of a layer hidden from another layer

          Each layer focused on a cohesive set of responsibilities

          Each layer can provide services to objects in another layer
                                                    J2EE/ Session 3/Slide 17 of 49
Layered Architecture
                           Layers may be thin, and
                           have little impact on system

       Replaced by…

                            Layers may be replaced -
                            API, however, MUST remain
                            the same

In a good design, entire layer can be swapped
                                         J2EE/ Session 3/Slide 18 of 49
 Various models of architecture


                  Component-based n-Tier


                            Distributed nature of application
         Depends on
                            Memory Management
                                            J2EE/ Session 3/Slide 19 of 49
   J2EE Architecture
 J2EE is a layered architecture
 J2EE framework designed based on…

Using these we can design applications that are…

                                                   J2EE/ Session 3/Slide 20 of 49
J2EE Layer Stacks

                    J2EE/ Session 3/Slide 21 of 49
The Presentation Layer

    Manages i/o interactions

    Renders HTML, present application data
    intercepts user input, performs application-
    specific range and syntactic checking

    Layer executes in web browser

    J2EE supports applets, applications and CORBA

                                     J2EE/ Session 3/Slide 22 of 49
The Presentation Layer

   JSPs generate dynamic content for web

   Also called ‘layout layer’

   Presents application data to browser in the
   form of web pages

   Data presented as specified by JSP

                                            J2EE/ Session 3/Slide 23 of 49
  The Presentation Layer

Components of presentation layer are page renderers
that render dynamic content on web

Components written in JSP or servlets

According to J2EE 1.3, presentation layer could
comprise of XML and XSL
                                        J2EE/ Session 3/Slide 24 of 49
           Application Layer

      Mediates interaction between client-side presentation and services

  Application A
                                                     Services and Domain layers
                                                     may be shared among
Application B               Services   Domain        multiple applications
                             Layer      Layer
                                                     Application layer, therefore,
                                                     calls services to implement
   Application C                - Presentation Layer behavior of each application
                                   - Application Layer

       This layer-also called the ‘logic layer’
                                                                J2EE/ Session 3/Slide 25 of 49
    Application Layer

           invoke                      invoke


Presentation component mediates the interaction between the client-side
                            presentation and services layers
Controller components (JSP/Servlet) interact with presentation
layeraccept request invoke business components

Business component returns data to presentation layer. Component
also responsible for session management in HTTP session.
                                                         J2EE/ Session 3/Slide 26 of 49
Service Layer
              Services layer can be
               encapsulation layer for domain
              Methods in service layer take
               responsibility for transactions
               involving several domain objects
              Services permit schema hiding
              Schema hiding offers greater
               flexibility in object distribution

                                 J2EE/ Session 3/Slide 27 of 49
       Service Layer

         Many applications can share a suite of services and
          their own unique services
         Different kinds of clients can use same services
         Services provide a very high leverage test point
         Components that form service layer:

Simple Beans                                           Transactional
                           Session Beans                Components

                                                 J2EE/ Session 3/Slide 28 of 49
    Domain Layer

• Models abstractions in problem domain

   Domain Layer
                       Business rules and semantics
                       embedded within
                    • Layer responsible for enforcement of
                      business rules and process
                    • Components in this layer: ENTITY
                                           J2EE/ Session 3/Slide 29 of 49
         Connectivity Layer
             Domain Layer
                                      N   L
                                      E   A
               Objects                C
            Objects                       Y
                                      T   E
                                      I   R
                                      V               Back-End

• Forms connectivity layer between domain objects and back-end
• Application/Domain model can be reused to connect to different back-ends
• JDBC & JNDI, and Java Connector Architecture form modules for this
                                                       J2EE/ Session 3/Slide 30 of 49
        Persistence Layer

 Domain Layer   N
                N   L
                                     • Provides mechanisms to
                                       permanently save object
Domain          C   Y
   Objects      T   E
Objects         I


                                     • Deals with object to
                                       relational mapping issues

• Provides basic        Create Read Update Delete services
• Layer could also be the existing EIS or a mainframe
                                                   J2EE/ Session 3/Slide 31 of 49
       J2EE Container

                                 To maintain components and
                                 provide run-time services

       •   Hosts the component
       •   Provides transaction services
       •   Provides security management
       •   Provides access to necessary environment variables
       •   Pool instance
       •   Manages states
                                                 J2EE/ Session 3/Slide 32 of 49
          J2EE Container
                     Two most important containers:

Web Components                                                              EJBs
• Manages threading for components       • Holds the following components:
• Provides necessary interface with          - Entity beans
  web server                                 - Stateful session beans
                                             - Stateless session beans
                                             - Message beans
  Containers provide medium for services to communicate with domain layer
                                                         J2EE/ Session 3/Slide 33 of 49
       J2EE Container
For every application, the following services are necessary:

      •   Hosting components
      •   Transactional Services
      •   Security Services
      •   Database Services           Services can be provided by…

                   Creating required services          Using Framework

                  Developer concentrates on         Developer concentrates only on
                  coding the functionality +        developing business logic
                  developing business logic

                                                            J2EE/ Session 3/Slide 34 of 49
     J2EE Container Services
                                                            Naming and
  Security Framework            Messaging Services
                                                            Directory Services

                                    J2EE                     Assembly and
Transaction Management
                                  Application                Deployment Tools
  Persistence                                             Standard J2SE APIs

                               Optional Services
Load Balancing                                                  Result Caching

        Replication                                        Thread Pool

                               Database Connection Pool

* As Per J2EE Specifications                               J2EE/ Session 3/Slide 35 of 49
                 Existing application
                 needs to be web-

               Not easy with existing architecture
  J2EE components capable of connecting to any back-end
resources, even legacy applications, if infrastructure is provided.
             Therefore, J2EE’s Connector Architecture!
                                                     J2EE/ Session 3/Slide 36 of 49
     Benefits of J2EE Architecture
1.    J2EE Server core manages resources and
      transactions; includes JVM
2.    J2EE Platform Services can be implemented on
      single system or distributed over disparate
3.    J2EE-compliant servers guarantee seamless and
      correct execution of components and middleware
4.    It becomes J2EE platform vendor’s
      responsibility to manage integration of service

                                         J2EE/ Session 3/Slide 37 of 49
     J2EE Applications
J2EE can be used in a variety of applications


 2-Tier Enterprise                              B2B applications
 wide applications

                     Web-centric applications    J2EE/ Session 3/Slide 38 of 49
J2EE Application Scenario

                      J2EE/ Session 3/Slide 39 of 49
       J2EE Application Scenario
Considerations for depicting such a scenario:
   Requirement of rapid and frequent changes to the look of the application

   Partitioning the application

   Segregating the development task

   Developers need to be familiar with back-office applications

   Communicating the business logic to the teams concerned

   Assembling back-office applications using components from various sources

   Deploying transactional components across multiple hardware and
   software platforms independent of underlying database technology

                                                         J2EE/ Session 3/Slide 40 of 49
    J2EE Programming Model
   The programming model suggests 3-tier
    architecture—Therefore, move to multi-tier
    architecture is easy
   Business logic cannot be completely separated
    from presentation logic
   Accomplishments of the model
      Anticipates growth

      Encourages component-oriented code re-usability

      Leverages strengths of inter-tier communication

   Tier integration lies at the heart of the J2EE
    programming model

                                          J2EE/ Session 3/Slide 41 of 49
        Other Scenarios

  Client                                                 XML EIS Resources

                                        EJB Container      XML
                                                                    EIS Resources
                        Application Components
                        (handle given
                        application’s presentation
MAJOR STRENGTH: We can decouple accessing data from issues
surrounding end-user interactions                 J2EE/ Session 3/Slide 42 of 49
       Other Scenarios
Stand-alone clients
                      EJB Client                         J
                                                         D              EIS
                    EJB Client         EJB Server
                                                         B           Resources
                      EJB Client                         C

             Stand-alone Java          D               EIS
             application clients       B            Resources
                          Middle-tier (business + presentation logic) embedded in client

                     VB Clients               Web Tier             EIS
    Presentation logic             XML data              Business logic
                                                                      J2EE/ Session 3/Slide 43 of 49
Other Scenarios

         D      EIS
         B   Resources

                         J2EE/ Session 3/Slide 44 of 49
   The traditional client-server systems are based on the
    two-tier architecture. There is a clear division between
    data and the application. However, the presentation
    and business logic are combined together.
   Owing to the drawbacks of the two-tier architecture, the
    three-tier architecture was introduced. The business
    logic was separated from the presentation logic.
   There are different types of n-tier Systems such as,
       Traditional (non-component)
       Component
   The traditional n-tier model is good but not sufficient to meet
    the enterprise-wide requirements.
   In the component n-tier approach, the different components
    communicate with each other using interfaces. Related
    groups of components form layers.
                                                J2EE/ Session 3/Slide 45 of 49
    Summary Contd...
   Layering helps achieve system flexibility in three ways:
       Encapsulation
       Separation of concerns
       Reuse
   J2EE is a layered architecture with many functional layers.
   Each layer is designed to implement a specific set of
    responsibilities and have a clearly defined API. Within the
    layers, the designer partitions these responsibilities,
    delegates them to relevant objects, and coordinates resource
    and data usage to ensure scalability and data integrity.
   The J2EE stack consists of six layers:
       Presentation
       Application
       Services
       Domain
                                                 J2EE/ Session 3/Slide 46 of 49
    Summary Contd...
       Connectivity
       Persistence

   These layers are physically split across the client and the
    server, and they are logically partitioned into the J2EE Web
    container, EJB container, and the database.

   Containers are required to maintain the components. They
    provide the components with run-time services, such as
    managing transactions, connection pools, security
    management, etc.

   Types of containers include
       Web containers
       EJB containers
                                                 J2EE/ Session 3/Slide 47 of 49
    Summary Contd...
   According to the J2EE specifications, the application server
    must provide the following services:
       Security framework
       Transaction management
       Persistence
       Naming and Directory Services
       Assembly and deployment tools
       Messaging services
       Standard J2SE APIs
   The connector architecture, (to be a part of the future
    specifications of J2EE) will allow connectivity to most of
    the existing applications written in COBOL.
   The benefits of the J2EE architecture include the
                                                  J2EE/ Session 3/Slide 48 of 49
    Summary Contd...
       J2EE server core manages resources and transactions and
        includes the JVM
       J2EE platform services can be implemented on a single
        system or distributed over disparate platforms
       J2EE-compliant servers guarantee the seamless and correct
        execution of all components and middle-ware services
       It is responsible for managing the integration of service
        implementations from different vendors.
   The J2EE programming model promotes a model that
    accomplishes the following things:
       Anticipating growth
       Encouraging component-oriented code reusability
       Leveraging the strengths of inter-tier communication

                                                     J2EE/ Session 3/Slide 49 of 49

Shared By: