distributed computing and java - · pdf filedistributed computing and java ... what is the...

78
Distributed Computing and Java Sang Shin Java Technology Evangelist [email protected]

Upload: ngohanh

Post on 03-Mar-2018

238 views

Category:

Documents


4 download

TRANSCRIPT

Page 1: Distributed Computing and Java - · PDF fileDistributed Computing and Java ... What Is the Java™ 2 Platform, Enterprise Edition ... Java 2 Platform, Enterprise Edition API and Technology

Distributed Computing and Java™

Sang ShinJava™ Technology Evangelist

[email protected]

Page 2: Distributed Computing and Java - · PDF fileDistributed Computing and Java ... What Is the Java™ 2 Platform, Enterprise Edition ... Java 2 Platform, Enterprise Edition API and Technology

2

Topics

Overview of Distributed computing Java APIs for distributed computing

JDBCRMIJava IDL (Corba)Java Servlets and JSPJ2EE™

Jini™ Network Technology and JavaSpaces (We will learn from next week)

Page 3: Distributed Computing and Java - · PDF fileDistributed Computing and Java ... What Is the Java™ 2 Platform, Enterprise Edition ... Java 2 Platform, Enterprise Edition API and Technology

3

Objectives

Understand the value of distributed computing (network computing)

Get some exposure to the evolution of distributed computing

Understand the 7 fallacies of distributed computing

Get some exposure to distributed computing technologies of Java

Page 4: Distributed Computing and Java - · PDF fileDistributed Computing and Java ... What Is the Java™ 2 Platform, Enterprise Edition ... Java 2 Platform, Enterprise Edition API and Technology

Overview ofDistributed Computing (Network Computing)

Page 5: Distributed Computing and Java - · PDF fileDistributed Computing and Java ... What Is the Java™ 2 Platform, Enterprise Edition ... Java 2 Platform, Enterprise Edition API and Technology

5

Virtual Fish Tank

“Most people grow up with a 'centralized mindset,' assuming that organized patterns can be created only by centralized control. The VFT exhibit helps people move beyond the centralized mindset, giving them a chance to create and participate in an artificial ecosystem -- and learn how patterns can, in fact, arise from decentralized interactions.”- Michael Resnick, MIT Media Lab

Page 6: Distributed Computing and Java - · PDF fileDistributed Computing and Java ... What Is the Java™ 2 Platform, Enterprise Edition ... Java 2 Platform, Enterprise Edition API and Technology

Things - 1014

Computers 108

Embedded Computers

1011

Desktops

TransfersTransfers TransactionsTransactions ContentContent Telemetry Telemetry ControlControl

Clients

Functions

Organization

Protocols

Waves of Network Computing

IP v6IP v4 IP Layer

SwitchesSwitches

PackagesPackages

ThermostatsThermostats

ClothesClothesPhonesPhones

TVsTVsCarsCars

GamesGames

Page 7: Distributed Computing and Java - · PDF fileDistributed Computing and Java ... What Is the Java™ 2 Platform, Enterprise Edition ... Java 2 Platform, Enterprise Edition API and Technology

Things - 1014

Computers 108

Embedded Computers

1011

Desktops

Client/Server

Web ApplicationsWeb Applications

Web Web ServicesServices

FractalFractal

PolyarchicalPolyarchical

N-tier

FTPTelnet

HTTPXRPC/XDR

SMTP

Clients

Functions

Organization

Protocols

SOAPSOAPRMI/IIOPRMI/IIOP

JiniJiniIdentityIdentity

UDDIUDDI

LDAPLDAP

JXTAJXTA

Waves of Network Computing

IP v6IP v4 IP Layer

PhonePhoness

TVsTVsCarsCars

GamesGames

SwitchesSwitches

PackagesPackages

ThermostatsThermostats

ClothesClothes

TransfersTransfers TransactionsTransactions ContentContent TelemetryTelemetry ControlControl

Page 8: Distributed Computing and Java - · PDF fileDistributed Computing and Java ... What Is the Java™ 2 Platform, Enterprise Edition ... Java 2 Platform, Enterprise Edition API and Technology

Platform EvolutionCatchCatchPhrasePhrase

The NetworkThe NetworkIs the Is the

ComputerComputer ObjectsObjectsLegacy to Legacy to the Webthe Web

The Computer The Computer Is theIs the

NetworkNetwork

Network of Network of Embedded Embedded

ThingsThingsNetworkNetworkof Thingsof Things

ScaleScale

When/PeakWhen/Peak

LeafLeafProtocol(s)Protocol(s)

DirectoryDirectory(s)(s)

SessionSession

100s100s 1,000s1,000s 1,000,000s1,000,000s 10,000,000s10,000,000s 100,000,000s100,000,000s 100,000,000100,000,000ss

1984/19871984/1987 1990/19931990/1993 1996/19991996/1999 2001/20032001/2003 1998/20041998/2004 2004/20072004/2007

XX XX +HTTP+HTTP(+JVM)(+JVM)

+XML+XMLPortalPortal +RMI+RMI UnknownUnknown

NS, NS+NS, NS+ +CDS+CDS +LDAP(*)+LDAP(*)+UDDI+UDDI

+ebXML +ebXML reg/repreg/rep

+Jini +Jini Lookup Lookup serviceservice

+?+?

RPC, XDRRPC, XDR +CORBA+CORBA +CORBA,+CORBA,RMIRMI

+SOAP,+SOAP,XMLXML +RMI/Jini+RMI/Jini +?+?

SchematicSchematic

Page 9: Distributed Computing and Java - · PDF fileDistributed Computing and Java ... What Is the Java™ 2 Platform, Enterprise Edition ... Java 2 Platform, Enterprise Edition API and Technology

Design Patterns

Client-Server 3-Tier

Web Application

Web Services

HybridP2P Fractal

Page 10: Distributed Computing and Java - · PDF fileDistributed Computing and Java ... What Is the Java™ 2 Platform, Enterprise Edition ... Java 2 Platform, Enterprise Edition API and Technology

10

Three Laws of Computing Moore's Law

Computing power doubles every 18 months

Gilder's LawNetwork bandwidth capacity doubles

every 12 months Metcalfe's Law (Net Effect)

Value of network increases exponentially as number of participants increases

Page 11: Distributed Computing and Java - · PDF fileDistributed Computing and Java ... What Is the Java™ 2 Platform, Enterprise Edition ... Java 2 Platform, Enterprise Edition API and Technology

11

Public Internet

Corporate Internet

Firewall

WorkgroupServer

WebServerTelco

Server

Pager

Cell Phone

Thin Client

Thin Client

PDA

NT Workstation

Solaris™

Workstation

Solaris Workstation

VideoServer

Current Enterprise Reality

Page 12: Distributed Computing and Java - · PDF fileDistributed Computing and Java ... What Is the Java™ 2 Platform, Enterprise Edition ... Java 2 Platform, Enterprise Edition API and Technology

12

What is a distributed system?

A collection of processes/processors that do not share memory or a clock

Page 13: Distributed Computing and Java - · PDF fileDistributed Computing and Java ... What Is the Java™ 2 Platform, Enterprise Edition ... Java 2 Platform, Enterprise Edition API and Technology

13

Why Distributed Systems?

Resource sharing Higher performance Flexible Reliable Scalable Cheaper Manage’able (it depends)

Page 14: Distributed Computing and Java - · PDF fileDistributed Computing and Java ... What Is the Java™ 2 Platform, Enterprise Edition ... Java 2 Platform, Enterprise Edition API and Technology

14

Characteristics of Distributed Systems Complex programming Heterogeneous

Hardware, OS, networking behavior, object model, programming language

Inherent problemsNetwork latencyConcurrency issuesPartial Failure

Page 15: Distributed Computing and Java - · PDF fileDistributed Computing and Java ... What Is the Java™ 2 Platform, Enterprise Edition ... Java 2 Platform, Enterprise Edition API and Technology

15

7 Fallacies of Distributed Computing The network is reliable Latency is zero Bandwidth is infinite The network is secure Topology doesn't change There is one administrator Transport cost is zero

Page 16: Distributed Computing and Java - · PDF fileDistributed Computing and Java ... What Is the Java™ 2 Platform, Enterprise Edition ... Java 2 Platform, Enterprise Edition API and Technology

16

Terminology

Naming and TransparencyLocation transparency Location Independence

Stateful vs. Stateless Failure Detection and Recovery

ReplicationLog based Recovery

Parameter Marshaling/Unmarshaling

Page 17: Distributed Computing and Java - · PDF fileDistributed Computing and Java ... What Is the Java™ 2 Platform, Enterprise Edition ... Java 2 Platform, Enterprise Edition API and Technology

17

Distributed Coordination

Mutual Exclusion Atomicity Concurrency Control Deadlock Handling Election Algorithms Transaction

2 phase commit

Page 18: Distributed Computing and Java - · PDF fileDistributed Computing and Java ... What Is the Java™ 2 Platform, Enterprise Edition ... Java 2 Platform, Enterprise Edition API and Technology

18

Distributed Systems

Evolution

RPC (procedural)

ORB(object based)

80s

RMI(object oriented)

90s

Page 19: Distributed Computing and Java - · PDF fileDistributed Computing and Java ... What Is the Java™ 2 Platform, Enterprise Edition ... Java 2 Platform, Enterprise Edition API and Technology

19

Early Distributed Systems

RPCDCE, ONC

Distributed File Systemsexample - NFS, SMB

Databasesexample - Oracle

Transaction Processing Monitorsexample - CICS

Page 20: Distributed Computing and Java - · PDF fileDistributed Computing and Java ... What Is the Java™ 2 Platform, Enterprise Edition ... Java 2 Platform, Enterprise Edition API and Technology

20

At the root of it all ...

SocketsSocket, ServerSocket, SocketImpl classes

UsesData compressionmulticastcustom protocols, etc.

Page 21: Distributed Computing and Java - · PDF fileDistributed Computing and Java ... What Is the Java™ 2 Platform, Enterprise Edition ... Java 2 Platform, Enterprise Edition API and Technology

JDBC

Page 22: Distributed Computing and Java - · PDF fileDistributed Computing and Java ... What Is the Java™ 2 Platform, Enterprise Edition ... Java 2 Platform, Enterprise Edition API and Technology

22

What is JDBC?

Java APIs for manipulating relational databases

Uses standardized SQL

Page 23: Distributed Computing and Java - · PDF fileDistributed Computing and Java ... What Is the Java™ 2 Platform, Enterprise Edition ... Java 2 Platform, Enterprise Edition API and Technology

23

JDBC Architecture

MS SQL

SPISybasedriver

DB2driver

Oracledriver

JDBC Driver Manager

BridgeODBC

Sybase DB2 Oracle

Java application Java application

JDBC API

Page 24: Distributed Computing and Java - · PDF fileDistributed Computing and Java ... What Is the Java™ 2 Platform, Enterprise Edition ... Java 2 Platform, Enterprise Edition API and Technology

24

A 2-tier Example

Database

Database

Frontend

Frontend

Frontend

JDBC

Page 25: Distributed Computing and Java - · PDF fileDistributed Computing and Java ... What Is the Java™ 2 Platform, Enterprise Edition ... Java 2 Platform, Enterprise Edition API and Technology

25

JDBC Status

Core API in JDK 1.1 onwards JDBC 3.0 Core and Extension API

currently available JDBC drivers available for wide-range

relational databases

Page 26: Distributed Computing and Java - · PDF fileDistributed Computing and Java ... What Is the Java™ 2 Platform, Enterprise Edition ... Java 2 Platform, Enterprise Edition API and Technology

26

JDBC Resources

Java Packagesjava.sqljavax.sql

Websites java.sun.com/products/jdbc

BooksDatabase Programming with JDBC and

Java by George E. Reese, George H. Reese

Page 27: Distributed Computing and Java - · PDF fileDistributed Computing and Java ... What Is the Java™ 2 Platform, Enterprise Edition ... Java 2 Platform, Enterprise Edition API and Technology

RMI (Remote Method Invocation)

Page 28: Distributed Computing and Java - · PDF fileDistributed Computing and Java ... What Is the Java™ 2 Platform, Enterprise Edition ... Java 2 Platform, Enterprise Edition API and Technology

28

What is RMI?

New Distributed system paradigm Natural extension of the OO paradigm Seamless integration of objects (objects

everywhere) Allows method invocation across JVM

boundaries Can pass or receive objects to/from

remote object Code moves with the object (code movement)

Distributed garbage collection Activation

Page 29: Distributed Computing and Java - · PDF fileDistributed Computing and Java ... What Is the Java™ 2 Platform, Enterprise Edition ... Java 2 Platform, Enterprise Edition API and Technology

29

A 3-tier Example

Database

Database

Frontend

Frontend

Frontend

Business Logic

RMI JDBC

Page 30: Distributed Computing and Java - · PDF fileDistributed Computing and Java ... What Is the Java™ 2 Platform, Enterprise Edition ... Java 2 Platform, Enterprise Edition API and Technology

30

RPC Architecture (General)

ClientProxy

ServerProxy

Wire

The proxies deal with parameter marshaling/unmarshaling

Page 31: Distributed Computing and Java - · PDF fileDistributed Computing and Java ... What Is the Java™ 2 Platform, Enterprise Edition ... Java 2 Platform, Enterprise Edition API and Technology

31

RMI Architecture

JavaClient

Stub

JavaServer

Skeleton

The Stubs/Skeletons deal with Serializing/De-serializing

JRMP

Page 32: Distributed Computing and Java - · PDF fileDistributed Computing and Java ... What Is the Java™ 2 Platform, Enterprise Edition ... Java 2 Platform, Enterprise Edition API and Technology

32

Class Loading

RMI loads classes if not available locallyRemote object, stub, skeleton, parameter

and return value classes Loaded classes subject to installed

security manager

ClientServer

Lookup

Remote Reference + stub code

Page 33: Distributed Computing and Java - · PDF fileDistributed Computing and Java ... What Is the Java™ 2 Platform, Enterprise Edition ... Java 2 Platform, Enterprise Edition API and Technology

33

Object Serialization

Used for passing objects by value Write/read objects and graphs of objectsLightweight PersistenceObjects are converted into byte streamsCustomization on a per-class basis is

possible

Page 34: Distributed Computing and Java - · PDF fileDistributed Computing and Java ... What Is the Java™ 2 Platform, Enterprise Edition ... Java 2 Platform, Enterprise Edition API and Technology

34

RMI Development Process

Four step development Define the interfaces to your remote

objects Implement the remote objects Run rmic on remote implementation

classes Make code network-accessible

Page 35: Distributed Computing and Java - · PDF fileDistributed Computing and Java ... What Is the Java™ 2 Platform, Enterprise Edition ... Java 2 Platform, Enterprise Edition API and Technology

35

RMI Deployment

rmiregistryProvides a bootstrap service to locate the

first server object Start the server Start the client

Page 36: Distributed Computing and Java - · PDF fileDistributed Computing and Java ... What Is the Java™ 2 Platform, Enterprise Edition ... Java 2 Platform, Enterprise Edition API and Technology

36

RMI Status

Core since JDK 1.1 New Features in JDK 1.2

Activation Custom socket types API enhancements Performance improvements

Page 37: Distributed Computing and Java - · PDF fileDistributed Computing and Java ... What Is the Java™ 2 Platform, Enterprise Edition ... Java 2 Platform, Enterprise Edition API and Technology

37

Customer Feedback

Many customers like RMI: Easy to program No need to learn separate IDL Supports full Java programming language

semantics (value objects) Ideal for communication between Java

applications

Page 38: Distributed Computing and Java - · PDF fileDistributed Computing and Java ... What Is the Java™ 2 Platform, Enterprise Edition ... Java 2 Platform, Enterprise Edition API and Technology

38

Customer Feedback (Cont’d)

Many customers like CORBA: Standardizing on CORBA IDL and IIOP Multi-vendor Cross-language Allows communication between Java

applications and C++ Common input: Why not RMI over

IIOP?

Page 39: Distributed Computing and Java - · PDF fileDistributed Computing and Java ... What Is the Java™ 2 Platform, Enterprise Edition ... Java 2 Platform, Enterprise Edition API and Technology

39

RMI over IIOP

RMI over IIOP supports a large subset of JDK 1.1 RMI API over CORBA IIOP

Joint work between: IBM, Netscape, Oracle, Sun, Visigenic

With input from many other partners

Page 40: Distributed Computing and Java - · PDF fileDistributed Computing and Java ... What Is the Java™ 2 Platform, Enterprise Edition ... Java 2 Platform, Enterprise Edition API and Technology

40

RMI over IIOP

Page 41: Distributed Computing and Java - · PDF fileDistributed Computing and Java ... What Is the Java™ 2 Platform, Enterprise Edition ... Java 2 Platform, Enterprise Edition API and Technology

41

RMI over IIOP (Simplified)

Java ClientORB

AnyServerORBIIOP

The ORBs deal with parameter marhalling/unmarshalling

Page 42: Distributed Computing and Java - · PDF fileDistributed Computing and Java ... What Is the Java™ 2 Platform, Enterprise Edition ... Java 2 Platform, Enterprise Edition API and Technology

42

RMI over IIOP Features

True subset of RMI over JRMP Uses CORBA objects-by-value

extension Allows genuine interoperability with

C++ and other languages RMI over IIOP combines:

RMI style ease of use plus cross-language interoperability

No Distributed Garbage Collection

Page 43: Distributed Computing and Java - · PDF fileDistributed Computing and Java ... What Is the Java™ 2 Platform, Enterprise Edition ... Java 2 Platform, Enterprise Edition API and Technology

43

What is Java IDL

Java IDLUses OMG's Java Language Mapping Layered on Internet Inter ORB Protocol

(IIOP) Generates Portable Stubs/Skeletons

Page 44: Distributed Computing and Java - · PDF fileDistributed Computing and Java ... What Is the Java™ 2 Platform, Enterprise Edition ... Java 2 Platform, Enterprise Edition API and Technology

44

Java IDL Development

Page 45: Distributed Computing and Java - · PDF fileDistributed Computing and Java ... What Is the Java™ 2 Platform, Enterprise Edition ... Java 2 Platform, Enterprise Edition API and Technology

45

Java IDL runtime

Page 46: Distributed Computing and Java - · PDF fileDistributed Computing and Java ... What Is the Java™ 2 Platform, Enterprise Edition ... Java 2 Platform, Enterprise Edition API and Technology

XML

Page 47: Distributed Computing and Java - · PDF fileDistributed Computing and Java ... What Is the Java™ 2 Platform, Enterprise Edition ... Java 2 Platform, Enterprise Edition API and Technology

47

Language Description Pros consSGML Language for

describingdocuments

Completeandextensible

Complex

HTML HyperTextMarkupLanguage

Simple Focus onrendering;Not Extensible

XML eXtensibleMarkupmetaLanguage

Simple,extensible

Need othertechnologiesin conjunction

What Is XML?

eXtensible Markup metaLanguage Universal Data description

mechanism

Page 48: Distributed Computing and Java - · PDF fileDistributed Computing and Java ... What Is the Java™ 2 Platform, Enterprise Edition ... Java 2 Platform, Enterprise Edition API and Technology

48

XML and Java Technology

Complementary technologiesXML is portable reusable dataJava Technology is portable behavior

Both are Web-friendly, open, vendor neutral, Unicode support

Page 49: Distributed Computing and Java - · PDF fileDistributed Computing and Java ... What Is the Java™ 2 Platform, Enterprise Edition ... Java 2 Platform, Enterprise Edition API and Technology

49

What is Needed?

XML “Basic Plumbing” classes:Ability to parse XML:

Parser(s) SAX DOM Namespaces Support in parser(s)

Page 50: Distributed Computing and Java - · PDF fileDistributed Computing and Java ... What Is the Java™ 2 Platform, Enterprise Edition ... Java 2 Platform, Enterprise Edition API and Technology

50

XML Schema

XML = Data without syntax? Schemas specifies syntax of XML

documentDTDXML schema

Page 51: Distributed Computing and Java - · PDF fileDistributed Computing and Java ... What Is the Java™ 2 Platform, Enterprise Edition ... Java 2 Platform, Enterprise Edition API and Technology

J2EE

Page 52: Distributed Computing and Java - · PDF fileDistributed Computing and Java ... What Is the Java™ 2 Platform, Enterprise Edition ... Java 2 Platform, Enterprise Edition API and Technology

52

What Is the Java™ 2 Platform, Enterprise Edition (J2EE)?

Open and standard based platform for

developing, deploying and managing n-tier, Web-enabled, server-centric

enterprise applications

Page 53: Distributed Computing and Java - · PDF fileDistributed Computing and Java ... What Is the Java™ 2 Platform, Enterprise Edition ... Java 2 Platform, Enterprise Edition API and Technology

53

The Java™ 2 Platform

High-EndServer

Java TechnologyEnabled Desktop

WorkgroupServer

Java TechnologyEnabled Devices

Page 54: Distributed Computing and Java - · PDF fileDistributed Computing and Java ... What Is the Java™ 2 Platform, Enterprise Edition ... Java 2 Platform, Enterprise Edition API and Technology

54

What Do You Get from J2EE?

API and Technology specifications Development and Deployment

Platform Reference implementation Compatibility Test Suite (CTS) J2EE BluePrints

Page 55: Distributed Computing and Java - · PDF fileDistributed Computing and Java ... What Is the Java™ 2 Platform, Enterprise Edition ... Java 2 Platform, Enterprise Edition API and Technology

55

J2EE 1.3APIs and Technologies

Java 2 SDK, Standard EditionRMI/ IIOP

JDBC™ Java Messaging Service

JNDIServlet

JavaServer Pages™JavaMail

JavaBeans™ Activation FrameworkEnterprise JavaBeansJava Transaction API

Java Transaction ServiceConnector Architecture

ECPerf™

Version1.31.03.0

1.0.2b 1.2.1

2.31.21.2

1.0.12.0

1.0.11.11.01.0

Page 56: Distributed Computing and Java - · PDF fileDistributed Computing and Java ... What Is the Java™ 2 Platform, Enterprise Edition ... Java 2 Platform, Enterprise Edition API and Technology

56

What is EJB Technology?

Cornerstone of J2EE A server-side component technology Easy development and deployment of

Java technology-based application that are:Transactional, distributed, multi-tier,

portable, scalable, secure, …

Page 57: Distributed Computing and Java - · PDF fileDistributed Computing and Java ... What Is the Java™ 2 Platform, Enterprise Edition ... Java 2 Platform, Enterprise Edition API and Technology

57

Why EJB Technology?

Leverages the benefits of component-model on the server side

Separates business logic from system code

Provides framework for portable components Over different J2EE-compliant servers Over different operational environments

Enables deployment-time configurationDeployment descriptor

Page 58: Distributed Computing and Java - · PDF fileDistributed Computing and Java ... What Is the Java™ 2 Platform, Enterprise Edition ... Java 2 Platform, Enterprise Edition API and Technology

58

EJB Architecture

Page 59: Distributed Computing and Java - · PDF fileDistributed Computing and Java ... What Is the Java™ 2 Platform, Enterprise Edition ... Java 2 Platform, Enterprise Edition API and Technology

59

What is a Servlet?

Java™ objects which extend the functionality of a HTTP server

Dynamic contents generation Better alternative to CGI, NSAPI,

ISAPI, etc.EfficientPlatform and server independentSession managementJava-based

Page 60: Distributed Computing and Java - · PDF fileDistributed Computing and Java ... What Is the Java™ 2 Platform, Enterprise Edition ... Java 2 Platform, Enterprise Edition API and Technology

60

Servlets vs. CGI

CGIBased

Webserver

CGIBased

Webserver

Request CGI1Child for CGI1

CGIBased

Webserver

Servlet Based Webserver

JVM

Request CGI1Child for CGI1

Request Servlet1

CGIBased

Webserver

Servlet Based Webserver

JVMServlet1

Request CGI1Child for CGI1

Request CGI2

Request Servlet1

CGIBased

WebserverChild for CGI2

Servlet Based Webserver

JVMServlet1

Request CGI1Child for CGI1

Request CGI2

Request Servlet1

Request Servlet2

CGIBased

WebserverChild for CGI2

Servlet Based Webserver

JVMServlet1

Servlet2

Request CGI1Child for CGI1

Request CGI2

Request CGI1

Request Servlet1

Request Servlet2

CGIBased

WebserverChild for CGI2

Child for CGI1

Servlet Based Webserver

JVMServlet1

Servlet2

Request CGI1Child for CGI1

Request CGI2

Request CGI1

Request Servlet1

Request Servlet2

Request Servlet1

CGIBased

WebserverChild for CGI2

Child for CGI1

Servlet Based Webserver

JVMServlet1

Servlet2

Request CGI1Child for CGI1

Page 61: Distributed Computing and Java - · PDF fileDistributed Computing and Java ... What Is the Java™ 2 Platform, Enterprise Edition ... Java 2 Platform, Enterprise Edition API and Technology

61

01 public class ExampleServlet extends HttpServlet {02 public void doGet(HttpServletRequest request,03 HttpServletResponse response)04 throws ServletException, IOException05 {06 response.setContentType(“text/html”);07 PrintWriter out = response.getWriter();08 out.println(“Good Day USA!<BR>”);09 Date rightNow = new Date();10 out.println(“The time is: “ + rightNow);11 }12 }

Code for a Simple Servlet

Page 62: Distributed Computing and Java - · PDF fileDistributed Computing and Java ... What Is the Java™ 2 Platform, Enterprise Edition ... Java 2 Platform, Enterprise Edition API and Technology

62

What is JSP Technology?

Enables separation of business logic from presentationPresentation is in the form of HTML or

XML/XSLTBusiness logic is implemented as Java

Beans or custom tagsBetter maintainability, reusability

Extensible via custom tags Builds on Servlet technology

Page 63: Distributed Computing and Java - · PDF fileDistributed Computing and Java ... What Is the Java™ 2 Platform, Enterprise Edition ... Java 2 Platform, Enterprise Edition API and Technology

63

Big Picture

HTTP(S)HTTP(S)HTML/XMLHTML/XML

Client

Page 64: Distributed Computing and Java - · PDF fileDistributed Computing and Java ... What Is the Java™ 2 Platform, Enterprise Edition ... Java 2 Platform, Enterprise Edition API and Technology

64

JSP

Servlets and JSP - Comparison

HTML code in Java

Any form of Data Not easy to author Underlying

semantics

Java-like code in HTML

Structured Text Very easy to author Code is compiled

into a servlet

Servlets

Page 65: Distributed Computing and Java - · PDF fileDistributed Computing and Java ... What Is the Java™ 2 Platform, Enterprise Edition ... Java 2 Platform, Enterprise Edition API and Technology

65

JTS/JTA (Transaction Processing)

Distributed transaction processing JTS: Mapping to CORBA Object

Transaction Service (OTS)Access to standard object transaction

coordinationWho: IBM, Inprise, Bull, WebLogic

JTA: API for transactionsJava interface to transactional systemsWho: Transaction/DB server vendors

Page 66: Distributed Computing and Java - · PDF fileDistributed Computing and Java ... What Is the Java™ 2 Platform, Enterprise Edition ... Java 2 Platform, Enterprise Edition API and Technology

66

•JNDI (Naming and Directory)

JNDI: Java Naming and DirectoryUnified field theory for namingLDAP, NIS, NIS+, DNS, File, etc. Industry supportBenefits:

Single interface to enterprise network objects Cross platform

Page 67: Distributed Computing and Java - · PDF fileDistributed Computing and Java ... What Is the Java™ 2 Platform, Enterprise Edition ... Java 2 Platform, Enterprise Edition API and Technology

67

JMS (Messaging and Pub/Sub)

JMS: Java Message Service APIAsynchronous communicationsPublish and SubscribeReliable QueuesGuaranteed deliveryBenefits:

Single interface to MOM Open and cross platform

Who: TIBCO, IBM, Modulus, Active

Page 68: Distributed Computing and Java - · PDF fileDistributed Computing and Java ... What Is the Java™ 2 Platform, Enterprise Edition ... Java 2 Platform, Enterprise Edition API and Technology

68

Java 2 Platform, Enterprise Edition API and Technology specifications Development and Deployment

Platform Reference implementation Compatibility tests with branding J2EE BluePrints

Page 69: Distributed Computing and Java - · PDF fileDistributed Computing and Java ... What Is the Java™ 2 Platform, Enterprise Edition ... Java 2 Platform, Enterprise Edition API and Technology

69

Platform Value to Developers

Unified platform Choice of platform implementation

PerformanceScalabilityReliabilityManageabilityTools

Increased productivity Portability of code Ready-to-use security framework

Page 70: Distributed Computing and Java - · PDF fileDistributed Computing and Java ... What Is the Java™ 2 Platform, Enterprise Edition ... Java 2 Platform, Enterprise Edition API and Technology

70

Client

Client

Client

Client

Client

ClientTier

Enterprise Information

TierMiddle

Tier

Enterprise Information

Systems (EIS):RelationalDatabase,Legacy

Applications,ERP Systems

Enterprise JavaBeans™

Enterprise JavaBeans

Other Services:JNDI, JMS,JavaMail™

J2EEApplication

Server

Web ServerJSP,

Servlets

Firewall

J2EE is End-to-End Solution

HTML/XML

Page 71: Distributed Computing and Java - · PDF fileDistributed Computing and Java ... What Is the Java™ 2 Platform, Enterprise Edition ... Java 2 Platform, Enterprise Edition API and Technology

71

JND

I

J2SE

JMS

RM

I/IIO

P

JDB

C

Database

AppClient

App Client Container

HTTP/HTTPS

J2SE

RMIJ2SE

JND

I

JMS

RMI/I

IOP

JDB

C

JTA JavaMail

JAF JND

I

JMS

RMI/I

IOP

JDB

C

JTA

JavaMail

JAF

HTTP/HTTPS

Applet Container

Applet JSP Servlet EJB

Web Container EJB Container

RMI

J2SE

J2EE Containers & Components

Page 72: Distributed Computing and Java - · PDF fileDistributed Computing and Java ... What Is the Java™ 2 Platform, Enterprise Edition ... Java 2 Platform, Enterprise Edition API and Technology

72

ComponentsHandle

Containers and Components

Concurrency Security Availability Scalability Persistence Transaction Lifecycle

management Management

Presentation Business Logic

ContainersHandle

Page 73: Distributed Computing and Java - · PDF fileDistributed Computing and Java ... What Is the Java™ 2 Platform, Enterprise Edition ... Java 2 Platform, Enterprise Edition API and Technology

73

Creation Assembly Deployment

Created by Component Developer

Assembledand Augmentedby Application

Assembler

Processed by Deployer

Deploy

EnterpriseComponents

J2EE Container

J2EE APPJ2EE Modules

Lifecycle illustration

Page 74: Distributed Computing and Java - · PDF fileDistributed Computing and Java ... What Is the Java™ 2 Platform, Enterprise Edition ... Java 2 Platform, Enterprise Edition API and Technology

74

Java 2 Platform, Enterprise Edition API and Technology specifications Development and Deployment

Platform Reference implementation Compatibility Test Suite (CTS) J2EE BluePrints

Page 75: Distributed Computing and Java - · PDF fileDistributed Computing and Java ... What Is the Java™ 2 Platform, Enterprise Edition ... Java 2 Platform, Enterprise Edition API and Technology

75

What and Why a Reference Implementation? Validates specification Fully-compliant Fully-functional Not commercial quality

ScalabilityPerformance

Use it for prototyping J2EE based applications

Page 76: Distributed Computing and Java - · PDF fileDistributed Computing and Java ... What Is the Java™ 2 Platform, Enterprise Edition ... Java 2 Platform, Enterprise Edition API and Technology

76

Compatibility Test Suite (CTS)

Ultimate Java™ technology mission:Write Once, Run Anywhere™My Java-based application runs on any

compatible Java virtual machinesMy J2EE based technology-based

application will run on any J2EE based Compatible platforms

Page 77: Distributed Computing and Java - · PDF fileDistributed Computing and Java ... What Is the Java™ 2 Platform, Enterprise Edition ... Java 2 Platform, Enterprise Edition API and Technology

77

J2EE BluePrints

Best practice guidelines, design patterns and design principlesMVC pattern

Covers all tiersClient tierWeb tierBusiness logic (EJB) tierDatabase access tier

Sample codeJava Pet Store

Page 78: Distributed Computing and Java - · PDF fileDistributed Computing and Java ... What Is the Java™ 2 Platform, Enterprise Edition ... Java 2 Platform, Enterprise Edition API and Technology

78

Summary

Java is unifying the fragmented distributed systems arena

The ability to be able to move code makes Java unique

Java is able to inter-operate with legacy applications