101
© Hewlett-Packard Company, 2000 H6786S version B.03 5/00 2-1 E-speak Fundamentals E-speak Fundamentals

E-speak Fundamentals

  • Upload
    pink

  • View
    42

  • Download
    0

Embed Size (px)

DESCRIPTION

E-speak Fundamentals. The Essential Difference. Hardware + Software Tell the computer how to do the job. Services Tell the computer what job you want done. Overview. What the "big picture" for e-speak is What the various modules of e-speak are How service providers and consumers interact - PowerPoint PPT Presentation

Citation preview

Page 1: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-1

E-speak FundamentalsE-speak Fundamentals

Page 2: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-2

The Essential DifferenceThe Essential Difference

Hardware + Software

Tell the computer how to do the job

Services

Tell the computer what job you want done

Page 3: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-3

OverviewOverview

What the "big picture" for e-speak is What the various modules of e-speak are How service providers and consumers interact How to identify projects that are a good fit with

the e-speak technology

Page 4: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-4

Monolithic, proprietary systems

Open systems2-tier client-server systems

Open data (Web)3-tier, 4-tier, … systemsProprietary, one-off services (Amazon.com, Expedia, eBay, …)

Open services (E-speak)Dynamic n-tier systemsService composition & Customization

Systems EvolutionSystems Evolution

Page 5: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-5

Do for services what the Web has done for data.

Make it as simple to create, compose, deploy, manage, personalize, and access services as it is to publish and access data on the Web.

E-speak - the Technology GoalE-speak - the Technology Goal

Page 6: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-6

Internet (connectivity)

Web (data)

E-speak (services)

Technology Platform for Open Services

What is E-speak ?What is E-speak ?

Page 7: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-7

What does E-speak do ? What is it ?What does E-speak do ? What is it ?

In a world made up of electronic services, (being provided and consumed on the intranet or internet)

e-speak helps to solve the problems of

developing,deploying, advertising,securing and managing

those electronic services. E-speak is a platform for services

Page 8: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-8

Appliance Service Provider A

Service Provider B

Service Provider C

E-speak

Services on TapServices on Tap

1. User needs application on the appliance2. Appliance connects to e-speak and asks

it to find the "best" provider3. Service provider runs the application4. E-speak mediates the interaction5. Data store can be on appliance, in

service provider B, or elsewhere in the system.

6. Consumer and service provider may remain mutually anonymous

Page 9: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-9

An E-service in E-speak termsAn E-service in E-speak terms

has an interface (programmatic or document based) can be described using attributes can be found using an attribute-based description can be managed by a party other than the user is available for use on a distributed basis

Page 10: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-10

Service Specification

WorkflowRequirementsAccess control (security, billing, ...)

Utility

Service Access

Int**net

Service Execution

Int**net

Utility

Service Discovery

Int**net

Utility

Int**net

Reducing the barrier to new,

competitive services

Services FrameworkServices Framework

Page 11: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-11

Int**net

Utility

New services and service compositions,

New service providers

New customers

Discover

Distribute

MonitorBill

Verify

Manage

Meter

Convert

QoS

Locate

Negotiate

Mirror

Isolate

Cache

Open Services MarketplaceOpen Services Marketplace

Page 12: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-12

Service Framework Service Framework

Hea

lth

M

on

ito

rin

g

Dat

a S

tora

ge

Dat

a M

inin

g

Ser

vice

N

ER

P

Pri

nti

ng

Pro

cure

men

t

Document Exchange Model

E-speak Service EngineE-speak Service Engine

E-speak API (J-ESI) Network Object ModelE-speak API (J-ESI) Network Object Model

E-Speak: The Big Picture E-Speak: The Big Picture

Page 13: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-13

Assumptions and ImplicationsAssumptions and Implications

• Large number of machines– No centralized anything, forget consistency

• Dynamic– Deal with failures, new services

• Heterogeneous– Different hardware, OS, capability

• Hostile environment– Security is critical

• Different fiefdoms– Never look inside another machine

Page 14: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-14

E-speak Resource Model

E-speak System

Attribute Descriptions

Naming

Permissions Interfaces

Communication

Virtual Resource Abstraction

Attribute Vocabularies

Authorization

Transports Repositories

Basic Services

ResourceAccess

LDAPDCOM/CORBAJava PlatformHTTP

Basic Services

Interrupt Handling

Scheduling

Memory Management

Timer Services

Legacy OS

Legacy Resource Abstraction

(eg: NTFS)

Page 15: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-15

The E-speak Engine’sThe E-speak Engine’sThree Main Functions Three Main Functions

Managing a repository of service descriptions for the purposes of allowing others to find those services

Message routing (to services or to other engines) Name handling (allowing users to create name

hierarchies)

Page 16: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-16

A Simplified View of an Architecture

E-speak engine E-speak engine

Service ConsumerService Provider

Architecture - Scenario 1Architecture - Scenario 1

Federation of autonomous engines Asynchronous, message-passing between engines Service mediation

Naming, monitoring, service location independence

Page 17: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-17

1. find a service

E-speak engine E-speak engine

Service Consumer Service Provider

Architecture - Scenario 2Architecture - Scenario 2

Look up a service in one engine Get a reference to a second engine (or the web

access part of the second engine) Use the service via the second engine

2. Use the service

Page 18: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-18

1. find the service

E-speak engine

Service Consumer Service Provider

Architecture - Scenario 3Architecture - Scenario 3

Look up a service in one engine Get a reference to the service Use the service directly (no engine intervention) This is the web access model (check documentation

for more information)

2. Use the service

Page 19: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-19

E-speak vs.Traditional Middleware

• Virtual service intermediation

• Uniform services model

• Attribute-based lookup

• Individual name spaces

• Capability-based security

Proxies

e-speak

Core Core

Clientapplication

Advertisingservice

Service

Service

Traditional Middleware

Directory

Server

Server

Client

• Directory lookup

• Direct access to service

• No mediation

• No virtualization

Page 20: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-20

J-ESI and E-speak WebAccessJ-ESI and E-speak WebAccess

J-ESI: (Java E-service Interface - the engine API) fast, relatively close coupling (programmatic interface must be

shared by service provider and service consumer) intense and small grained interactions feasible more suited to intranet uses

WebAccess: piercing of firewalls simpler, use of services on the internet, B2B larger overhead (parsing of XML documents, WebServer, servlet

time consumption) per message larger grained messages (e.g. one XML document contains all information) standard message content, loose coupling of service provider to

consumer

Page 21: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-21

XML and e-speakXML and e-speak

The e-speak J-ESI currently supports XML for the following vocabulary descriptions service descriptions queries

XML will also be used to interact with the e-speak core and e-speak components

XML can be used as the encoding for the payload of your service interface You must provide your own parsing for the message

payload as part of your service provider and service consumer code

This use of XML is independent of the e-speak engine; the engine does not interpret the payload of messages.

Page 22: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-22

Technology InnovationsTechnology Innovations

Dynamic discovery of services Security Model Meta-data Model

Page 23: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-23

The E-speak Network Object Model The E-speak Network Object Model

How Service Providers and Service How Service Providers and Service Consumers Interact Consumers Interact

Page 24: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-24

service consumer

clientlibrary

engine

resource

resourcehandler

clientlibrary

The E-speak Engine’s Network Object The E-speak Engine’s Network Object ModelModel

A resource is anything that can be described to e-speak using attributes and their values

Page 25: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-25

service consumer

clientlibrary

engine

resource

resourcehandler

clientlibrary

J-ESI J-ESI

ABI ABI

Interfaces are defined between Interfaces are defined between componentscomponents

ABI - Application Binary Interface - a set of

structured messages between the engine and

the client library

Page 26: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-26

service consumer

clientlibrary

engine

resource

resourcehandler

clientlibrary

E-speak

provides these

J-ESI J-ESI

ABI ABI

E-speak’s Network Object ModelE-speak’s Network Object Model

Developer writes this

Developer writes this

Page 27: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-27

Q: How does a task use a resource from another e-speak engine?

A: The same way it uses a resource on its own engine.

E-speak’s Network Object ModelE-speak’s Network Object Model

Page 28: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-28

service consumer

clientlibrary

engine

resource

resourcehandler

clientlibrary

A Single engine ViewA Single engine View

Page 29: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-29

service consumer

clientlibrary

Engine A

resource

Engine B

resourcehandler

clientlibrary

A Multiple-Engine ViewA Multiple-Engine View

ABI

ABI ABI

Page 30: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-30

service consumer

clientlibrary

engine

resource

engine

resourcehandler

clientlibrary

J-ESI J-ESI

ABI

ABI

ABI

E-speak

E-speak’s Network Object ModelE-speak’s Network Object Model

Page 31: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-31

Q: How can e-speak handle the great variety of potential services?

A: E-speak is concerned with service metadata and access control.

Page 32: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-32

MetadataMetadata

Description (attributes with values) Vocabulary (one or more, in which the service is

described) Contract (the interface provided by the service) Access Control (handled by the security subsystem)

Page 33: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-33

A simple exampleA simple example

Show me what happens when a consumer makes use of an e-service.

Page 34: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-34

providersystems

engine B

serviceprovider

J-ESI clientlibrary

1. service provider registers with the local engine.

E-speak’s Network Object ModelE-speak’s Network Object Model

Page 35: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-35

service consumer

engine A engine B

serviceprovider

2. Consumer does a “find” on its local engine (using a J-ESI API call) to discover one or more suitable service providers.

J-ESI clientlibrary

E-speak’s Network Object ModelE-speak’s Network Object Model

More detail on this “discovery” later.

Page 36: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-36

service consumer

engine A engine B

serviceprovider

3. Consumer sends message to service provider via its local engine.

J-ESI clientlibrary

E-speak’s Network Object ModelE-speak’s Network Object Model

Page 37: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-37

serviceconsumer

engine A engine B

serviceprovider

4. Security library checks access.

5. engine A knows that this message should be sent to engine B, (since it received internal e-speak data from engine B earlier, which told it so).

E-speak’s Network Object ModelE-speak’s Network Object Model

Page 38: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-38

serviceconsumer

engine A engine B

serviceprovider

6. engine A sends the message to engine B.

(Engines communicate using ABI compatible messages)

E-speak’s Network Object ModelE-speak’s Network Object Model

Page 39: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-39

serviceconsumer

J-ESI clientlibrary

Engine A Engine B

service provider

7. engine B forwards the message to the service provider.

8. Library checks that the request is allowed.

E-speak’s Network Object ModelE-speak’s Network Object Model

Page 40: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-40

Q: How are new e-services made available to others?

A: E-services are registered by a service provider. Attribute-based lookups discover registered services.

Page 41: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-41

Dynamic DiscoveryDynamic Discovery

YOU

SERVICE PROVIDER

hotelbookinge-service

travele-service

travele-service

hotelbookinge-service

hotelbookinge-service

airlinebookinge-service

airlinebookinge-service

weathere-service

reservatione-service

travele-service

SERVICE PROVIDER

Page 42: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-42

Discovery optionsDiscovery options

1. Obtain reference to a service from a local repository “find” call

2. Receive a reference from someone else (e.g., an advertising service)

Both of these actions are done by the service finder “find” API (see the ESServiceFinder class document online).

3. A reference may be loaded from persistent store

Page 43: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-43

advertisinge-service

serviceprovider

1. advertise

Advertising and findingAdvertising and finding

engine

Advertising services are standard services attached to engines (often as default options). They have their own service description repositories.

Page 44: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-44

advertisinge-service

serviceprovider

serviceconsumer

1. advertise

2. find

engine engine

Page 45: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-45

advertisinge-service

serviceprovider

serviceconsumer

1. advertise2. find

3. engine location information

engine engine

Page 46: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-46

advertisinge-service

serviceprovider

serviceconsumer

1. advertise

2. find

3. engine location information

4. service accessengine engine

Page 47: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-47

advertisinge-service

serviceprovider

serviceconsumer

1. advertise

2. find

3. engine location information

4. service access

5. service resultengine engine

Page 48: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-48

Where is E-speak a good fit in projects?Where is E-speak a good fit in projects?

Dynamic discovery of services, based on attribute matching, in a set of growing services, either from one or many providers (openness to new services)

Establishing communities of use for a set of services Mediation of access to services (access control) Creating a trusted third party between pairs of

unfamiliar parties (provider and consumer of service) Comparing services against others Composing services from other services Monitoring of service use Negotiation between services

Page 49: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-49

E-speak TerminologyE-speak Terminology

Page 50: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-50

ESServiceElement.register()ESService from

ESServiceFinder.find()

ESConnection ESConnection

Utility/Community

A Network Object Model Programmer’s A Network Object Model Programmer’s ViewpointViewpoint

Service Provider

Service Consumer

Page 51: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-51

engine Events

Naming

Router

ResourceHandler

Repository

(Metadata)

ServiceConsumer

Name Space Name Space

Event Subscriber

Actions1. Message created2. Message Delivered

to engine

Start of a RequestStart of a Request

Service Provider

Page 52: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-52

engine Events

Naming

Router

Service Consumer

Resource Handler

Repository

(Metadata)

Name Space Name Space

Event Subscriber

Action: Application Namesmapped to engine handles viaRepository Lookup.Message is then delivered.

Name ManagerName Manager

Service Provider

Page 53: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-53

Resource Access ControlResource Access Control

This is handled outside the engine by the security library

The engine does not protect access to any resources that are not “its own” data, that is the service metadata.

Protection in e-speak is between two endpoints that manage access rights independently of the engine.

Page 54: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-54

Each connected party has an accountEach connected party has an account

Folders Compendium of mappings of application-specific names to

resources/services Provides complete configurability of application-visible

names

An account contains

Page 55: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-55

E-speak - What is in the download ?E-speak - What is in the download ?

The E-speak “engine”, a platform for mediated access to services, for management and monitoring of services

A set of Java APIs that allow the E-speak engine to be used

Advertising and event services Security service Management services (Process, Service management) Tools for manipulating the services above Contributed applications (samples, VFS)

Page 56: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-56

Design PrinciplesDesign Principles

Uniform representation for resources/services E-speak engine manages/manipulates representation

of resources Resource Identity can be established through

attribute descriptions URL’s are also available as Resource/Service

identifiers ESAccessor is the way in which programmers identify

a service - look at Service ID for security reasons Resource addressability through names - separate

from identity Reasoning about Contracts and Attribute Models

Page 57: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-57

E-speak TerminologyE-speak Terminology

Resource An entity which can be described and used by others The fundamental building block in E-speak technology Used to represent a service Described using attributes

Resource Handler A service provider - an active piece of code that registers a

service and handles calls to that service

Page 58: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-58

E-speak TerminologyE-speak Terminology

Account Equivalent to a user account or “protection domain” in

operating systems; Encapsulation of an active-entity’s environment Has a mapping of the application’s private names to

resources/services handles (which are maintained by engines)

Every connection to an engine has its own environment Contract

Protocol or interface between service consumer and service provider (sometimes referred to as the API of the service)

Vocabulary Description of a service in terms of attributes

Page 59: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-59

Service Development using J-ESIService Development using J-ESI

Page 60: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-60

OutlineOutline

Overview of the e-speak J-ESI APIs The steps for writing a simple service A first look at the J-ESI APIs for

ESConnection ESServiceDescription ESServiceElement

e-speak IDL How to describe a service’s interface How to compile an ESIDL file

Page 61: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-61

Using the e-speak J-ESI APIUsing the e-speak J-ESI API

Service providers connect to the e-speak engine describe their service using a vocabulary and a contract

(interface definition) create a service, provide an implementation of the contract (interface) register the service (with the engine) start the service

Service consumers connect to the e-speak engine find the service they want to use by formulating a query in a

vocabulary use the service according to its interface

Page 62: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-62

Key API ConceptsKey API Concepts

The engine provides 4 first-order abstractions: Service Vocabulary Contract View

For each of these, the engine offers the following mechanisms: Description -- a way to describe the service, vocabulary or

contract Element -- a way to register it Finder -- a way to find it A means of delivering the stub for the resource/service so

that it can be used remotely.

Page 63: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-63

Class Diagram: DescriptionsClass Diagram: Descriptions

ESBaseDescription

ESServiceDescription ESVocabularyDescription ESContractDescription

addStringProperty(...)addIntegerProperty()

setInterfaceDefinition(..)

addAttribute()getAttributes()getVocabulary()

ESViewDescription

equals(...)toString()

Page 64: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-64

Class Diagram: Element ClassesClass Diagram: Element Classes

ESAbstractElement

ESServiceElement ESVocabularyElement ESContractElement

advertise()unadvertise()unregister()update(…)alreadyExists(…)

getAccessor()getAttributes()register()setImplementation(..)start(). . .

register() register()

ESViewElement

register()

Page 65: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-65

Class Diagram: FindersClass Diagram: Finders

ESAbstractFinder

ESServiceFinder ESVocabularyFinder ESContractFinder

find(ESQuery q)findAll(ESQuery q)getMaxToFind()setMaxToFind(…)

find(ESQuery q)findAll(ESQuery q)

find(ESQuery q)findAll(ESQuery q)

ESViewFinder

find(ESQuery q)findAll(ESQuery q)

Page 66: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-66

Base Base InterfacesInterfaces for All Services - used for All Services - used by the Stubs classesby the Stubs classes

ESBaseService

ESService ESVocabulary ESContract

getProperties() getInterfaceDefinition(…)getInterfaceName(…)

ESView

add()clear()contains()remove()

An object of class ESServiceStub, which implements this interface is the return type from ESServiceFinder.find()

Page 67: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-67

Other Interesting ClassesOther Interesting Classes

ESXMLFile ESCommunityESXMLQuery

ESQuery ESConnection

addConstraint() close()getBaseVocabulary()getDefaultPublisher()getHomeFolder()getSecurityContext()

add(...)listGroupServers()

ESIceptor

Intercept messagesbetween the J-ESIlibrary and the engine

Load into memory andparse an e-speakcompatible XML file

Load into memory andparse an e-speakcompatible XML filecontaining a “find()”constraint

Page 68: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-68

Creating a Service with e-speakCreating a Service with e-speak

Page 69: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-69

Using the e-speak J-ESI APIUsing the e-speak J-ESI API

Service providers do the following

create an interface definition using esidl create an implementation class that does the real work create a “main program” class that drives the registration

and implements the startup for the service

Page 70: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-70

The Anatomy of a ServiceThe Anatomy of a Service

Service S

service description

service element

specifies the implementation for a service

describes the service using a vocabulary;

AND

allows a service to be found by a consumer

SIntf.esidldescribes the interface

S.javadeploys the service; provides description

and contract to engine

SImpl.javaimplements the

interface (the actual service code)

The service implementor writes these.

Page 71: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-71

Writing a Service "Writing a Service "SS""

Create the interface file: SIntf.esidl Run the esidl compiler

Produces SIntf.java, SStub.java and SIntfMessageRegistry.java Create SImpl.java

Contains the actual implementation of the service tasks Create S.java

Contains the main program for the service Describes a service Ensures that the description for the service is registered Provides a backend implementation of the service (SImpl.java)

to the engine Starts the service

Page 72: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-72

SSIntf.esidlIntf.esidl

package x; //choose an appropriate package name - optional

import net.espeak.jesi.*;import net.espeak.infra.cci.exception.ESInvocationException;// Import other packages/classes as needed

public interface SIntf extends ESService{

// define the methods for the service with appropriate return// types and parameterspublic void invokeService()

throws ESInvocationException;}

Page 73: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-73

E-speak IDL CompilerE-speak IDL Compiler

A set of classes provided with e-speak Takes an interface definition file and generates a stub for the

service from it (along with marshalling code in a registry file)

%JRE% /cp:p "%CLASSPATH%;%ESPEAK_CLASSPATH%;lib" net.espeak.util.esidl.IDLCompiler src/HelloServiceIntf.esidl

OR

java net.espeak.util.esidl.IDLCompiler -classpath %CLASSPATH%;%ESPEAK_CLASSPATH%;lib" src/HelloServiceIntf.esidl

(In our lab, the utility file, idlcompile.bat, requires the .esidl file extension)

Page 74: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-74

SSImpl.javaImpl.java

package x; // optional package name

import net.espeak.infra.cci.exception.ESInvocationException;

public class SImpl implements SIntf{

// write the methods for the service as declared in SIntfpublic void invokeService()

throws ESInvocationException{

// method code goes here}

}

Page 75: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-75

SS.java.java

package x; // optionalimport net.espeak.jesi.*;import net.espeak.infra.cci.exception.*;public class S {

public static void main (String[] args){

try{

// Connect to the e-speak engine (see the following slide) // Register and start the service with the engine

}catch (Exception e){ // do whatever you want with exceptions

System.err.println(e);} } }

Page 76: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-76

Connect to the e-speak engineConnect to the e-speak engine

// Connect to the e-speak engine using a property fileESConnection connection = new ESConnection(propFileName);

OR

// Connect to the e-speak engine using a java.util.Properties objectESConnection connection = new ESConnection(properties);

The null constructor ESConnection() has been deprecated, but still works in E-speak 3.01.

Page 77: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-77

ESConnectionESConnection

represents the connection from a client to the engine has the following properties

username password esurl [specifies the communication path to the engine, e.g.

tcp:machine.cup.hp.com:12346] protocol

hostnameportnumber [these properties are an alternative to esurl]

accountname

Page 78: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-78

ESConnection interfaceESConnection interface

ESConnection(propertyFileName) propertyFileName is the name of a file that specifies the

parameters for the connection if an user account is specified in the property file, it will be

used in the connection (and created if it does not exist) if no account is specified, a transient guest account is used

Page 79: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-79

Create a service descriptionCreate a service description

// Create a service descriptionESServiceDescription servDesc = new ESServiceDescription ();// Add the attributes of the service to the description// using the base vocabularyservDesc.addAttribute("Name", "service name for S");

Here, we are using the Base Vocabulary to create a description. The attribute “Name” belongs to this Base Vocabulary.

Later, we will use domain-specific vocabularies, and see how to use XML to build the service description.

Page 80: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-80

Service DescriptionService Description

Attribute Set - Name-value pair that describes resource Preferred notion of finding services in the system

Attribute Vocabulary - understands grammar of description Keywords, order of attributes etc.

Contract - represents the API of the Service Contracts and vocabularies are covered in detail in module 6 In J-ESI, the contract is a Java-style interface.

Page 81: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-81

Create, Register & Start the ServiceCreate, Register & Start the Service

// Create a service element, which represents this service to the engineESServiceElement servElement =

new ESServiceElement (connection, servDesc);

// Create the implementation and tell the engine where to find itservElement.setImplementation(new SImpl());

// Register the serviceservElement.register();

// Start the serviceservElement.start();

This calls a constructor for the implementation class.

We may use any of the constructors in SImpl.java

Page 82: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-82

Example: A Classified Ad ServiceExample: A Classified Ad Service

ClassifiedIntf.esidl Classified.java

•the handler for the service•registers and starts the service with the engine

•defines the interface for the service:placeAd(String text)getCategories()readAds(String category)

ClassifiedIntf.java

•created by the esidl compiler

ClassifiedImpl.java

•implements the interface ClassifiedIntf•contains the actual service code

In this example, an electronic classified advertising service allows you to:

•place an ad

•retrieve the list of advertising categories

•read the ads in a particular category

Page 83: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-83

Write ClassifiedIntf.esidlWrite ClassifiedIntf.esidl

import net.espeak.jesi.*;import net.espeak.infra.cci.exception.ESInvocationException;

public interface ClassifiedIntf extends ESService{

public void placeAd(String text)throws ESInvocationException;

public String[] getCategories()throws ESInvocationException;

public String[] readAds(String category)throws ESInvocationException;

}

Page 84: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-84

Compile the esidlCompile the esidl

%JRE% /cp:p "%CLASSPATH%;%ESPEAK_CLASSPATH%;lib" esidl.IDLCompiler ClassifiedIntf.esidl OR java -classpath "%CLASSPATH%;%ESPEAK_CLASSPATH%;lib" esidl.IDLCompiler ClassifiedIntf.esidl

ClassifiedIntf.esidl

ClassifiedIntfMessageRegistry.java

ClassifiedStub.javaClassifiedIntf.java

These files are generated by the esidl compiler

Page 85: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-85

Write ClassifiedImpl.javaWrite ClassifiedImpl.java

import net.espeak.infra.cci.exception.ESInvocationException;

public class ClassifiedImpl implements ClassifiedIntf{

public void placeAd(String text)throws ESInvocationException

{ /* write the code to place an advertisement here */ }public String[] getCategories()

throws ESInvocationException{ /* write the code to get the categories here */}

public String[] readAds(String category)throws ESInvocationException

{ /* write the code to read the advertisements here */ }}

Note that you may want to write one or more constructors for ClassifiedImpl

Page 86: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-86

Write Classified.javaWrite Classified.java

import net.espeak.jesi.*;import net.espeak.infra.cci.exception.*;public class Classified{ public static void main (String[] args)

{ try{ ESConnection conn = new ESConnection(propFileName);

ESServiceDescription sDesc = new ESServiceDescription ();sDesc.addAttribute("Name", "Classified");ESServiceElement sElem =

new ESServiceElement (conn, sDesc);sElem.setImplementation(new ClassifiedImpl());sElem.register();sElem.start();

} catch (Exception e){ System.err.println(e); }

} }

Page 87: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-87

Compile and Run the ServiceCompile and Run the Service

Compile the files:%JVC% /cp:p %CLASSPATH%;%ESPEAK_CLASSPATH%;.

ClassifiedIntf.java ClassifiedImpl.java Classified.java ClassifiedIntfMessageRegistry.java

ClassifiedStub.java Run the service

%JRE% /cp:p "%CLASSPATH%;%ESPEAK_CLASSPATH%;." Classified

or java -classpath "%CLASSPATH%;%ESPEAK_CLASSPATH%;." Classified

Note : You should have the e-speak engine up and running before running this service

Page 88: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-88

Service Provider SummaryService Provider Summary

Connect to engine Create service description (in a particular vocabulary) Register the service with engine Start the Service

Wait for request Process request Send reply

Page 89: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-89

Setting the CLASSPATH variableSetting the CLASSPATH variable

set CLASSPATH=C:\E-speak\lib\escore.jar;C:\E-speak\lib\esclient.jar;C:\e-speak\lib\swingall.jar;C:\e-speak\extern\cryptix\cryptix.jar;C:\e-speak\extern\parser\xerces.jar;C:\jsdk2.0\lib\jsdk.jar (servlet developers

kit)

escore.jar ~ 408 classesesclient.jar ~ 1378 classes

Page 90: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-90

Using a Service Using a Service

Page 91: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-91

In this module, you will learnIn this module, you will learn

How to build a service consumer that uses the e-speak API to connect to the e-speak engine find a service by formulating a query in a

vocabulary use the service according to its interface

Page 92: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-92

The Anatomy of a ConsumerThe Anatomy of a Consumer

Consumer C.javacontains the code

that uses oneor more services

The consumer does not register with the e-speak engine. It connects to the engine and uses services -- so it has to know how to find the services, and how to use the interfaces that the services support.

SIntf.esidldescribes the interface

SIntfMessageRegistry.java

SStub.java

SIntf.java

generatesuses

Developer writes this

and uses the interface below

Page 93: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-93

Writing a Consumer "Writing a Consumer "CC""

Obtain the interface file: SIntf.esidl May be published by a service provider or consortium Could be retrieved by writing the code to find the contract (as we

will see in the Vocabularies and Contracts section) Run the esidl compiler

Produces SIntf.java, SStub.java and SIntfMessageRegistry.java Create C.java

Contains the main program for the consumer Uses the e-speak engine to locate a service that provides the

desired interface and matches the desired attributes Uses the service by invoking its methods

Compile and run the consumer

Page 94: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-94

CC.java.java

import net.espeak.jesi.*;import net.espeak.infra.cci.exception.*;public class C {

public static void main (String[] args){

try{ // Connect to the e-speak engine (just like the provider code)

ESConnection myConn = new ESConnection(propertyFileName);// Find the service// Use the service

}catch (Exception e){ // do whatever you want with exceptions

e.printStackTrace();} } }

Page 95: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-95

Finding a serviceFinding a service

// Create a “finder” object to perform the search for a service.// The second parameter filters so that only services that have the// specified interface will be consideredString interfaceName = SIntf.class.getName();ESServiceFinder servFinder = new ESServiceFinder (myConn, interfaceName);

// Create a query object to specify the attributes of the service. You may // search using any attributes you wishESQuery query = new ESQuery ("Name == 'service name for S'");

// Get the service from the finder, using the querySIntf myServiceObj = (SIntf) servFinder.find(query);

If the service was described in a vocabulary other than the Base Vocabulary, you would first need to find the vocabulary and use it to formulate the query.

Page 96: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-96

Using a ServiceUsing a Service

// Use the service myServiceObj.invokeService();

Page 97: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-97

Compiling the Service Consumer codeCompiling the Service Consumer code

Compile the files:%JVC% /cp:p %CLASSPATH%;%ESPEAK_CLASSPATH%;. ClassifiedIntf.java Consumer.java ClassifiedIntfMessageRegistry.java ClassifiedIntfStub.java

or javac -classpath %CLASSPATH%;%ESPEAK_CLASSPATH%;. ClassifiedIntf.java Consumer.java

ClassifiedIntfMessageRegistry.java ClassifiedIntfStub.java Run the service consumer

the e-speak engine must be up and running the service should also be registered and running

%JRE% /cp:p "%CLASSPATH%;%ESPEAK_CLASSPATH%;." Consumer ORjava -classpath "%CLASSPATH%;%ESPEAK_CLASSPATH%;." Consumer

Page 98: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-98

Service Consumer codeService Consumer code

In the next piece of code, we will be using an

ESVocabularyFinder object,

which allows us to find a vocabulary, in the same way we used an

ESServiceFinder object

to find a service previously (using an attribute-based query)

Assumption : we know how to use this vocabulary

Page 99: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-99

Service Consumer ExampleService Consumer Example

import net.espeak.jesi.*;import net.espeak.infra.cci.exception.*;public class Advertiser { public static void main (String[] args)

{ try{ ESConnection conn = new ESConnection(propFileName);

try{ // Find the vocabulary

ESQuery vQuery = new ESQuery("Name == 'AdvertVocab'");

ESVocabularyFinder findVocab = new ESVocabularyFinder(conn);

ESVocabulary myVocab = findVocab.find(vQuery);} catch (LookupFailedException lfe) { throw lfe; }

continued on next page . . .

Page 100: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-100

Service Consumer Example, continuedService Consumer Example, continued

// Find the serviceString interfaceName = ClassifiedIntf.class.getName();ESServiceFinder servFinder =

new ESServiceFinder (connection, interfaceName);// note that this query is created to use the Classified vocabularyESQuery query = new ESQuery(myVocab, "PublicationName == 'Weekly Planet'"); // Constraint

ClassifiedIntf myPaper = (ClassifiedIntf) servFinder.find(query);// Use the service to get the classified ads for carsString theAdds = myPaper.readAds("car");

}catch (Exception e){ // do whatever you want with exceptions

e.printStackTrace();} } }

Page 101: E-speak Fundamentals

© Hewlett-Packard Company, 2000H6786S version B.03 5/00

2-101

Service Consumer SummaryService Consumer Summary

Connect to engine Find service Invoke service Handle response from service

Now that we have seen both service provider and service consumer sides of the code, we may also have the case where the service describer/advertiser is a completely separate entity (such as a standards body).

We can separate the code for description/advertising from the service implementation, if we choose to.