J2EE/WS/SOA Training

37
J2EE/WS/SOA Training

Transcript of J2EE/WS/SOA Training

Page 1: J2EE/WS/SOA Training

J2EE/WS/SOA Training

Page 2: J2EE/WS/SOA Training

OSS/J OverviewTMW Dallas, November 2005

Page 2www.ossj.org

Scope/ContentsScope/Contents

J2EE concepts J2EE components Service Oriented Architectures Web Services How they all tie together

Page 3: J2EE/WS/SOA Training

OSS/J OverviewTMW Dallas, November 2005

Page 3www.ossj.org

J2EETM – A brief historyJ2EETM – A brief history

Java EE (formerly J2EE™) was released with Java 1.2

Developing and running distributed multi-tier architecture applications.

Component-based approach to design, development, assembly and deployment of enterprise applications.

Introduced Enterprise Java Beans, Servlets, JSPs and Web

Page 4: J2EE/WS/SOA Training

OSS/J OverviewTMW Dallas, November 2005

Page 4www.ossj.org

What is J2EEWhat is J2EE

J2EE is not a technology, nor a system, but simply an implementation of a set of specifications. is platform middleware a comprehensive set of specifications for a platform that

supports the development of robust and feature rich distributed systems specifications that were written with managing general

distributed systems in mind, not any particular domain. technology neutral (agnostic) and scalable has clearly defined standardized interfaces which are

build to integrate seamlessly with other applications that support these interfaces.

Page 5: J2EE/WS/SOA Training

OSS/J OverviewTMW Dallas, November 2005

Page 5www.ossj.org

What is J2EEWhat is J2EE

Component-based model which is reusable, scalable, modular and easy to integrate. Well architected implementation for

development of managed systems. Reduced integration time Reuse helps reduce the development time Web Services support through integrated data

interchange on Extensible Markup Language (XML)-based open standards and protocols

Page 6: J2EE/WS/SOA Training

OSS/J OverviewTMW Dallas, November 2005

Page 6www.ossj.org

J2EE ConceptsJ2EE Concepts

Abstraction Encapsulation Modularity Interface-driven Reusability Component-based Technology Neutral Interoperability Write-once run/test everywhere

Page 7: J2EE/WS/SOA Training

OSS/J OverviewTMW Dallas, November 2005

Page 7www.ossj.org

J2EE ConceptsJ2EE Concepts

Multi-tiered (3-tier or MVC) 3-tiered since they are

distributed over 3 locations. Middle layer is a multi-

threaded J2EE application server

Any tier can be replaced/upgraded independently as requirements or technology change

Tiers could work across various operating systems or different legacy systems

Modular Advantage over simple client

server architecture.

Client TierApplicationClient/Applet

DynamicHTML Pages

EJBs

JSPPages

EJBs

DatabaseLegacy

Application

Web Tier

Business Tier

EIS Tier

J2EEApplication

J2EEApplication

Client Machine

J2EE ComplaintApplicationServer

Other Servers

Page 8: J2EE/WS/SOA Training

OSS/J OverviewTMW Dallas, November 2005

Page 8www.ossj.org

J2EE componentsJ2EE components

Page 9: J2EE/WS/SOA Training

OSS/J OverviewTMW Dallas, November 2005

Page 9www.ossj.org

J2EE ComponentsJ2EE Components

Self-contained unit of deployment that contains the implementation of value-added services which are instantiated and executed within a container.

Client Components contain: Application Clients Applets

Web Components contain: JSP Pages Servlets

Business Components contain: Enterprise JavaBeans™

Page 10: J2EE/WS/SOA Training

OSS/J OverviewTMW Dallas, November 2005

Page 10www.ossj.org

Client Components -Application ClientsClient Components -Application Clients

Java™ Applications that access services provided by a J2EE Application Server.

Use these when a “thick”client is required.

Used when a richer user interface is required.

Typically a GUI created from Swing or AWT.

Can access business tier, or open HTTP connection to web tier.

0

20

40

60

80

100

1st Qtr 2n d Qtr 3r d Qtr 4th QtrEast

We st

Nor th

80-100

60-80

40-60

20-40

0-20

Thick Application ClientClient Machine

Application ClientContainer

ApplicationClient

ApplicationServer

DBMS

WebServer

Richer, interactiveGUI (graphs, menus)

Page 11: J2EE/WS/SOA Training

OSS/J OverviewTMW Dallas, November 2005

Page 11www.ossj.org

Client Components - Applet ClientsClient Components - Applet Clients

An applet is a Java class that Must subclass from

java.applet.Applet Is embedded within an HTML

page Is invoked and executed with the

context of a Java-enabled HTML browser

Runs in the JVM in the web browser.

Very secure Can not create files local to the

platform hosting the browser Can only communicate back to

the server from which it has been/was downloaded.

Application Client

Client Machine

Browser

Applet

ApplicationServer

DBMS

WebServer

AppletdownloadedfromWeb Server

Applet can run only inside a browser

Page 12: J2EE/WS/SOA Training

OSS/J OverviewTMW Dallas, November 2005

Page 12www.ossj.org

Client Components – Web ClientsClient Components – Web Clients

Also called ‘thin’ clients Dynamic web pages

generated by web components

All ‘heavy weight’operations off-loaded to enterprise beans on the J2EE server Web clients do not directly

query databases, run business processes or connect to legacy systems.

Trade-offs between thick and thin clients.

Client

Client Machine

Browser

HTML/JS

ApplicationServer

DBMS

WebServer

HTML / DHTMLpagesdownloadedfrom Web Server

Applet can run only inside a browser

WebTier

BusinessTier

ApplicationClient Container

Web BrowserWeb Pages

Applets

ApplicationClient

Client Tier

Page 13: J2EE/WS/SOA Training

OSS/J OverviewTMW Dallas, November 2005

Page 13www.ossj.org

Web Components - ServletsWeb Components - Servlets

A servlet is Used to extend the capabilities of the application server Accessed via a request-response programming model Draw servlet specific diagram. Implemented as a class that inherits from

javax.servlet.Servlet

BusinessTierClient Tier Web Tier

Web Container

JSPPages

Servlets

Page 14: J2EE/WS/SOA Training

OSS/J OverviewTMW Dallas, November 2005

Page 14www.ossj.org

Web Components - JSPWeb Components - JSP

When your interface requires dynamic content

Two parts Static content provided by the normal textual

elements (XML, XHTML, HTML, etc) Dynamic content provided by JSP elements

Client TierWeb Container

= DynamicHTML / JSServlets +JSP

PagesJSPCompiler

Page 15: J2EE/WS/SOA Training

OSS/J OverviewTMW Dallas, November 2005

Page 15www.ossj.org

Business Components - EJBsBusiness Components - EJBs

Not to be confused with JavaBeans™ Three types

Session Beans Stateless Stateful

Entity Beans Container Managed Persistence Bean Managed Persistence

Message Driven Beans

EIS Tier

Client Tier

Business Tier

EntityBeans

SessionBeans

MessageDriven BeansWeb Tier

WebContainer

JSPPages

Servlets

Page 16: J2EE/WS/SOA Training

OSS/J OverviewTMW Dallas, November 2005

Page 16www.ossj.org

EJBs – Session beansEJBs – Session beans

Stateful Per client instantiation Can still be pooled by the appserver

Returned to pool after the client has disconnected/disposed

Stateless A shared pool One instance is equivalent to the next

Page 17: J2EE/WS/SOA Training

OSS/J OverviewTMW Dallas, November 2005

Page 17www.ossj.org

EJBs – Session beansEJBs – Session beans

Stateless can improve performance and scalability Cost of reconstruction of context Cost of number of required instances

Study the interaction patterns and cardinality issues

Page 18: J2EE/WS/SOA Training

OSS/J OverviewTMW Dallas, November 2005

Page 18www.ossj.org

EJBs – Entity beansEJBs – Entity beans

Provide data and business logic in one convenient place

Provide a transparent programmatic interface to data within a database

Implement the javax.ejb.EntityBean interface

2 flavors of persistence… Container managed persistence (CMP) Bean managed persistence (BMP)

Page 19: J2EE/WS/SOA Training

OSS/J OverviewTMW Dallas, November 2005

Page 19www.ossj.org

EJBs – Message-driven beansEJBs – Message-driven beans

An server-side component that allows a J2EE application to process messages in an asynchronous manner

Acts as a JMS listener Resembles a stateless session bean

No data or conversational state for clients All instances of an MDB are equivalent A single MDB can process messages from

multiple clients

Page 20: J2EE/WS/SOA Training

OSS/J OverviewTMW Dallas, November 2005

Page 20www.ossj.org

ContainersContainers

Interface between a component and the low-level platform-specific functionality that supports the component.

Hard-working second class citizens Intercept requests, instantiate EJBs, maintain bean pools, manage

threads. Provide services like security, transaction management, JNDI lookups

and remote connectivity. EJB and servlet life cycle management, database connection resource

pooling, data persistence.

EIS Tier J2EE compliantApplication Server

Low levelPlatform Specific

Functiona lity/Code

Web Container

JSPPages

Servlets

EJB Conta iner

EJBs EJBs

Client Tier

Page 21: J2EE/WS/SOA Training

OSS/J OverviewTMW Dallas, November 2005

Page 21www.ossj.org

ContainersContainers

Components are deployed in the container. Provide the runtime support for application

components Applet Container Application Client Container Web Container EJB Container

Advantages No code to be written to handle transaction, state

management, multi-threading, resource pooling and other complex low-level details.

If the container is J2EE complaint, you’re sure it will work.

Only concentrate on developing the business logic.

J2EE containerBean PoolIncoming Request

Response

Container takescare of beanmanagement

J2EE containerBean PoolBean PoolIncoming Request

Response

Container takescare of beanmanagement

Container takescare of beanmanagement

Page 22: J2EE/WS/SOA Training

OSS/J OverviewTMW Dallas, November 2005

Page 22www.ossj.org

J2EE – Service Oriented ArchitecturesJ2EE – Service Oriented Architectures

SOA is not Web Services A web service may or may

not be service oriented. SOA is a collection of

services that communicate with each other

Exchange data/info or co-ordinate some activity

In past implemented with DCOM and ORB based on CORBA spec

Now implemented with J2EE

Integrates seamlessly with the multi-tier J2EE development architecture

Internal Web Services

ExistingDBMS

DatabaseInternal SystemInternal System

ExistingInternalSystems

Adapter

MessageRouter Legacy

Application

AdapterAdapter

XML Firewall

Firewall

Middle-tierDBMS

WebServer

Cache

ApplicationServer

EIS Tier

Web Services External Web Services

Middle Tier

Internet

Web Services internal to theorganization and trusted 3rd parties

Data cache fordatabase in EIS

Access to otherWeb Services onthe Internet

Could be other relationaldatabases. Could also existin EIS tier

Contains deployedcomponents (EJBs, JSPs)

Page 23: J2EE/WS/SOA Training

OSS/J OverviewTMW Dallas, November 2005

Page 23www.ossj.org

SOA – ComponentsSOA – Components

Service (Service Endpoints) Well-defined, self-contained, independent function. End point of a connection

Connections Channel over which communication happens

Request, response, provider, consumer XML may or may not be used as the default

message format

Service Provider Service Consumer

Service Request

Service Response

Page 24: J2EE/WS/SOA Training

OSS/J OverviewTMW Dallas, November 2005

Page 24www.ossj.org

SOA – AdvantagesSOA – Advantages

Loose Coupling Asynchronous Robust Encapsulation Reusable Modularity Technology Agnostic Interoperable (Web Services)

Gartner reports that "By 2008, SOA will be a prevailing softwareengineering practice, ending the 40-year domination of monolithic software architecture" and that "Through 2008, SOA and web services will be implemented together in more than 75 percent of new SOA or Web Services projects."

Page 25: J2EE/WS/SOA Training

OSS/J OverviewTMW Dallas, November 2005

Page 25www.ossj.org

J2EE – Web ServicesJ2EE – Web Services

Web Service is a service/functionality defined/implemented according to WSDL and accessed using HTTP-SOAP.

Related to SOA? Web Service has the following constraints:

Interfaces based on HTTP, FTP, SMTP Messages in XML except Binary data

attachments

Page 26: J2EE/WS/SOA Training

OSS/J OverviewTMW Dallas, November 2005

Page 26www.ossj.org

Web Services - SOAPWeb Services - SOAP

SOAP Used to be Simple Object Access Protocol Originally designed for RPC Service Description in WSDL All messages except attachments must be in

HTTP-SOAP SOAP-RPC and document-centric SOAP WS

Page 27: J2EE/WS/SOA Training

OSS/J OverviewTMW Dallas, November 2005

Page 27www.ossj.org

Other components of Web Services - WSDLOther components of Web Services - WSDL

WSDL Web Services Definition Language XML format for describing network services as a set of

endpoints operating on messages Defines a binding mechanism to attach abstract services

to specific network addresses. Binding extensions for SOAP 1.1, HTTP and MIME. Consists of:

Definitions Types Messages

Operations (defined in a portType) Service bindings

Binding Port Service

Page 28: J2EE/WS/SOA Training

OSS/J OverviewTMW Dallas, November 2005

Page 28www.ossj.org

Other components of Web Services - WSDLOther components of Web Services - WSDL

WSDL document structure

MessageDefinitions

Definitions

Operation

Operation

Port Type

Operations Service Bindings

Data TypeDefinitions

Data TypeDefinitions

Data TypeDefinitions

Data TypeDefinitions

MessageDefinitions

Binding Port A

Port B

Port C

Service A

Page 29: J2EE/WS/SOA Training

OSS/J OverviewTMW Dallas, November 2005

Page 29www.ossj.org

Other components of Web Services - UDDIOther components of Web Services - UDDI

UDDI Universal Description, Discovery, and

Integration (UDDI) provides the definition of a set of services supporting the description and discovery of (1) businesses, organizations, and other Web

Services providers, (2) the Web Services they make available, and (3) the technical interfaces which may be used to

access those services. Yellow/White pages

Page 30: J2EE/WS/SOA Training

OSS/J OverviewTMW Dallas, November 2005

Page 30www.ossj.org

Web Services – SOAP ExampleWeb Services – SOAP Example

A service provider describes its service using WSDL. This definition is published to a directory of services like Universal Description, Discovery, and Integration (UDDI).

A service consumer issues one or more queries to the directory to locate a service and determine how to communicate with that service.

Part of the WSDL provided by the service provider is passed to the service consumer. This tells the service consumer what the requests and responses are for the service provider.

The service consumer uses the WSDL to send a request to the service provider.

The service provider provides the expected response to the service consumer.

1. Serv

ice D

escriptio

n usin

g WSDL

3. Query Response using WSDL

2. Directory Queries

4. Service Description using WSDL

5. XML Service Response based on WSDL

Service Provider Service Consumer

SOAPMessages

Directory

Page 31: J2EE/WS/SOA Training

OSS/J OverviewTMW Dallas, November 2005

Page 31www.ossj.org

Web Services and SOAWeb Services and SOA

A Web Service running on a Web Server in a SOA add another layer to abstraction to help interoperability

Service Provider Service Consumer

Service Request

Service Response

ServiceProvider/Consumer

Web Services + UDDI

ServiceProvider/Consumer

Page 32: J2EE/WS/SOA Training

OSS/J OverviewTMW Dallas, November 2005

Page 32www.ossj.org

J2EE supports Web ServicesJ2EE supports Web Services

Web Service implementation runs inside a web container (Web server)

Can write Web Services on top of an application to expose some of the application functionality as a service

Internal Web Services

ExistingDBMS

DatabaseInternal SystemInternal System

ExistingDBMS

ExistingInternalSystems

Adapter

MessageRouter Legacy

Application

AdapterAdapter

XML Firewall

Firewall

Middle-tierDBMS

WebServer

Cache

ApplicationServer

EIS Tier

Web Services External Web Services

Middle Tier

Internet

Web Services internal to theorganization and trusted 3rd parties

Data cache fordatabase in EIS

Access to otherWeb Services onthe Internet

Could be other relationaldatabases. Could also existin EIS tier

Contains deployedcomponents (EJBs, JSPs)

Page 33: J2EE/WS/SOA Training

Additional Slides

Page 34: J2EE/WS/SOA Training

OSS/J OverviewTMW Dallas, November 2005

Page 34www.ossj.org

Web Services Distributed ManagementWeb Services Distributed Management

Composed of Management Using Web Services (MUWS):

Enables management of distributed systems Management Of Web Services (MOWS):

Addresses management of Web service end-points using Web Services protocols.

Based on MUWS specification.

Page 35: J2EE/WS/SOA Training

OSS/J OverviewTMW Dallas, November 2005

Page 35www.ossj.org

J2EE – Databases (JDBC)J2EE – Databases (JDBC)

The J2EE Platform specifies that a J2EE Application Server must support connection to databases via the JDBC™ API.

There is an explicit requirement that the all clients, with the notable exception of applet based clients be capable of accessing the database. That is to say that there is not a requirement on a platform vendor to support access to a database from an

applet client ============================== The Java Database Connection API Based on X/Open SQL CLI (which is also the basis for ODBC Included in the J2SE™ 1.4 distribution First introduced in 1997 Current Version is 3.0 ============================= Provided a few critically needed updates to the capabilities of the JDBC interface

SavePoint interface set, release, and rollback

Retrieval of Parameter metadata Auto-generated Keys

Allow for multiple open ResultSet objects Holdable cursor support New datatypes

Boolean (go figure) DATALINK/URL

Page 36: J2EE/WS/SOA Training

OSS/J OverviewTMW Dallas, November 2005

Page 36www.ossj.org

Java Messaging ServiceJava Messaging Service

Providers Clients Messages Queues Topics

JMS Provider

Message Queue(Point-to-Point)Client Client

MessageTopic

(pub-sub)

Client

Page 37: J2EE/WS/SOA Training

OSS/J OverviewTMW Dallas, November 2005

Page 37www.ossj.org

JMXJMX

Should this be included?