Anda di halaman 1dari 81

Application Servers

Gke Banu Laleci

aim


for building integrated, enterprise-class applications that share information, deliver services, and automate collaboration among networked companies at Internet volume and speed
 


11.12.2003

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
CENG 520 Gokce Banu Laleci 2

Why?
 

 

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 Gokce Banu Laleci

What you need?


      

RMI Load balancing Transparent fail over Back-end integration Transaction Clustering Dynamic redeployement Clean shutdown

   

   

Logging and auditing System management Threading Message-oriented middleware Object life cycle Resource polling Security Caching
4

11.12.2003

CENG 520 Gokce Banu Laleci

Adds..


a new layer of functions and services between Web servers and underlying applications and databases

11.12.2003

CENG 520 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
CENG 520 Gokce Banu Laleci 6

11.12.2003

Single server / clustered servers

11.12.2003

CENG 520 Gokce Banu Laleci

J2EE based..
J2EE Patterns
TM

11.12.2003

CENG 520 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
CENG 520 Gokce Banu Laleci 9

11.12.2003

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)
CENG 520 Gokce Banu Laleci 10

11.12.2003

Three layered architecture




The presentation layer




managing the user interfaces of applications, including desktop applications, Web browsers, and pervasive devices contains the business logic provides connectivity with enterprise systems and databases
CENG 520 Gokce Banu Laleci 11

The business layer




The back-end layer




11.12.2003

Three layered architecture


Hosting Organization

Subscriber 1 Presentation

Logic Subscriber 2 Persistence

Subscriber 3

11.12.2003

CENG 520 Gokce Banu Laleci

12

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) 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+
CENG 520 Gokce Banu Laleci 13

Thick clients


11.12.2003

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
CENG 520 Gokce Banu Laleci 14

11.12.2003

Presentation Layer


Provides a Web Server




Servlet and JSP results caching and JSP tags caching provides high-reliability, scalability, monitoring, and other features required by enterprise applications plug-ins for Apache, iPlanet, and Microsoft IIS Web servers

11.12.2003

CENG 520 Gokce Banu Laleci

15

Additional Features


Virtual hosting


www.company1.com and www.company2.com scalability and high-availability insulates clients from hardware or power failures by eliminating single points of failure Incoming requests can be distributed across multiple instances of AS
CENG 520 Gokce Banu Laleci 16

Clustering
 

Load balancing


11.12.2003

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 Gokce Banu Laleci

17

Business Layer


contains the applications business logic independent of the user interface, including distributed components, running in the application server environment Enterprise Java Beans

11.12.2003

CENG 520 Gokce Banu Laleci

18

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 interfaces


 

To be reusable To be able to use the AS functionalities

11.12.2003

CENG 520 Gokce Banu Laleci

19

Java Beans vs. EJB




Generic java component model Can be either visible or not Local to a single process on the client side Uses BeanInfo classes to define themselves

Standard for building distributed systems Non-visible remote objects Remotely executable comp. deployed in the server Uses Deployment descriptor to describe itself
20

11.12.2003

CENG 520 Gokce Banu Laleci

Why EJB
      

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
CENG 520 Gokce Banu Laleci 21

11.12.2003

The EJB architecture

11.12.2003

CENG 520 Gokce Banu Laleci

22

What do containers provide


    

Remote invocation Pool and cache services Security Transaction Integration with external data sources

11.12.2003

CENG 520 Gokce Banu Laleci

23

Containers


Interface btw EJBeans & outside world EJB Clients never access an EJB directlyany access is done through containergenerated methods in turn invoke bean methods

11.12.2003

CENG 520 Gokce Banu Laleci

24

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 Gokce Banu Laleci

25

An example

11.12.2003

CENG 520 Gokce Banu Laleci

26

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 methods

11.12.2003

CENG 520 Gokce Banu Laleci

27

An example

11.12.2003

CENG 520 Gokce Banu Laleci

28

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 methods

11.12.2003

CENG 520 Gokce Banu Laleci

29

JNDI


Client API provides naming & directory services for Java Apps Does not replace DNS, CORBA, RMI etc Allows multiple directory services coexist Provides a federated name server
30

11.12.2003

CENG 520 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 =(AccountHome)initialCtx.lookup ("com/~gopalan/Account"); // use the Home Interface to create a Session bean object Account account = home.create (1234, "Athul", 1000671.54d);
11.12.2003 CENG 520 Gokce Banu Laleci 31

EJB Types
  

Entity Beans Session Beans Message-Driven Beans

11.12.2003

CENG 520 Gokce Banu Laleci

32

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
CENG 520 Gokce Banu Laleci 33

11.12.2003

Entity Bean Interface


    

ejbActivate () ejbLoad () ejbPassivate () ejbRemove () ejbStore ()

11.12.2003

CENG 520 Gokce Banu Laleci

34

Persistence


Container Managed Container is responsible for saving state of bean Container needs to generate DB calls Bean persistence is independent of data source specify container-managed fields in Deployment Descriptor

Bean Managed Bean is itself responsible for saving its own state Bean needs to code its own DB calls Bean persistence is hardcoded and is hence less adaptable

11.12.2003

CENG 520 Gokce Banu Laleci

35

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 database 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
CENG 520 Gokce Banu Laleci 36

11.12.2003

Stateless/Stateful
Stateless Session Bean  Have no internal state  need not be passivated or activated  Objects can be pooled to service multiple clients Stateful Session Bean  Have internal state  need to handle Activation/Passivation  One Session Bean object per client

11.12.2003

CENG 520 Gokce Banu Laleci

37

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 Gokce Banu Laleci

38

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 Gokce Banu Laleci

39

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 EJBs can be deployed in a cluster of BEA WebLogic Servers by means of distributed naming and directory facilities
CENG 520 Gokce Banu Laleci 40

Clustering


11.12.2003

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 route requests from remote clients to EJB components using a predetermined algorithm or custom-algorithm
CENG 520 Gokce Banu Laleci 41

Load balancing


11.12.2003

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
CENG 520 Gokce Banu Laleci 42

11.12.2003

Back-End Layer


provides access to other enterprise systems




databases, ERP, CRM, mainframe or other existing applications messaging, e-mail, Web Services, and other technologies to connect and communicate with enterprise systems

Integration layer


11.12.2003

CENG 520 Gokce Banu Laleci

43

Databases


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 Gokce Banu Laleci

44

Integration


 

integrating new applications with any legacy Enterprise Information System (EIS) J2EE Connector Architecture (J2CA) CORBA


integration with legacy systems that implement the CORBA specifications bi-directional interoperability with Microsoft s COM+  can access data in Microsoft applications, communicate with Visual Basic clients
CENG 520 Gokce Banu Laleci 45

COM/DCOM (COM+)


11.12.2003

JCA


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 Gokce Banu Laleci

46

JCA


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 Gokce Banu Laleci

47

JCA


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 Gokce Banu Laleci

48

JCA

11.12.2003

CENG 520 Gokce Banu Laleci

49

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 EIS The resource adapter implements the EISside of these system-level contracts
CENG 520 Gokce Banu Laleci 50

11.12.2003

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 mechanisms A resource adapter is used within the address space of the application server
CENG 520 Gokce Banu Laleci 51

11.12.2003

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
CENG 520 Gokce Banu Laleci 52

11.12.2003

Web Service Support


 

 

Automatically wraps the business components in to Web services 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 conversation A set of convenient graphical tools for development, search, and composing of the Web Services  BEA WebLogic Workshop
CENG 520 Gokce Banu Laleci 53

11.12.2003

Messaging
 

Asynchronous method invocations Why?


  

Performance Reliability Support for multiple senders and receivers


Message Oriented Middleware Application

Application

11.12.2003

CENG 520 Gokce Banu Laleci

54

MOM


Provides
   

Guaranteed message delivery Fault tolerance Load balancing of destinations Subscription mech. Tibco Rendezvous IBM MQSeries BEA Tuxedo/Q Microsoft MSMQ
CENG 520 Gokce Banu Laleci 55

Proprietary solutions
   

11.12.2003

Java Message Service




API


Write code to send and receive msg Plug in JMS drivers




Service Provider Interface (SPI)




to allow existing companies to JMS-enable their applications without impacting client-side development

Supports
 

Publish/subscribe Point-to-point
CENG 520 Gokce Banu Laleci 56

11.12.2003

JMS System
      

ConnectionFactory Connection Session Destination MessageProducer MessageConsumer Message


CENG 520 Gokce Banu Laleci 57

11.12.2003

2:Create Connection 3:Create Session

JMS Connection Factory JMS Connection JMS Session JMS Producer Or JMS Consumer

Client
1:RetrieveJ MS Driver Connection Factory

5:Create Producer or Consumer 6:Send or Receive Message

Serialized Message Connection

4:Lookuo JMS Destination

JMS Driver Client Runtime

JNDI

Naming Service
11.12.2003 CENG 520 Gokce Banu Laleci 58

Example
try { queueConnectionFactory =(QueueConnectionFactory) jndiContext.lookup("QueueConnectionFactory"); queue =(Queue)jndiContext.lookup(queueName); } try { queueConnection = queueConnectionFactory.createQueueConnection(); queueSession = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE); 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()); queueSender.send(message); }
11.12.2003 CENG 520 Gokce Banu Laleci 59

EJB JMS Integration


 

Message Driven Beans Do not have home/remote interface


  

Just to consume messages Not a component interface onMessage method Threading Life cycle management
CENG 520 Gokce Banu Laleci 60

Why not use existing beans


 

11.12.2003

Security
     

 

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
CENG 520 Gokce Banu Laleci 61

11.12.2003

Adding security to EJB




JAAS
 

Portable interface Java applications to remain independent from underlying authentication technologies Basic Digest Certificate
CENG 520 Gokce Banu Laleci 62

Authentication
  

11.12.2003

Authorization


Programmatic


Hard code security checks in to your bean code Through deployment descriptor Container handles the rest

Declarative
 

11.12.2003

CENG 520 Gokce Banu Laleci

63

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 Gokce Banu Laleci

64

Example role definition

11.12.2003

CENG 520 Gokce Banu Laleci

65

Example method permission

11.12.2003

CENG 520 Gokce Banu Laleci

66

Transaction


A series of operations that appear to execute as one large atomic operation


 

All-or-nothing Allow multiple users to share the same data Atomicity




ACID


Many operations are bundled together and appear as one atomic unit

11.12.2003

CENG 520 Gokce Banu Laleci

67

ACID


Consistency


A transaction leaves the system in a consistent state Protects concurrently executing transactions from seeing each others incomplete results Guarantees that updates to managed resources, such as database records, survive failures
CENG 520 Gokce Banu Laleci 68

Isolation


Durability


11.12.2003

Transaction


Type
 

Flat Nested Resource managers are transaction aware They do no not make the changes persistent until a commit statement issued

Rollback is not an undo logic


 

11.12.2003

CENG 520 Gokce Banu Laleci

69

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 Gokce Banu Laleci

70

Programmatic Transactions


Put the transaction logic in to your application code The programmer is responsible for issuing


begin, commit and abort


EJB Container 2:delegate 3:call begin

Client Code
1:call method

EJB object

EJB
4:perform business operations
11.12.2003

Transaction Service

5:call commit or abort

CENG 520 Gokce Banu Laleci

71

Declarative Transactions
 

EJB container handles Declare in deployment descriptor

11.12.2003

CENG 520 Gokce Banu Laleci

72

Declarative Transactions
Client Code
1:call method 3:call begin EJB Container

EJB object
2:delegate

5:call commit or abort

Transaction Service

EJB
4:perform business operations

11.12.2003

CENG 520 Gokce Banu Laleci

73

Client Initiated Transactions


EJB Container 3:call begin 5:call commit or abort 1:call method

Client Code

Transaction Service

EJB object
2:delegate

EJB
4:perform business operations

11.12.2003

CENG 520 Gokce Banu Laleci

74

Container-Managed Transactions


Bean deployer has to provide instructions to the container


 

Deployment descriptor Transaction Attributes


 

Entire bean Individual methods

11.12.2003

CENG 520 Gokce Banu Laleci

75

Transaction Attribute Values

11.12.2003

CENG 520 Gokce Banu Laleci

76

Transaction Attribute Values


Transaction Attribute Clients transaction
none T1 none T1 none T1 none T1 none T1 none T1
CENG 520 Gokce Banu Laleci

Beans transaction
T2 T1 T2 T2 None T1 Error T1 None None None error
77

Required RequiresNew Supports Mandatory NotSupported Never


11.12.2003

Programmatic Transactions


CORBAs 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 Gokce Banu Laleci

78

Java Transaction Service




Corba OTS
 

Java Transaction Service Java Transaction API To have various vendors to interoperate Used by AS Application developers Programmaticaly control transaction boundaries
CENG 520 Gokce Banu Laleci 79

JTA JTS OTS


 

JTA
 

11.12.2003

Java Transaction API


     

begin() Commit() getStatus() rollBack() setRollbackOnly() setTransactionTimeout()

11.12.2003

CENG 520 Gokce Banu Laleci

80

Example

11.12.2003

CENG 520 Gokce Banu Laleci

81

Anda mungkin juga menyukai