Top Banner
SERVICE-ORIENTED PROGRAMMING
33
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Service oriented programming with jolie part1

SERVICE-ORIENTED PROGRAMMING

Page 2: Service oriented programming with jolie part1

Overview

• Service-oriented programming• Introduction

• Fundamental concepts

• Jolie – Service Oriented Programming Language• Basic

• Data structure

Page 3: Service oriented programming with jolie part1

Introduction

- Function programming

- Object-oriented programming

- Service-oriented programming?

Page 4: Service oriented programming with jolie part1

Introduction

• What’s “service”?A service is an abstract resource that represents a capability of performing tasks that form a coherent functionality from the point of view of provider entities and requester entities. To be used, a service must be realized by a concrete provider agent

Page 5: Service oriented programming with jolie part1

What’s Service-oriented programming (SOP) Service-oriented programming (SOP) is a programming paradigm

that uses "services" as the unit of computer work, to design and implement integrated business applications and mission critical software programs. Services can represent steps of business processes and thus one of the main applications of this paradigm is the cost-effective delivery of standalone or composite business applications that can "integrate from the inside-out"

Page 6: Service oriented programming with jolie part1

ELEMEMT OF SOP

• Contract – An interface that contractually defines the syntax and semantics of a single behavior.

• Component – A third-party deployable computing element that is reusable due to independence from platforms, protocols, and deployment environments.

• Connector – An encapsulation of transport-specific details for a specifiedcontract. It is an individually deployable element.

• Container – An environment for executing components that managers availability and code security

• Context – An environment for deploying plug and play components, that prescribes the details of installation, security, discovery, and lookup

Page 7: Service oriented programming with jolie part1

Fundamental concepts

• Encapsulation• In-memory software modules are strictly encapsulated

• Using service interfaces for information hiding

Page 8: Service oriented programming with jolie part1

Fundamental concepts (Con.)

• Service interface• A service interface in SOP is an in-memory object that describes a well-

defined software task with well-defined input and output data structures

• Service interfaces can be grouped in to packages

• An SOP service interface can be externalized as a WSDL operation and a single service or a package of services can be described using WSDL

Page 9: Service oriented programming with jolie part1

Fundamental concepts (Con.)

• Service invoker• A service invoker makes service requests

Page 10: Service oriented programming with jolie part1

Fundamental concepts (Con.)

• Service listener• A service listener receivers service requests

Page 11: Service oriented programming with jolie part1

Fundamental concepts (Con.)

• Service implementation

• Semantic-based approach

• Programming constructs

• …

Page 12: Service oriented programming with jolie part1

JOLIE

Page 13: Service oriented programming with jolie part1

Introduction

• Nice logo:

• Formal foundations from the Academia

• Tested and used in the real world:

• Open source (http://www.jolie-lang.org/)

Page 14: Service oriented programming with jolie part1

Hello, Joie!

include “console.iol”

main

{

println@Console(“Hello, World!”)()

}

Page 15: Service oriented programming with jolie part1

What’s JOLIE can do?

• Simple services

• Orchestrators

• Web Application

• System compostition

and more program in a service-oriented style

Page 16: Service oriented programming with jolie part1

Understanding Hello World: concepts

Page 17: Service oriented programming with jolie part1

Our first service-oriented application

• A program defines the input/output communication it will make

• A sends 5 to B through the sendNunmber operation

• We need tell A how to reach B

• We need tell B how to expose sendNumber

• In other words, how they can communicate!

Page 18: Service oriented programming with jolie part1

Ports and interfaces: overview

• Services communicate through ports

• Ports give access to an interface

• An Interface is a set of operations

• An output port is used to invoke interfaces exposed by other service

• An input port is used to expose an interface

• Example: a client has an output port connected an input port a a calculator

Page 19: Service oriented programming with jolie part1

Our first service-oriented application

A.ol B.ol

Page 20: Service oriented programming with jolie part1

Anatomy of a port

• A port specifies:• The location on which the communication can take place;

• The protocol to use for encoding/decoding data

• The interfaces it exposes

• Ther is no limit how many ports a service can use

Page 21: Service oriented programming with jolie part1

Anatomy of a port: location

• A location is a URI (Uniform Resource Identifier) describing:• The communication medium to use;

• The parameters for the communication medium to work

• Some examples:• TCP/ IP : socket://www.google.com:80/

• Bluetooth :btl2cap://localhost:3B9FA89520078C303355AAA694238F07;name=Vision;encrypt=false;authenticate=false

• Unix sockets : localsocket:/tmp/mysocket.socket

• Java RMI : rmi://myrmiurl.com/MyService

Page 22: Service oriented programming with jolie part1

Anatomy of a port: protocol

• A protocol is a name, optionally equipped with configuration parameters

• Some examples: sodep, soap, htp, xmlrpc,..

Protocol : sodepProtocol : soapProtocol : http { .debug = true }

Page 23: Service oriented programming with jolie part1

Deployment and Behaviour

• A JOLIE program is composed by two definitions:• Deployment: defines how to execute by behavior and how to interact with

the rest of the system

• Behaviour : defines the workflow the service will execute

Page 24: Service oriented programming with jolie part1

Operation types:

• JOLIE sypports two of operations:• ONE – WAY: receives a message;

• REQUEST-RESPONSE: receives a message and send a response back

• In our example, sendNumber was a One-way operation

• Syntax for Request-Response:

Page 25: Service oriented programming with jolie part1

Basic data types

• Jolie is a dynamically typed language• No type declaration is needed when assigning values to variables

• Jolie supports seven basic data types:• bool : Booleans;

• int : integers;

• long : long integers;

• double: double-precision float;

• string : strings;

• raw : byte arrays;

• void: the empty type;

Page 26: Service oriented programming with jolie part1

Basic data types (cont.)

• Jolie supports the any basic type, which means a value that can be any basic type

1

2

a = 5;

a = "Hello"

Page 27: Service oriented programming with jolie part1

Basic data types (cont.)

• JOLIE supports some basic arithmetic operators: add (+) , subtract (-), multiply ( *) , divide ( / ) and modulo (%)

• pre-/post-increment (++) and pre-/post-decrement (--) operators.

Page 28: Service oriented programming with jolie part1

Casting and checking variable types

• Variables can be cast to other types by using corresponding casting functions: bools(), int(), long(), double()and string()

s = “10”

n = s + int( s ); // n = 15

d = “1.3”

n = double ( d ) ; // n = 1.3

n = int ( n ) // n = 1

Page 29: Service oriented programming with jolie part1

Dynamic array

• Arrray in Joie are dynamic and can be accessed by using [ ] oprator• a [ 0 ] = 0;

• a [ 1 ] = 5;

• a [ 2 ] = “Hello”;

• a [ 3 ] = 2.5

• a = 1; // JOLIE interprets this as a[0] = 1

• println@Console( a[ 0 ] )( ) // Will print 1

in JOLIE every variable is a dynamic array.

Page 30: Service oriented programming with jolie part1

Data Structures

• Jolie data structures are tree-like• It is easier to understand them by making a comparison between a data

structure in Jolie and its equivalent in XML.

Page 31: Service oriented programming with jolie part1

Createing a data structure

• Create a root node, named animals which contains two children note : pet and wild. Each of them is an array with two elements, respectively equipped with another sub-element (its name).

Page 32: Service oriented programming with jolie part1

Creating a data structure

• In JOLIE

main

{

animals.pet[0].name = "cat";

animals.pet[1].name = "dog";

animals.wild[0].name = "tiger";

animals.wild[1].name = "lion"

}

Page 33: Service oriented programming with jolie part1

Creating a data structure

XML JSON