Application Servers by liaoxiuli


									Application Servers
       Gökçe Banu Laleci

    for building integrated, enterprise-class
     applications that share information, deliver
     services, and automate collaboration among
     networked companies at Internet volume and
            separate of presentation, business logic, and data
            provide the underlying core functionality
             necessary for the development and deployment of
             business-driven application
            connect legacy systems, and Web Services
11.12.2003                         CENG 520                   2
                                Gokce Banu Laleci
    applications with complex business logic
    potentially servicing tens of thousands of
     concurrent users in real-time
    require a scalability and reliability
    Distributed system
            Stock trading system
            Banking application

11.12.2003                        CENG 520         3
                               Gokce Banu Laleci
What you need?
    RMI                                    Logging and auditing
    Load balancing                         System management
    Transparent fail over                  Threading
    Back-end integration                   Message-oriented
    Transaction                             middleware
    Clustering                             Object life cycle
    Dynamic                                Resource polling
     redeployement                          Security
    Clean shutdown                         Caching
11.12.2003                      CENG 520                            4
                             Gokce Banu Laleci
    a new layer of
     functions and
     between Web
     servers and
     applications and

11.12.2003                 CENG 520         5
                        Gokce Banu Laleci
What do they provide
    speeds application development and relieves developers of the
     effort and expense of creating these crucial services on their own
      Load balancing
      Fault tolerance
      Web Services
      Legacy integration
      Transaction management
      Security
      Messaging
      Multi-threading
      Persistence
      Database connectivity
      Resource pooling
      Development, testing, and packaging facilities

11.12.2003                         CENG 520                           6
                                Gokce Banu Laleci
Single server / clustered

11.12.2003        CENG 520         7
               Gokce Banu Laleci
J2EE based..
             J2EE Patterns

11.12.2003          CENG 520         8
                 Gokce Banu Laleci
J2EE based…
    BEA WebLogic Java Application Server
    IBM WebSphere Java Application Server
    Oracle 9i Java Application Server
    Sun ONE Java Application Server (iPlanet)
    HP Application Server (HP-AS) (Bluestone)
    JBoss Application Server
    Enhydra Application Server

11.12.2003               CENG 520                9
                      Gokce Banu Laleci
J2EE Components used..
    Java Servlets & Java Server Pages (JSP)
    Enterprise Java Beans (EJB)
    Java Transaction API (JTA)
    Java Transaction Service (JTS)
    Java API for XML Parsing (JAXP)
    Java Messaging Service (JMS)
    Message Driven Beans (MDB)
    Remote Method Invocation (RMI)
    Java Database Connection 2 (JDBC2)
    Java Connector Architecture (JCA)
    Java Naming and Directory Interface (JNDI)
    JavaBeans Activation Framework (JAF)

11.12.2003                       CENG 520         10
                              Gokce Banu Laleci
Three layered architecture
    The presentation layer
            managing the user interfaces of applications,
             including desktop applications, Web browsers,
             and pervasive devices
    The business layer
            contains the business logic
    The back-end layer
            provides connectivity with enterprise systems and
11.12.2003                        CENG 520                   11
                               Gokce Banu Laleci
Three layered architecture

             Hosting Organization

                                                           Subscriber 1



                                                           Subscriber 2


                                                           Subscriber 3

11.12.2003                                CENG 520                        12
                                       Gokce Banu Laleci
Presentation Layer
    Thin clients
            such as Web browsers that send HTTP requests
             and receive HTTP responses for static HTML or
             dynamic Web pages built by Java Servlets and
             Java Server Pages (JSPs)
    Thick clients
            such as Java applets and applications, ActiveX
             controls, or Visual Basic clients that run on a
             desktop and communicate with BEA WebLogic
             Server through CORBA, Java RMI,IIOP, or COM+

11.12.2003                        CENG 520                   13
                               Gokce Banu Laleci
Presentation Layer
    Pervasive devices
            including wireless phones, PDAs, smart
             appliances, and other emerging remote clients
             that communicate with the server via specific and
             usually very compact
                can generate WML pages from Servlets and JSPs.
    Web Services
             that connect to the system using Web Services
             technologies, such as SOAP,UDDI, and WSDL

11.12.2003                           CENG 520                     14
                                  Gokce Banu Laleci
Presentation Layer
    Provides a Web Server
            Servlet and JSP results caching and JSP tags
            provides high-reliability, scalability, monitoring,
             and other features required by enterprise
            plug-ins for Apache, iPlanet, and Microsoft IIS
             Web servers

11.12.2003                           CENG 520                      15
                                  Gokce Banu Laleci
Additional Features
    Virtual hosting
      and
    Clustering
            scalability and high-availability
            insulates clients from hardware or power failures
             by eliminating single points of failure
    Load balancing
            Incoming requests can be distributed across
             multiple instances of AS
11.12.2003                         CENG 520                      16
                                Gokce Banu Laleci
Additional Features
    High availability with transparent fail-over
             The data contained in Web components can be
             replicated across multiple machines
             In the event of a failure, current client session
             information is maintained
                disk-based persistence
                in- memory replication of a client ’s session state

11.12.2003                              CENG 520                       17
                                     Gokce Banu Laleci
Business Layer
    contains the application’s business logic
     independent of the user interface, including
     distributed components, running in the
     application server environment
    Enterprise Java Beans

11.12.2003                 CENG 520                 18
                        Gokce Banu Laleci
Enterprise Java Beans
    Reusable server components
            A manageable, discrete chunk of code
             implementing a set of well defined interfaces
    it has to be compliant to a well defined
            To be reusable
            To be able to use the AS functionalities

11.12.2003                         CENG 520                  19
                                Gokce Banu Laleci
Java Beans vs. EJB
    Generic java                         Standard for building
     component model                       distributed systems
    Can be either visible or             Non-visible remote
     not                                   objects
    Local to a single                    Remotely executable
     process on the client                 comp. deployed in the
     side                                  server
    Uses BeanInfo classes                Uses Deployment
     to define themselves                  descriptor to describe
11.12.2003                    CENG 520                              20
                           Gokce Banu Laleci
    Architectural independence from middleware
    WORA for sever side components
    Establishes roles for application development
    Take care of transaction management
    Provides distributed transaction support
    Portable
    Integrates seamlessly with CORBA

11.12.2003                CENG 520               21
                       Gokce Banu Laleci
The EJB architecture

11.12.2003       CENG 520         22
              Gokce Banu Laleci
What do containers provide
    Remote invocation
    Pool and cache services
    Security
    Transaction
    Integration with external data sources

11.12.2003                CENG 520            23
                       Gokce Banu Laleci
    Interface btw EJBeans
     & outside world
    EJB Clients never
     access an EJB directly-
     any access is done
     through container-
     generated methods in
     turn invoke bean

11.12.2003                   CENG 520         24
                          Gokce Banu Laleci
Home interface
    Contains factory methods for locating,
     creating and instances of EJBs
    The EJB developer defines the Home
     Interface for his bean
    Object generated by the Container vendor

11.12.2003               CENG 520               25
                      Gokce Banu Laleci
An example

11.12.2003      CENG 520         26
             Gokce Banu Laleci
Remote Interface & EJBObject
    Lists the business methods present in EJB
    Interface defined by the developer
    Object created by the container vendor
    Clients use this object to invoke business

11.12.2003                CENG 520                27
                       Gokce Banu Laleci
An example

11.12.2003      CENG 520         28
             Gokce Banu Laleci
EJB Client
    Finds EJB containers using JNDI
    Uses EJB container to invoke EJB methods
    Uses Home Object to locate, create or
     destroy and EJB class
    Uses the EJBObject instance to invoke

11.12.2003               CENG 520               29
                      Gokce Banu Laleci
                            Client API provides
                             naming & directory
                             services for Java Apps
                            Does not replace DNS,
                             CORBA, RMI etc
                            Allows multiple
                             directory services co-
                            Provides a federated
                             name server
11.12.2003      CENG 520                          30
             Gokce Banu Laleci
An example
     // get the JNDI naming context
     Context initialCtx = new InitialContext ();
     // use the context to lookup the EJB Home interface
     AccountHome home
     // use the Home Interface to create a Session bean
     Account account = home.create (1234, "Athul",

11.12.2003                   CENG 520                      31
                          Gokce Banu Laleci
EJB Types
    Entity Beans
    Session Beans
    Message-Driven Beans

11.12.2003             CENG 520         32
                    Gokce Banu Laleci
Entity Beans
    Used to represent business data in an application
    Correspond with information stored in databases or other
     persistent storage
    Have primary key
    Participate in transactions
    Long-lived
    Can survive EJB server clashes
    Multiple clients can access and work with the same entity bean
    When not used
      Preserved in persistent location and returned to the pool
    When used
      Can be cached

11.12.2003                        CENG 520                            33
                               Gokce Banu Laleci
Entity Bean Interface
    ejbActivate ()
    ejbLoad ()
    ejbPassivate ()
    ejbRemove ()
    ejbStore ()

11.12.2003                CENG 520         34
                       Gokce Banu Laleci
        Container Managed                          Bean Managed
    Container is responsible for            Bean is itself responsible for
     saving state of bean                     saving its own state
    Container needs to                      Bean needs to code its own
     generate DB calls                        DB calls
    Bean persistence is                     Bean persistence is hard-
     independent of data source               coded and is hence less
    specify container-managed                adaptable
     fields in Deployment

11.12.2003                       CENG 520                                 35
                              Gokce Banu Laleci
Session Beans
    Execute on behalf of a single client
    They may or may-not be transaction-aware
    They may or may-not update data in the underlying
    Their lifetime is limited to that of the client and hence
     they are relatively short-lived
    They do not survive server crashes
    They do not represent data in the database
    Since they only represent conversational state with
     a single client, their identity is hidden

11.12.2003                     CENG 520                     36
                            Gokce Banu Laleci
Stateless Session Bean            Stateful Session Bean
 Have no internal state          Have internal state

 need not be passivated          need to handle
  or activated                     Activation/Passivation
 Objects can be pooled           One Session Bean
  to service multiple              object per client

11.12.2003               CENG 520                           37
                      Gokce Banu Laleci
Message-Driven Beans
    Do not have home or remote interface
    Used to integrate with JMS
    Called JMS message consumers
            Listen from a message from JMS server
            Performs a set of actions defined when message
             is received

11.12.2003                        CENG 520                    38
                               Gokce Banu Laleci
Deployment Descriptors
    While deploying your EJB to container
            Provide a deployment descriptor file (xml)
                JNDI name
                Transactional rules
                Security roles and permissions of a component

11.12.2003                            CENG 520                   39
                                   Gokce Banu Laleci
Additional Features
    Instance pooling
            pre-load a given number of instances and prepare
             them for use, thereby saving time by not having to
             create a new instance for each request
    Clustering
            EJBs can be deployed in a cluster of BEA
             WebLogic Servers
            by means of distributed naming and directory

11.12.2003                         CENG 520                   40
                                Gokce Banu Laleci
Additional Features
    High availability with transparent fail-over
            replicate state that EJB hold across a cluster of
             separate physical AS processes
            creating redundancy in case of
            transparently fail-over to a backup machine in the
             cluster in the event of a failure
    Load balancing
            route requests from remote clients to EJB
             components using a predetermined algorithm or
11.12.2003                         CENG 520                   41
                                Gokce Banu Laleci
Additional Features
    EJB Caching
            store a configurable number of EJBs in memory to
             save on database access
            In case another instance of the server in the
             cluster updates the same bean, all the cached
             instances of the bean cached in the cluster will be
             invalidated, and reloaded with the next access
            increases performance and reduces the load on
             the database

11.12.2003                         CENG 520                    42
                                Gokce Banu Laleci
Back-End Layer
    provides access to other enterprise systems
            databases, ERP, CRM, mainframe or other
             existing applications
    Integration layer
            messaging, e-mail, Web Services, and other
             technologies to connect and communicate with
             enterprise systems

11.12.2003                       CENG 520                   43
                              Gokce Banu Laleci
    JDBC
            Thin clients – servlet, JSP
            Thick clients – RMI to remote databases
            most recommended way is to use entity beans
             and benefit from the underlying services
            Connection pooling

11.12.2003                       CENG 520                  44
                              Gokce Banu Laleci
    integrating new applications with any legacy
     Enterprise Information System (EIS)
    J2EE Connector Architecture (J2CA)
    CORBA
            integration with legacy systems that implement the CORBA
    COM/DCOM (COM+)
            bi-directional interoperability with Microsoft ’s COM+
              can access data in Microsoft applications, communicate
                with Visual Basic clients

11.12.2003                            CENG 520                          45
                                   Gokce Banu Laleci
    a standard architecture for connecting the
     J2EE platform to heterogeneous EIS systems
            ERP, mainframe transaction processing,
             database systems, and legacy applications not
             written in the Java programming language
            enables the integration of EISs with application
             servers and enterprise applications
                By defining a a set of scalable, secure, and
                 transactional mechanisms

11.12.2003                             CENG 520                 46
                                    Gokce Banu Laleci
    enables an EIS vendor to provide a standard
     resource adapter for its EIS
    The resource adapter plugs into an application
     server, providing connectivity between the EIS, the
     application server, and the enterprise application
    An EIS vendor needs to provide just one standard
     resource adapter which has the capability to plug in
     to any application server that supports the J2EE
     Connector architecture

11.12.2003                   CENG 520                       47
                          Gokce Banu Laleci
    Multiple resource adapters are pluggable into
     an application server
    enables application components deployed on
     the application server to access the
     underlying EIS systems

11.12.2003                CENG 520               48
                       Gokce Banu Laleci

11.12.2003      CENG 520         49
             Gokce Banu Laleci
Resource Adapter
    To achieve a standard system-level
     pluggability between application servers and
     EISs, the J2EE Connector architecture
     defines a standard set of system-level
     contracts between an application server and
    The resource adapter implements the EIS-
     side of these system-level contracts

11.12.2003                CENG 520                  50
                       Gokce Banu Laleci
Resource Adapter
    system-level software driver used by an
     application server or an application client to
     connect to an EIS
    By plugging into an application server, the
     resource adapter collaborates with the server
     to provide the underlying mechanisms, the
     transactions, security, and connection pooling
    A resource adapter is used within the
     address space of the application server
11.12.2003                CENG 520                51
                       Gokce Banu Laleci
Application Contract
    An application server and an EIS collaborate to
     keep all system-level mechanisms, such as
     transactions, security, and connection management,
     transparent from the application components
    A Connection Management contract
    A Transaction Management contract
    Security contract
    A Message Inflow contract
    A Lifecycle Management contract
    A Work Management contract

11.12.2003                  CENG 520                  52
                         Gokce Banu Laleci
Web Service Support
    Automatically wraps the business components in to Web
    Support for WSDL and UDDI
      Publish, search, host
    Support for Web Services Security standard
    Reliable SOAP implementation
      based on a sequence of asynchronous SOAP communications,
        receipts, and notifications
      guaranteed delivery, “exactly-once ” delivery, ordered
    A set of convenient graphical tools for development, search, and
     composing of the Web Services
      BEA WebLogic Workshop

11.12.2003                        CENG 520                          53
                               Gokce Banu Laleci
    Asynchronous method invocations
    Why?
            Performance
            Reliability
            Support for multiple senders and receivers

    Application                                     Application

11.12.2003                         CENG 520                       54
                                Gokce Banu Laleci
    Provides
            Guaranteed message delivery
            Fault tolerance
            Load balancing of destinations
            Subscription mech.
    Proprietary solutions
            Tibco Rendezvous
            IBM MQSeries
            BEA Tuxedo/Q
            Microsoft MSMQ

11.12.2003                            CENG 520         55
                                   Gokce Banu Laleci
Java Message Service
    API
            Write code to send and receive msg
    Service Provider Interface (SPI)
            Plug in JMS drivers
                to allow existing companies to JMS-enable their
                 applications without impacting client-side development
    Supports
            Publish/subscribe
            Point-to-point
11.12.2003                             CENG 520                       56
                                    Gokce Banu Laleci
JMS System
    ConnectionFactory
    Connection
    Session
    Destination
    MessageProducer
    MessageConsumer
    Message

11.12.2003              CENG 520         57
                     Gokce Banu Laleci
                   2:Create            JMS Connection
                   Connection             Factory

                                       JMS Connection
                    5:Create            JMS Session
     Client         Producer or

                                        JMS Producer
                   6:Send or
MS Driver          Receive                   Or
Connection                              JMS Consumer
         4:Lookuo JMS
         Destination              JMS Driver Client Runtime



      11.12.2003                                     CENG 520                      58
                                                  Gokce Banu Laleci
try {
     queueConnectionFactory =(QueueConnectionFactory)
     queue =(Queue)jndiContext.lookup(queueName);
try {
     queueConnection =
     queueSession =            queueConnection.createQueueSession(false,
     queueSender =queueSession.createSender(queue);
     message =queueSession.createTextMessage();
     for (int i =0;i <NUM_MSGS;i++){
            message.setText("This is message "+(i +1));
            System.out.println("Sending message:"+ message.getText());
11.12.2003                            CENG 520                             59
                                   Gokce Banu Laleci
EJB JMS Integration
    Message Driven Beans
    Do not have home/remote interface
            Just to consume messages
            Not a component interface
            onMessage method
    Why not use existing beans
            Threading
            Life cycle management

11.12.2003                       CENG 520         60
                              Gokce Banu Laleci
    Java Authentication and Authorization Server (JAAS)
    Encryption
    Auditing
    HTTPS,
    basic HTTP authentication with Base64 encoding for services
     protected by firewalls
    Role based security
      User and group definition
      Built-in security data store retains the role,profile,and entitlement
        data,and is built on a highly optimized LDAP directory
    Single Sign-On
    WS-Security

11.12.2003                           CENG 520                              61
                                  Gokce Banu Laleci
Adding security to EJB
    JAAS
            Portable interface
            Java applications to remain independent from
             underlying authentication technologies
    Authentication
            Basic
            Digest
            Certificate

11.12.2003                        CENG 520                  62
                               Gokce Banu Laleci
    Programmatic
            Hard code security checks in to your bean code
    Declarative
            Through deployment descriptor
            Container handles the rest

11.12.2003                        CENG 520                    63
                               Gokce Banu Laleci
Role based
    Each user must be uniquely identified
    User should be assigned one or more
     security roles
    Each security role is assigned a set of
     method permissions

11.12.2003                 CENG 520            64
                        Gokce Banu Laleci
Example role definition

11.12.2003       CENG 520         65
              Gokce Banu Laleci
Example method permission

11.12.2003      CENG 520         66
             Gokce Banu Laleci
   A series of operations that appear to execute
    as one large atomic operation
        All-or-nothing
        Allow multiple users to share the same data
   ACID
        Atomicity
            Many operations are bundled together and appear as
             one atomic unit

11.12.2003                        CENG 520                        67
                               Gokce Banu Laleci
    Consistency
            A transaction leaves the system in a consistent
    Isolation
            Protects concurrently executing transactions from
             seeing each other’s incomplete results
    Durability
            Guarantees that updates to managed resources,
             such as database records, survive failures
11.12.2003                         CENG 520                    68
                                Gokce Banu Laleci
    Type
            Flat
            Nested
    Rollback is not an undo logic
            Resource managers are transaction aware
            They do no not make the changes persistent until
             a commit statement issued

11.12.2003                        CENG 520                  69
                               Gokce Banu Laleci
EJB and transactions
    EJB never interact with a transaction
     manager or a resource manager
    The container handles all the low-level things
    Demarcating transactional boundries
            Programmatically
            Declaratively
            Client-initiated

11.12.2003                         CENG 520         70
                                Gokce Banu Laleci
  Programmatic Transactions
      Put the transaction logic in to your application
      The programmer is responsible for issuing
              begin, commit and abort

Client Code                                                          EJB Container

               1:call                      2:delegate
               method   EJB object
                                                      3:call begin
                                            EJB                          Service
                             4:perform                 5:call commit
                             business                  or abort
  11.12.2003                                 CENG 520                                71
                                          Gokce Banu Laleci
Declarative Transactions
    EJB container handles
    Declare in deployment descriptor

11.12.2003                  CENG 520         72
                         Gokce Banu Laleci
Declarative Transactions

Client Code                                                   EJB Container

                                             3:call begin
             1:call                                           Transaction
             method   EJB object              5:call commit     Service
                                              or abort




11.12.2003                                CENG 520                            73
                                       Gokce Banu Laleci
Client Initiated Transactions

                                                                EJB Container

                          3:call begin
Client Code                                                     Transaction
                           5:call commit                          Service
                           or abort
             method   EJB object




11.12.2003                                  CENG 520                            74
                                         Gokce Banu Laleci
    Bean deployer has to provide instructions to
     the container
            Deployment descriptor
            Transaction Attributes
                Entire bean
                Individual methods

11.12.2003                               CENG 520         75
                                      Gokce Banu Laleci
Transaction Attribute Values

11.12.2003       CENG 520         76
              Gokce Banu Laleci
Transaction Attribute Values
Transaction Attribute   Client’s transaction       Bean’s transaction

                        none                       T2
                        T1                         T1
                        none                       T2
                        T1                         T2
                        none                       None
                        T1                         T1
                        none                       Error
                        T1                         T1
                        none                       None
                        T1                         None
                        none                       None
                        T1                         error
11.12.2003                        CENG 520                              77
                               Gokce Banu Laleci
Programmatic Transactions
    CORBA’s Object Transaction Service (OTS)
            Multiple parties participating in a transaction
            Basic interfaces that transactional object,
             resources, resource managers, and transaction
             managers use to interoperate

11.12.2003                         CENG 520                    78
                                Gokce Banu Laleci
Java Transaction Service
    Corba OTS
            Java Transaction Service
            Java Transaction API
            To have various vendors to interoperate
            Used by AS
    JTA
            Application developers
            Programmaticaly control transaction boundaries

11.12.2003                        CENG 520                    79
                               Gokce Banu Laleci
Java Transaction API
    begin()
    Commit()
    getStatus()
    rollBack()
    setRollbackOnly()
    setTransactionTimeout()

11.12.2003                  CENG 520         80
                         Gokce Banu Laleci

11.12.2003      CENG 520         81
             Gokce Banu Laleci

To top