building distributed applications with jolie and qt · based on a formal theoretical framework. it...
TRANSCRIPT
![Page 1: Building distributed applications with JOLIE and Qt · Based on a formal theoretical framework. It offers new constructs and primitives, focusing on the problems of distributed programming](https://reader036.vdocuments.net/reader036/viewer/2022081404/5f0673337e708231d4180df2/html5/thumbnails/1.jpg)
Introduction JOLIE QtJolie Example
Building distributed applications withJOLIE and Qt
How to help your applications enter theservice-oriented world
Fabrizio Montesi, Kévin Ottens
Akademy 2009 – July 6th
Fabrizio Montesi, Kévin Ottens – Building distributed applications with JOLIE and Qt – 1/25
![Page 2: Building distributed applications with JOLIE and Qt · Based on a formal theoretical framework. It offers new constructs and primitives, focusing on the problems of distributed programming](https://reader036.vdocuments.net/reader036/viewer/2022081404/5f0673337e708231d4180df2/html5/thumbnails/2.jpg)
Introduction JOLIE QtJolie Example
Outline
1 Introduction
2 JOLIE
3 QtJolie
4 Example
Fabrizio Montesi, Kévin Ottens – Building distributed applications with JOLIE and Qt – 2/25
![Page 3: Building distributed applications with JOLIE and Qt · Based on a formal theoretical framework. It offers new constructs and primitives, focusing on the problems of distributed programming](https://reader036.vdocuments.net/reader036/viewer/2022081404/5f0673337e708231d4180df2/html5/thumbnails/3.jpg)
Introduction JOLIE QtJolie Example
Outline
1 Introduction
2 JOLIE
3 QtJolie
4 Example
Fabrizio Montesi, Kévin Ottens – Building distributed applications with JOLIE and Qt – 3/25
![Page 4: Building distributed applications with JOLIE and Qt · Based on a formal theoretical framework. It offers new constructs and primitives, focusing on the problems of distributed programming](https://reader036.vdocuments.net/reader036/viewer/2022081404/5f0673337e708231d4180df2/html5/thumbnails/4.jpg)
Introduction JOLIE QtJolie Example
A distributed world
Networking technologies have introduced new waysfor users to share, store and access data.
User data is now stored in multiple points, each onepossibly implemented in a different way.
We want to enable users to coordinate theirdistributed data.
How do we make UIs interacting with this distributedworld?
Fabrizio Montesi, Kévin Ottens – Building distributed applications with JOLIE and Qt – 4/25
![Page 5: Building distributed applications with JOLIE and Qt · Based on a formal theoretical framework. It offers new constructs and primitives, focusing on the problems of distributed programming](https://reader036.vdocuments.net/reader036/viewer/2022081404/5f0673337e708231d4180df2/html5/thumbnails/5.jpg)
Introduction JOLIE QtJolie Example
The objectives
Reuse existing tools and languages in their ownspecific area.
Provide developers with the means for coordinatingdistributed applications easily.
Connect UIs to these technologies.
Pay attention to performance and scalability.
Fabrizio Montesi, Kévin Ottens – Building distributed applications with JOLIE and Qt – 5/25
![Page 6: Building distributed applications with JOLIE and Qt · Based on a formal theoretical framework. It offers new constructs and primitives, focusing on the problems of distributed programming](https://reader036.vdocuments.net/reader036/viewer/2022081404/5f0673337e708231d4180df2/html5/thumbnails/6.jpg)
Introduction JOLIE QtJolie Example
How we do it
We make use of a service-oriented language (JOLIE)to handle distributed programming.
We build a layer between C++/Qt and JOLIE so theycan interoperate.
Distributed programming and UI programmingremain separated.
Fabrizio Montesi, Kévin Ottens – Building distributed applications with JOLIE and Qt – 6/25
![Page 7: Building distributed applications with JOLIE and Qt · Based on a formal theoretical framework. It offers new constructs and primitives, focusing on the problems of distributed programming](https://reader036.vdocuments.net/reader036/viewer/2022081404/5f0673337e708231d4180df2/html5/thumbnails/7.jpg)
Introduction JOLIE QtJolie Example
Service-Oriented Computing (SOC)
An emerging paradigm for programming distributedapplications.
Generalizes the concepts of service.
Offers a model for handling the complexity ofservice systems.
Web Services and D-Bus are examples ofservice-oriented technologies.
Fabrizio Montesi, Kévin Ottens – Building distributed applications with JOLIE and Qt – 7/25
![Page 8: Building distributed applications with JOLIE and Qt · Based on a formal theoretical framework. It offers new constructs and primitives, focusing on the problems of distributed programming](https://reader036.vdocuments.net/reader036/viewer/2022081404/5f0673337e708231d4180df2/html5/thumbnails/8.jpg)
Introduction JOLIE QtJolie Example
What’s a service?
An application exposing functionalities to otherapplications.
It communicates through language-independentprotocols.
Offers a description of itself to the other partners.
Fabrizio Montesi, Kévin Ottens – Building distributed applications with JOLIE and Qt – 8/25
![Page 9: Building distributed applications with JOLIE and Qt · Based on a formal theoretical framework. It offers new constructs and primitives, focusing on the problems of distributed programming](https://reader036.vdocuments.net/reader036/viewer/2022081404/5f0673337e708231d4180df2/html5/thumbnails/9.jpg)
Introduction JOLIE QtJolie Example
Service composition and orchestration
A service can exploit the functionalities of existingones, by composing them.
Such composite services are called "orchestrators".
An orchestrator coordinates other services from itssingle point of view.
Writing orchestrators can be a difficult task: weneed new appropriate languages and primitives.
Fabrizio Montesi, Kévin Ottens – Building distributed applications with JOLIE and Qt – 9/25
![Page 10: Building distributed applications with JOLIE and Qt · Based on a formal theoretical framework. It offers new constructs and primitives, focusing on the problems of distributed programming](https://reader036.vdocuments.net/reader036/viewer/2022081404/5f0673337e708231d4180df2/html5/thumbnails/10.jpg)
Introduction JOLIE QtJolie Example
Outline
1 Introduction
2 JOLIE
3 QtJolie
4 Example
Fabrizio Montesi, Kévin Ottens – Building distributed applications with JOLIE and Qt – 10/25
![Page 11: Building distributed applications with JOLIE and Qt · Based on a formal theoretical framework. It offers new constructs and primitives, focusing on the problems of distributed programming](https://reader036.vdocuments.net/reader036/viewer/2022081404/5f0673337e708231d4180df2/html5/thumbnails/11.jpg)
Introduction JOLIE QtJolie Example
JOLIE
JOLIE is a new service-oriented language.
Lightweight and cross-platform.
Based on a formal theoretical framework.
It offers new constructs and primitives, focusing onthe problems of distributed programming.
It supports pluggable communication protocols andmediums, without requiring you to change yourprograms.
Fabrizio Montesi, Kévin Ottens – Building distributed applications with JOLIE and Qt – 11/25
![Page 12: Building distributed applications with JOLIE and Qt · Based on a formal theoretical framework. It offers new constructs and primitives, focusing on the problems of distributed programming](https://reader036.vdocuments.net/reader036/viewer/2022081404/5f0673337e708231d4180df2/html5/thumbnails/12.jpg)
Introduction JOLIE QtJolie Example
Some native features in JOLIE
Native primitives for performing communications.
Parallel execution of activities, through the |operator.
External choice: the orchestrator offers multiplepossibilities (like in a switch) and thecommunicating partner chooses one by sending amessage notifying the choice.
Dynamic fault handling, adaptive w.r.t. theexecution flow.
Fabrizio Montesi, Kévin Ottens – Building distributed applications with JOLIE and Qt – 12/25
![Page 13: Building distributed applications with JOLIE and Qt · Based on a formal theoretical framework. It offers new constructs and primitives, focusing on the problems of distributed programming](https://reader036.vdocuments.net/reader036/viewer/2022081404/5f0673337e708231d4180df2/html5/thumbnails/13.jpg)
Introduction JOLIE QtJolie Example
MetaService
A registry of services, it acts as a service router.
It allows you to access services without knowingtheir location, or even the protocol they speak.
Routes your messages to the registered service,converting the data to the appropriate protocol.
Can load embedded services on demand.
Fabrizio Montesi, Kévin Ottens – Building distributed applications with JOLIE and Qt – 13/25
![Page 14: Building distributed applications with JOLIE and Qt · Based on a formal theoretical framework. It offers new constructs and primitives, focusing on the problems of distributed programming](https://reader036.vdocuments.net/reader036/viewer/2022081404/5f0673337e708231d4180df2/html5/thumbnails/14.jpg)
Introduction JOLIE QtJolie Example
Outline
1 Introduction
2 JOLIE
3 QtJolie
4 Example
Fabrizio Montesi, Kévin Ottens – Building distributed applications with JOLIE and Qt – 14/25
![Page 15: Building distributed applications with JOLIE and Qt · Based on a formal theoretical framework. It offers new constructs and primitives, focusing on the problems of distributed programming](https://reader036.vdocuments.net/reader036/viewer/2022081404/5f0673337e708231d4180df2/html5/thumbnails/15.jpg)
Introduction JOLIE QtJolie Example
Qt + JOLIE→ QtJolieExposing C++ applications to the service world since 2009
Goals
Allow Qt applications to drive a JOLIE instance
Make it easy to talk to a (Web) Service
Mid-term, benefit from JOLIE abilities to mix servicesand protocols
Provide a Qt-ish API, similar to QtDBus when itmakes sense
Architecture
Application QtJolie JOLIE
MetaService
Uses SODEP
Uses Instanciates
Fabrizio Montesi, Kévin Ottens – Building distributed applications with JOLIE and Qt – 15/25
![Page 16: Building distributed applications with JOLIE and Qt · Based on a formal theoretical framework. It offers new constructs and primitives, focusing on the problems of distributed programming](https://reader036.vdocuments.net/reader036/viewer/2022081404/5f0673337e708231d4180df2/html5/thumbnails/16.jpg)
Introduction JOLIE QtJolie Example
API overview
[WARNING]Work in progress.
Convenience missing.
Fabrizio Montesi, Kévin Ottens – Building distributed applications with JOLIE and Qt – 16/25
![Page 17: Building distributed applications with JOLIE and Qt · Based on a formal theoretical framework. It offers new constructs and primitives, focusing on the problems of distributed programming](https://reader036.vdocuments.net/reader036/viewer/2022081404/5f0673337e708231d4180df2/html5/thumbnails/17.jpg)
Introduction JOLIE QtJolie Example
API overviewMost important facts
We’re using the Jolie namespace
You can create a Client or a ServerThe API allows to manage Messages
Messages have data which is a Value instance
Values form a tree of key/list pairs and can be int,double or byte array
In case of problems Fault instances shall be issued
By inheriting AbstractAdaptor you can processincoming calls
Fabrizio Montesi, Kévin Ottens – Building distributed applications with JOLIE and Qt – 17/25
![Page 18: Building distributed applications with JOLIE and Qt · Based on a formal theoretical framework. It offers new constructs and primitives, focusing on the problems of distributed programming](https://reader036.vdocuments.net/reader036/viewer/2022081404/5f0673337e708231d4180df2/html5/thumbnails/18.jpg)
Introduction JOLIE QtJolie Example
Making callsLet’s use Jolie::Client
using namespace Jolie;
Client *client = new Client("localhost", 9000);
Message message("/Printer", "printInput");message.setData(Value("Patapatapon!"));
Message reply = client->call(message);
Q_ASSERT(reply.toByteArray()=="success");
Fabrizio Montesi, Kévin Ottens – Building distributed applications with JOLIE and Qt – 18/25
![Page 19: Building distributed applications with JOLIE and Qt · Based on a formal theoretical framework. It offers new constructs and primitives, focusing on the problems of distributed programming](https://reader036.vdocuments.net/reader036/viewer/2022081404/5f0673337e708231d4180df2/html5/thumbnails/19.jpg)
Introduction JOLIE QtJolie Example
Receiving calls (1/3)Let’s use Jolie::Server and Jolie::AbstractAdaptor
using namespace Jolie;
class CalculatorAdaptor : public AbstractAdaptor{
Q_OBJECTpublic:
CalculatorAdaptor(QObject *parent = 0): AbstractAdaptor(parent) { }
private://==>
Fabrizio Montesi, Kévin Ottens – Building distributed applications with JOLIE and Qt – 19/25
![Page 20: Building distributed applications with JOLIE and Qt · Based on a formal theoretical framework. It offers new constructs and primitives, focusing on the problems of distributed programming](https://reader036.vdocuments.net/reader036/viewer/2022081404/5f0673337e708231d4180df2/html5/thumbnails/20.jpg)
Introduction JOLIE QtJolie Example
Receiving calls (2/3)Let’s use Jolie::Server and Jolie::AbstractAdaptor
//<==Message relay(Server *server,
const Message &message){
Value data = message.data();qint32 x = data.children("x").first().toInt();qint32 y = data.children("y").first().toInt();
Message reply(message.resourcePath(),message.operationName(),message.id());
reply.setData(Value(x+y));return reply;
}};
[...]Server *server = new Server(8000);CalculatorAdaptor *adaptor = new CalculatorAdaptor(this);server->registerAdaptor("/", adaptor);
Fabrizio Montesi, Kévin Ottens – Building distributed applications with JOLIE and Qt – 20/25
![Page 21: Building distributed applications with JOLIE and Qt · Based on a formal theoretical framework. It offers new constructs and primitives, focusing on the problems of distributed programming](https://reader036.vdocuments.net/reader036/viewer/2022081404/5f0673337e708231d4180df2/html5/thumbnails/21.jpg)
Introduction JOLIE QtJolie Example
Receiving calls (3/3)Let’s use Jolie::Server and Jolie::AbstractAdaptor
using namespace Jolie;
Server *server = new Server(8000);CalculatorAdaptor *adaptor
= new CalculatorAdaptor(this);
server->registerAdaptor("/", adaptor);
Fabrizio Montesi, Kévin Ottens – Building distributed applications with JOLIE and Qt – 21/25
![Page 22: Building distributed applications with JOLIE and Qt · Based on a formal theoretical framework. It offers new constructs and primitives, focusing on the problems of distributed programming](https://reader036.vdocuments.net/reader036/viewer/2022081404/5f0673337e708231d4180df2/html5/thumbnails/22.jpg)
Introduction JOLIE QtJolie Example
Managing servicesLet’s use Jolie::MetaService
MetaService management
start()/stop()loadService("Math", "math.ol")unloadService("MathService")listServices()
Redirections
addRedirection("Calculator","socket://localhost:8000",Value("sodep"),Value("soap"));
Fabrizio Montesi, Kévin Ottens – Building distributed applications with JOLIE and Qt – 22/25
![Page 23: Building distributed applications with JOLIE and Qt · Based on a formal theoretical framework. It offers new constructs and primitives, focusing on the problems of distributed programming](https://reader036.vdocuments.net/reader036/viewer/2022081404/5f0673337e708231d4180df2/html5/thumbnails/23.jpg)
Introduction JOLIE QtJolie Example
Outline
1 Introduction
2 JOLIE
3 QtJolie
4 Example
Fabrizio Montesi, Kévin Ottens – Building distributed applications with JOLIE and Qt – 23/25
![Page 24: Building distributed applications with JOLIE and Qt · Based on a formal theoretical framework. It offers new constructs and primitives, focusing on the problems of distributed programming](https://reader036.vdocuments.net/reader036/viewer/2022081404/5f0673337e708231d4180df2/html5/thumbnails/24.jpg)
Introduction JOLIE QtJolie Example
Yahoo! Search clientQuick and dirty... but with nice tricks
Quick demo...
Show me the code!
Fabrizio Montesi, Kévin Ottens – Building distributed applications with JOLIE and Qt – 24/25
![Page 25: Building distributed applications with JOLIE and Qt · Based on a formal theoretical framework. It offers new constructs and primitives, focusing on the problems of distributed programming](https://reader036.vdocuments.net/reader036/viewer/2022081404/5f0673337e708231d4180df2/html5/thumbnails/25.jpg)
Introduction JOLIE QtJolie Example
Questions ?
Fabrizio [email protected]
Kévin [email protected]
Fabrizio Montesi, Kévin Ottens – Building distributed applications with JOLIE and Qt – 25/25