cse298 cse300 jr&b-1.1 java beans and enterprise java beans paul c. barr the mitre corporation...

74
CSE298 CSE300 JR&B-1.1 Java Beans and Java Beans and Enterprise Java Beans Enterprise Java Beans Paul C. Barr The Mitre Corporation Eatontown NJ [email protected] Kimble Cheron, Prof. Steven A. Demurjian, and Mitch Saba Computer Science & Engr. Dept. [email protected] http://www.engr.uconn.edu/ ~steve (860) 486 - 4818

Post on 20-Dec-2015

221 views

Category:

Documents


0 download

TRANSCRIPT

CSE298

CSE300

JR&B-1.1

Java Beans andJava Beans andEnterprise Java BeansEnterprise Java Beans

Paul C. BarrThe Mitre Corporation

Eatontown NJ

[email protected]

Kimble Cheron,Prof. Steven A. Demurjian,

and Mitch SabaComputer Science & Engr. Dept.

[email protected]://www.engr.uconn.edu/

~steve(860) 486 - 4818

CSE298

CSE300

JR&B-1.2

Changing PerspectivesChanging Perspectives

Computers are Guilty of Creating More Disorder Computers are Guilty of Creating More Disorder then Simplicitythen Simplicity

Current Software Systems are RelicsCurrent Software Systems are Relics Built Largely By and For Technical Computer

Users Never Intended to Operate in Today’s

Environment Designer’s Need to Break Out of Old MoldDesigner’s Need to Break Out of Old Mold

Consider Total Design Space Design Should Help Manage Complexity, Not

Add to It What is Available to Assist in Changing Times?What is Available to Assist in Changing Times?

CSE298

CSE300

JR&B-1.3

ComponentsComponents

Reusable Software Building BlocksReusable Software Building Blocks Pre-Constructed from Encapsulated Application Pre-Constructed from Encapsulated Application

CodeCode Easily Combined with Other Components Seamlessly Merged with Custom Code Rapid Prototyping of Complete Applicaiton

What is a Component?What is a Component? GUI Widget (Button, Window, etc.) Combination of Components (Window with

Elevator Bars and Pull-Down Menus) Application Service (Account Management

Function)

CSE298

CSE300

JR&B-1.4

OverviewOverview

A First Look at Java BeansA First Look at Java Beans What are They? How are They Utilized?

Enterprise Java BeansEnterprise Java Beans Not Just for Clients Anymore! Capabilities and Usage Relationship to “New” and “Old” Technologies Component-Based Client/Server Model

Multi-Tiered Architecture and EJBMulti-Tiered Architecture and EJB Tiered Development for Extensibility Comparisons of Approaches

Java Blend for Database InteroperabilityJava Blend for Database Interoperability

CSE298

CSE300

JR&B-1.5

Java BeansJava Beans

Extends "Write Once, Run Anywhere (WORA)Extends "Write Once, Run Anywhere (WORA)TMTM" " to Include "Reuse Everywhere”to Include "Reuse Everywhere”

What is a Bean?What is a Bean? Independent Reusable Software Component Visually Manipulated in Builder Tools Can Be Visible Object:

AWT Components or Invisible Objects:

Queues and Stacks or Composed Objects:

Calculator Ops + Keys + Display

CSE298

CSE300

JR&B-1.6

Java BeansJava Beans

Bean vs. ComponentBean vs. Component Source Code Inaccessible Customizable to Suit Application Needs via

External Properties Powerful Means of Reuse

ExamplesExamples GUI Button with Property to Allow Button

Name to be Set Account Management Component that Allows

Account Database Location to be Set Properties Can be Very Complex and Offer Properties Can be Very Complex and Offer

Significant Power to Application BuildersSignificant Power to Application Builders

CSE298

CSE300

JR&B-1.7

Java Beans FundamentalsJava Beans Fundamentals

Supported within IDEsSupported within IDEs Visual Age, JBuilder, PowerJ, Visual Café Construct JavaBeans Component as Specialized

Java Classes with Enhanced Capabilities Three-Part ArchitectureThree-Part Architecture

Events Notifies Others When Something Has Occurred Delegation-Event Model of AWT

Properties Define the Characteristics of the Bean

Methods Utilized to Define a Property

CSE298

CSE300

JR&B-1.8

Architecture: EventsArchitecture: Events

EventsEvents Notifies Others When Something Has Occurred Delegation-Event Model of AWT

Event ElementsEvent Elements Eventobjects

Components Sends to Listener Eventlisteners

In Order to Register an Eventlistener With a Component, the Component Must Understand the Event Set

Event Sources We’ll Discuss Shortly and Revisit in Detail with We’ll Discuss Shortly and Revisit in Detail with

Java RMIJava RMI

CSE298

CSE300

JR&B-1.9

Architecture: PropertiesArchitecture: Properties

Example: AWT TextfieldExample: AWT Textfield User Will See Properties for the Caret Position,

Current Text, and the Echo Character, etc. Methods Used to Define a PropertyMethods Used to Define a Property

public void setPropertyName(PropertyType value);public PropertyType getPropertyName(); The Name of the Property is Propertyname The Datatype is Propertytype Only One Method Present the Property is Read-

Only (Set Missing) Or the Property is Write-only (Get Missing)

CSE298

CSE300

JR&B-1.10

Architecture: MethodsArchitecture: Methods

MethodsMethods Public

Available for Anyone to Call Beaninfo and Getmethoddescriptors Method

Restricts Which Methods Are Visible to the Beanbuilder/Integration Tool

The Getmethoddescriptors Method Reports All the Methods of a Bean

Supports Introspection Beaninfoclass

Customize a Bean's Appearance to an Integration Tool

CSE298

CSE300

JR&B-1.11

AbilitiyAbilitiy

PersistencePersistence Ability of an Object to Store its State Object Serialization Saves All Non-static and

Non-transient Instance Variables of an Object Objectinput and Objectoutput Interfaces

The Basis for Serialization Within Java. Objectinputstream and Objectoutputstream

Classes Implement the Objectinput and Objectoutput

Interfaces

CSE298

CSE300

JR&B-1.12

Five Defining FeaturesFive Defining Features

Introspection Introspection Allow a Builder Tool to Analyze How a Bean

Works Customization Customization

User is Allowed to Alter the Appearance and Behavior of a Bean

Events Events Firing of Events Inform Builder Tools About Both the Events

They Can Fire and Handle

CSE298

CSE300

JR&B-1.13

Five Defining FeaturesFive Defining Features

PropertiesProperties Beans Can Be Manipulated Programmatically Support the Customization as Mentioned

Persistence Persistence Customized Beans Can Have Their State Saved

and Restored Work in a Constructed Application Can Be

Restored by an Application Builder's Save and Load Menu Commands

Beans Are Used Primarily With Builder ToolsBeans Are Used Primarily With Builder Tools Programmatic Interfaces Allow Beans to Be

Manually Manipulated by Text Tools

CSE298

CSE300

JR&B-1.14

Differences Between Beans and ClassesDifferences Between Beans and Classes

IntrospectionIntrospection Process of Determining the Supported

Properties, Methods, and Events of a Bean Introspector ClassIntrospector Class

Provides Access to the Beaninfo for the Bean Component Via Its getBeanInfo Method

CodeTextField tf = new TextField ();

BeanInfo bi = Introspector.getBeanInfo (tf.getClass());

Alternative to Introspector ClassAlternative to Introspector Class Provides Access Directly Through the Use of

the Reflection API

CSE298

CSE300

JR&B-1.15

Introspection ToolsIntrospection Tools

Differentiates Beans From Typical Java ClassesDifferentiates Beans From Typical Java Classes Recognize Predefined Patterns in Class Definitions Recognize Predefined Patterns in Class Definitions

and Method Signatures and Method Signatures Able to "Look Inside" a Bean to Determine Its

Properties and Behavior Require That Method Signatures Within Beans Require That Method Signatures Within Beans

Must Follow a Certain Pattern Must Follow a Certain Pattern Recognize How Beans Can Be Manipulated at Recognize How Beans Can Be Manipulated at

Design and Run TimeDesign and Run Time Pattern Signatures are Designed to Be Recognized Pattern Signatures are Designed to Be Recognized

by Human Readers and Builder Toolsby Human Readers and Builder Tools

CSE298

CSE300

JR&B-1.16

Bean vs. ClassBean vs. Class

A Bean's State Can Be Manipulated at Design A Bean's State Can Be Manipulated at Design Time in Contrast to Classes at Run TimeTime in Contrast to Classes at Run Time

Beans Attributes and Behaviors Beans Attributes and Behaviors Published by Special Method Signature Patterns Recognized by Beans-Aware Application

Construction Tools What to Use for Software Modules?What to Use for Software Modules?

Beans are Better for Software Components Visually Manipulated Within Builder Tools

Classes are Better for Functionality Through a Programmatic (Textual) Interface An SQL API Would Be Better Packaged Through a

Class Library

CSE298

CSE300

JR&B-1.17

Event ModelEvent Model

Three ElementsThree Elements Eventobject Eventlistener Eventsource (the Bean)

EventobjectEventobject Basis of All Beans Events Java.Util.Eventobject Class Require Programmer to Subclass an

Eventobject to Have a Specific Event Type

CSE298

CSE300

JR&B-1.18

Java 1.1 Delegation Event ModelJava 1.1 Delegation Event Model

CSE298

CSE300

JR&B-1.19

Example: Event for Employee’s Hire Example: Event for Employee’s Hire DateDate

public class HireEvent extends EventObject {

private long hireDate;

public HireEvent (Object source) {

super (source);

hireDate = System.currentTimeMillis();

}

public HireEvent (Object source, long hired) {

super (source);

hireDate = hired;

}

public long getHireDate () {

return hireDate;

}

}

CSE298

CSE300

JR&B-1.20

EventListenerEventListener

DefinitionDefinition Entity That Desires Notification When an Event

Happens Receives the Specific Eventobject Subclass As

a Parameter

CSE298

CSE300

JR&B-1.21

EventListenerEventListener

Eventlistener InterfaceEventlistener Interface Empty Interface Acts as a Tagging Interface That All Event

Listeners Must Extend Eventtypelistener Name of Listener Interface The Name for the New Hireevent

Listener Would Be Hirelistener Method Names Should Describe the Event

Happening Code

public interface HireListenerextends java.util.EventListener {

public abstract void hired (HireEvent e);}

CSE298

CSE300

JR&B-1.22

EventSourceEventSource

EventsourceEventsource Defines When and Where an Event Will

Happen Hireevent and Hirelistener Are Required for an

Event Source to Function Sends Notification to Registered Classes When

the Event Happens

CSE298

CSE300

JR&B-1.23

EventSource: MethodsEventSource: Methods

Registration Process Method Patternspublic synchronized void

addListenerType(ListenerType l);public synchronized void

removeListenerType(ListenerType l);

Maintaining Eventsource Codeprivate Vector hireListeners = new Vector();

public synchronized void

addHireListener(HireListener l) {

hireListeners.addElement (l);

}

public synchronized void

removeHireListener (HireListener l) {

hireListeners.removeElement (l);

}

CSE298

CSE300

JR&B-1.24

EventSource: Hiring ExampleEventSource: Hiring Example

protected void notifyHired () {Vector l;// Create EventHireEvent h = new HireEvent (this);// Copy listener vector so it won't change while

firingsynchronized (this) {

l = (Vector)hireListeners.clone();}for (int i=0;i<l.size();i++) {

HireListener hl = (HireListener)l.elementAt (i);

hl.hired(h); }

}

CSE298

CSE300

JR&B-1.25

What is Enterprise Java Beans ?What is Enterprise Java Beans ?

Expansion of Java Beans (Client-side) to Support Expansion of Java Beans (Client-side) to Support Server Side Reusable ComponentsServer Side Reusable Components Server Components Run on Application Server EJB Integral Part of Java Technology

Component Architecture for Distributed Systems Component Architecture for Distributed Systems Multi-Tier Distributed Architecture Movement of Application Logic from Client to

Server Side Creation of “Thin”, Easier to Maintain Clients

Framework for Creating Middle WareFramework for Creating Middle Ware Integration of “New” and “Old” Technologies RMI, IIOP, CORBA, RPC, Active X, etc.

CSE298

CSE300

JR&B-1.26

Designer and Developer Roles in Designer and Developer Roles in Enterprise Java Beans (EJB)Enterprise Java Beans (EJB)

Towards Towards “Highly Scalable, Highly Available, “Highly Scalable, Highly Available, Highly Reliable, Highly Secure, Transaction Highly Reliable, Highly Secure, Transaction Distributed Applications”Distributed Applications”

Enterprise Bean Provider Enterprise Bean Provider Creates and Sells EJBs

Application Assembler Application Assembler Uses EJBs to Build an Application

EJB Server Provider EJB Server Provider Creates and Sells EJB Server

EJB Container Provider EJB Container Provider Creates and Sells EJB Containers Server Provider Will Likely Provide

Containers

CSE298

CSE300

JR&B-1.27

EJB Roles & DeploymentEJB Roles & Deployment

CSE298

CSE300

JR&B-1.28

Utilizing EJB TechnologyUtilizing EJB Technology

CSE298

CSE300

JR&B-1.29

The EJB ArchitectureThe EJB Architecture

EJB Servers: Analogous to CORBA ORB EJB Servers: Analogous to CORBA ORB Server Software Provides Naming and Transaction Services Makes Containers Visible

EJB Containers: Interface Between EJB Bean and EJB Containers: Interface Between EJB Bean and Outside World Outside World Client Never Accesses Bean Directly Access via Container-Generated Methods These Methods Then Call the Bean’s Methods

EJB Clients EJB Clients Locate EJB Containers Via JNDI Make Use of EJB Beans

Enterprise Java Beans - Discussed ShortlyEnterprise Java Beans - Discussed Shortly

CSE298

CSE300

JR&B-1.30

Recall CORBARecall CORBA

CSE298

CSE300

JR&B-1.31

EJB ContainerEJB Container

CSE298

CSE300

JR&B-1.32

Enterprise Java APIsEnterprise Java APIs

CSE298

CSE300

JR&B-1.33

Enterprise Java Beans Enterprise Java Beans Session BeansSession Beans

Associated With a Particular ClientAssociated With a Particular Client Performs Operations on Behalf of ClientPerforms Operations on Behalf of Client

Accessing a Database Performing Calculations

Created and Destroyed by a Client Created and Destroyed by a Client Can be Transactional - But, Do Not Survive Can be Transactional - But, Do Not Survive

System ShutdownSystem Shutdown Can be Stateless or Maintain Conventional State Can be Stateless or Maintain Conventional State

Across Methods and TransactionsAcross Methods and Transactions Must Manage Own Persistent DataMust Manage Own Persistent Data

CSE298

CSE300

JR&B-1.34

Enterprise Java Beans Enterprise Java Beans Entity BeansEntity Beans

Object Representation of Persistent Data Object Representation of Persistent Data Maintained in Permanent Store (DatabaseMaintained in Permanent Store (Database

Identifiable by Primary KeyIdentifiable by Primary Key Shared by Multiple Clients Shared by Multiple Clients Persist Across Multiple Invocations Persist Across Multiple Invocations Survive System ShutdownSurvive System Shutdown Created byCreated by

Inserting Data into Database Creating an Object Instance

CSE298

CSE300

JR&B-1.35

Model for PersistenceModel for PersistencePassivation/ActivationPassivation/Activation

Programmatic Model for Managing Persistent Programmatic Model for Managing Persistent ObjectsObjects

EJB Server has the Right to Manage its Working EJB Server has the Right to Manage its Working Set Set

Passivation Passivation Saves State of a Bean to Persistent Storage Then Swaps Bean Out

Activation Activation Restores State of a Bean From Persistent Storage,Then Swaps Bean in

Applies to Both Session and Entity BeansApplies to Both Session and Entity Beans

CSE298

CSE300

JR&B-1.36

Stateless vs. Stateful Session BeansStateless vs. Stateful Session Beans

Stateless Stateless No Internal State Do Not Need to Be "Pass-ivated" Can Be Pooled to Service Multiple Clients

Stateful Stateful Possess Internal State Need to Handle Passivation/Activation One Per Client

CSE298

CSE300

JR&B-1.37

Persistent Session BeansPersistent Session Beans

Session Beans Can Be Saved and Restored Across Session Beans Can Be Saved and Restored Across Client Sessions Client Sessions

To SaveTo Save Call the Session Bean’s getHandle() Method Returns a Handle Object

To RestoreTo Restore Call the Handle Object’s getEJBObject()

Method

CSE298

CSE300

JR&B-1.38

Entity Bean PersistenceEntity Bean Persistence

Container-Managed Container-Managed Container is Responsible for Saving State In Deployment Descriptor, Specify Container-

Managed Fields Persistence Independent of Data Source

Bean-Managed Bean-Managed Bean is Responsible for Saving its Own State Container Doesn’t Need to Generate DB Calls Less Adaptable; Persistence is Hard-Coded

CSE298

CSE300

JR&B-1.39

Writing an EJB ClientWriting an EJB Client

Locate the Bean Container Locate the Bean Container Allocate a Bean, If Needed Allocate a Bean, If Needed Use the Bean Use the Bean Dispose of the BeanDispose of the Bean

//An idealized EJB client import paul.ejb.restaurant.*; public class EJBClient{

public static void main(String[] argv){ //get JNDI naming context

javax.naming.Context initialContext = new javax.naming.InitialContext(); //use context to look up EJB home interface RestaurantHome rh = initialContext.lookup(“RestaurantHome”);

//use home interface to create a session object Restaurant r = rh.Create(“Burger Heaven”);

//invoke business methods r.order(“cheeseburger”); //remove session object r.remove(); }

}

CSE298

CSE300

JR&B-1.40

Writing a Session BeanWriting a Session Bean

Create Remote Interface Create Remote Interface must extend javax.ejb.EJBObject interface must give prototypes for business methods class needn’t say “implements”; this is handled by the container

Create Home Interface Create Home Interface must extend javax.ejb.EJBHome interface create() methods, remove() methods

Implement Create Methods Implement Create Methods called by container at creation time

Implement the SessionBean Interface Implement the SessionBean Interface ejbActivate() - called when bean is activated ejbPassivate() - called when bean is passivated ejbRemove() - called when bean is destroyed setSessionContext(SessionContext ctx) - called by container to give bean

a context

CSE298

CSE300

JR&B-1.41

Session Bean ExampleSession Bean Example

package paul.ejb.restaurant.server; public class OrderBean implements SessionBean{ private transient SessionContext ctx; private String order; //can have many create methods public void ejbCreate () throws Exception { //initialization of class variables here } //business method public boolean order(String order) { this.order = order; System.out.println("order received for " + order); return true; } //these methods are required by the SessionBean interface public void ejbActivate() throws Exception { } public void ejbDestroy() throws Exception { } public void ejbPassivate() throws Exception { } public void setSessionContext(SessionContext ctx) throws Exception { this.ctx = ctx; } }

CSE298

CSE300

JR&B-1.42

Writing an Entity BeanWriting an Entity Bean

Implement the EntityBean Interface Implement the EntityBean Interface ejbActivate() // called on activation ejbPassivate() // called on passivation ejbLoad() // tells bean to load state from database ejbStore() // tells bean to store state in database ejbRemove() // called when client calls remove() setEntityContext() // called by container when instance has been created unsetEntityContext() // called by container before removing the instance must also implement ejbFind() // allows client to look up EJB objects

Optionally Implement Optionally Implement create()create() Methods Methods Create Remote Interface Create Remote Interface

must extend javax.ejb.EJBObject interface Create Home Interface Create Home Interface

CSE298

CSE300

JR&B-1.43

Entity Bean ExampleEntity Bean Example

package paul.ejb.entity.server; public class ExampleBean implements EntityBean { private transient EntityContext ctx; //notice: no finder method -- generated at deployment time by container provider //can have multiple create methods public void ejbCreate () throws Exception { } //business method public boolean doSomething () { } //required methods for EntityBean interface public void ejbActivate() throws Exception { } public void ejbDestroy() throws Exception { } public void ejbPassivate() throws Exception { } public void ejbLoad() throws Exception { } public void ejbStore() throws Exception { } public void setEntityContext (EntityContext ctx) throws Exception { this.ctx = ctx; }

CSE298

CSE300

JR&B-1.44

Deploying EJBsDeploying EJBs

EJBs Deployed As .SER Files: EJBs Deployed As .SER Files: Serialized InstanceSerialized Instance Manifest File Used to List EJBs Manifest File Used to List EJBs Must Also Provide a “Deployment Descriptor” Must Also Provide a “Deployment Descriptor” Sample Entry Sample Entry

Name: paul.RestaurantDeployment.ser Enterprise-Bean: True

“ “Name” Line Name” Line Describes a Serialized Deployment Descriptor

“ “Enterprise-Bean” Line Enterprise-Bean” Line Indicates Whether the Entry Should Be Treated

as an EJB (Not All Entries Need to Be EJBs)

CSE298

CSE300

JR&B-1.45

Who’s Announced EJB Support?Who’s Announced EJB Support?

WebLogic WebLogic IBM IBM Oracle Oracle GemStone GemStone BEA BEA Borland Borland Netscape Netscape LotusLotus

Forte Forte Progress Progress Novell Novell Novera Novera Borland Borland Informix Informix IONA IONA More...More...

CSE298

CSE300

JR&B-1.46

Typical Development and Deployment Typical Development and Deployment ScenarioScenario

EJB Server Provider EJB Server Provider Creates and Sells an EJB Server Provides EJB Containers That Will Run on

These Servers EJB ProvidersEJB Providers

Individuals Responsible for Developing the EJBs

Provide “Tools” and “Components” for Down-Stream Usage

Application AssemblersApplication Assemblers Individuals that Utilize Pre-Built EJBs to

Construct Their Domain-Specific Applications Utilize “State-of-Art-Tools” for EJB and JB

CSE298

CSE300

JR&B-1.47

EJB Component-Based ArchitectureEJB Component-Based Architecture

EJB Client

EJB Container

EJB Server

Enterprise Java Bean

Invoke EJB Container Methods

Invoke EJB Methods

CSE298

CSE300

JR&B-1.48

Client-Server Component ModelClient-Server Component Model

CSE298

CSE300

JR&B-1.49

Client-Server Component RelationshipClient-Server Component Relationship

CSE298

CSE300

JR&B-1.50

Client-Server Component Relationship Client-Server Component Relationship (Concluded)(Concluded)

CSE298

CSE300

JR&B-1.51

EJB Server ExampleEJB Server Example

CSE298

CSE300

JR&B-1.52

EJB Server Example (continued)EJB Server Example (continued)

CSE298

CSE300

JR&B-1.53

EJB Server Example (Concluded)EJB Server Example (Concluded)

CSE298

CSE300

JR&B-1.54

Three-Tier Architecture ConceptThree-Tier Architecture Concept

CSE298

CSE300

JR&B-1.55

Two-Tier, Three-Tier, Four-Tier Two-Tier, Three-Tier, Four-Tier Example ArchitecturesExample Architectures

From: http://java.sun.com/javaone/javaone98/sessions/T400/index.html

CSE298

CSE300

JR&B-1.56

Wombat SecuritiesWombat Securities

Web Access to Brokerage Accounts Web Access to Brokerage Accounts Only HTML Browser Required on Front End Only HTML Browser Required on Front End "Brokerbean" EJB Provides Business Logic "Brokerbean" EJB Provides Business Logic Login, Query, Trade Servlets Call Brokerbean Login, Query, Trade Servlets Call Brokerbean Use JNDI to Find EJBs, RMI to Invoke ThemUse JNDI to Find EJBs, RMI to Invoke Them Order and History Records from Java Blend Order and History Records from Java Blend

Product Product Records Mapped to Oracle Tables, JDBC Calls Records Mapped to Oracle Tables, JDBC Calls

CSE298

CSE300

JR&B-1.57

Four-Tier Architecture ExampleFour-Tier Architecture Example

CSE298

CSE300

JR&B-1.58

Initialization Code Initialization Code

class LoginServlet extends HttpServlet { private Broker createBroker(String account, String password) { /* Use JNDI to find Broker EJB home, then return new EJB */ Context initialContext = new InitialContext(); BrokerHome brokerHome = (BrokerHome) initialContext.lookup("wombat/Broker"); return brokerHome.create(account, password); } public doPost (HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { /* Get account and password from HTML and create EJB*/ String account = req.getParameter("Account"); String password = req.getParameter("Password"); Broker brk = createBroker(account, password); ...} ...}

CSE298

CSE300

JR&B-1.59

User Interface Code User Interface Code

class TradeServlet extends HttpServlet { ... public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException { /* Get parameters from HTML and session object */ HttpSession session = req.getSession(true); String ticker = req.getParameter("Symbol"); ... Broker brk = (Broker) session.getValue("LoginServlet.BrokerRef"); /* Place order and print confirmation as HTML */ String orderNum = brk.submitOrder(txType, ticker, shares); printOrderSubmitted(out, account, orderNum); ... } }

CSE298

CSE300

JR&B-1.60

Business Logic Code Business Logic Code

class BrokerBean implements SessionBean { public void ejbCreate (String account, String password) ... public SecurityRecord getAcctPositions ( ) ... public OrderRecord getOrderStatus ( ) ... public String getQuote(String ticker) ... public String submitOrder(String txType, String ticker...) ... public HistoryRecord getAcctHistory ( ) ... private boolean login (...) ... ... etc ... }

CSE298

CSE300

JR&B-1.61

Database Access CodeDatabase Access Code

SQL:SQL: CREATE TABLE ORDER( ORDERNUM INTEGER NOT NULL, CUST INTEGER NOT NULL, TICKER VARCHAR(5), ... PRIMARY KEY (ORDERNUM), FOREIGN KEY (CUST) REFERENCES CUSTOMER);

Java:Java: class Order{ int orderNum; Customer cust; String ticker; ...}

Java Blend Automatically Maps Classes to/from Java Blend Automatically Maps Classes to/from Relational Tables at Compile-Time and Run-TimeRelational Tables at Compile-Time and Run-Time

CSE298

CSE300

JR&B-1.62

Nocturnal Aviation, Inc.Nocturnal Aviation, Inc.

Passenger Check-in for Regional Airline Passenger Check-in for Regional Airline Local Database for Seating on Today's Flights Local Database for Seating on Today's Flights Clients Invoke EJBs at Local Site Through RMI Clients Invoke EJBs at Local Site Through RMI EJBs Update Database and Queue Updates EJBs Update Database and Queue Updates JMS Queues Updates to Legacy System JMS Queues Updates to Legacy System DBC API Used to Access Local Database DBC API Used to Access Local Database JTS Synchs Remote Queue With Local UpdatesJTS Synchs Remote Queue With Local Updates

CSE298

CSE300

JR&B-1.63

Three-Tier ExampleThree-Tier Example

CSE298

CSE300

JR&B-1.64

Santa Cruz WidgetsSanta Cruz Widgets

Small Manufacturer Previously on C++ Small Manufacturer Previously on C++ New Order Entry, Inventory, and Invoicing New Order Entry, Inventory, and Invoicing

Applications in Java Programming Language Applications in Java Programming Language Existing Customer and Order Database Existing Customer and Order Database Most of Business Logic in Stored Procedures Most of Business Logic in Stored Procedures Tool-generated GUI Forms for Java ObjectsTool-generated GUI Forms for Java Objects Located Company on Web Using Widgets and Tcl, Located Company on Web Using Widgets and Tcl,

but Not Widgets and Javabut Not Widgets and Java

CSE298

CSE300

JR&B-1.65

Santa Cruz Widgets (2-tier) Santa Cruz Widgets (2-tier)

CSE298

CSE300

JR&B-1.66

Architecture ComparisonsArchitecture Comparisons

Two-tier Through JDBC API: Simplest Two-tier Through JDBC API: Simplest Multi-tier: Separate Business Logic, Protect Multi-tier: Separate Business Logic, Protect

Database Integrity, More Scaleable Database Integrity, More Scaleable JMS Queues Vs Synchronous (RMI or IDL): JMS Queues Vs Synchronous (RMI or IDL):

Availability, Response Time, Decoupling JMS Publish & Subscribe: Off-line Notification JMS Publish & Subscribe: Off-line Notification

RMI IIOP Vs JRMP Vs Java IDL: RMI IIOP Vs JRMP Vs Java IDL: Standard Cross-language Calls or Full Java

Functionality JTS: Distributed Integrity, Lockstep ActionsJTS: Distributed Integrity, Lockstep Actions

CSE298

CSE300

JR&B-1.67

Further API ComparisonsFurther API Comparisons

Servlets: Simplifies HTML, Connections, Web Servlets: Simplifies HTML, Connections, Web Front-Ending Legacy SystemsFront-Ending Legacy Systems

EJBs: Simplifies Components, Scalability, EJBs: Simplifies Components, Scalability, Transactions, Multi-threading, Security, StateTransactions, Multi-threading, Security, State

JDBC Vs ODMG Vs SQLJ API: JDBC Vs ODMG Vs SQLJ API: Programming Simplicity, Portability, SQL

Knowledge JNDI: Standardized Name Service Access JNDI: Standardized Name Service Access Enterprise Java APIs vs. Proprietary: Enterprise Java APIs vs. Proprietary:

Multi-Platform, Multiple Providers

CSE298

CSE300

JR&B-1.68

Summary & Key MessagesSummary & Key Messages

Enterprise Java APIs: EJB, JNDI, Java IDL, RMI, Enterprise Java APIs: EJB, JNDI, Java IDL, RMI, JDBC, ODMG, SQLJ, JMS, JTS, JMAPI, Servlets JDBC, ODMG, SQLJ, JMS, JTS, JMAPI, Servlets

Wide Variety of Architectural Alternatives: Wide Variety of Architectural Alternatives: Synchronous/Asynchronous, Multi-Tier,

Transactional, HTTP/JRMP/IIOP Benefits: Benefits:

WORA Portability Multiple Vendors Legacy Connectivity Java Programming Language Productivity

CSE298

CSE300

JR&B-1.69

EJB RoadmapEJB Roadmap

API Specification Complete ProductsEJB JavaSoft 1.0Q1 See PartnersJNDI JavaSoft 1.0 done Download SPJIDL OMG 1.0 Q2 JDK 1.2RMI JavaSoft 1.0 done JDK 1.1JDBC JavaSoft 2.0 Q2 JDK 1.2 PartnerODMG Consortium 2.0 done JavaBlendSQLJ Consortium 1.0 Q2 See PartnersJMS JavaSoft 1.0 Q2 See PartnersJTS OMG 1.0 done PartnersJMAPI JavaSoft 1.0 Q2 See PartnersSevlets JavaSoft 1.1 done Java Web Server

CSE298

CSE300

JR&B-1.70

What Is the Java Blend Product?What Is the Java Blend Product?

Product That Integrates Java Programming Product That Integrates Java Programming Language Objects With Enterprise Data Language Objects With Enterprise Data

Provides a Single Object Model Based on Java Provides a Single Object Model Based on Java Programming Language ClassesProgramming Language Classes Automatic Persistent Storage for Java

Application Objects Easy, Automatic Access to Existing Relational

Databases From Java Applications Result of Joint Development by the Javasoft Result of Joint Development by the Javasoft

Division, Baan and Tech@spree Division, Baan and Tech@spree

CSE298

CSE300

JR&B-1.71

JavaBlend ApplicationsJavaBlend Applications

JavaBlend Software Provides Mapping Capability JavaBlend Software Provides Mapping Capability Between Database Tables and Java Application Between Database Tables and Java Application ClassesClasses

Programmer Deals Only With Java Programming Programmer Deals Only With Java Programming Language Objects, and Does Not Need to Know Language Objects, and Does Not Need to Know SQL or Database RepresentationSQL or Database Representation

CSE298

CSE300

JR&B-1.72

Java Blend ComponentsJava Blend Components

Flexible Development Tool for Automatic Flexible Development Tool for Automatic Bi-Directional MappingBi-Directional Mapping Objects to Relational Relational to Objects

Powerful Runtime EnvironmentPowerful Runtime Environment Transaction Management System Query Processor Cache Management System

CSE298

CSE300

JR&B-1.73

Java Blend Runtime ArchitectureJava Blend Runtime Architecture

CSE298

CSE300

JR&B-1.74

Java Blend Software and Enterprise Java Blend Software and Enterprise JavaBeans Technology JavaBeans Technology

EJB Technology Provides Scaleable Component EJB Technology Provides Scaleable Component Architecture for Business ApplicationsArchitecture for Business Applications

Java Blend Product Provides Transparent Java Blend Product Provides Transparent Persistence for Enterprise Javabeans TechnologyPersistence for Enterprise Javabeans Technology Beans Implementing Business Logic Use Java

Blend for Database Access Java Blend Product Works With the Enterprise

Javabeans API Transaction Mechanisms