Current articles

Jolie programming language

When Jolie

Jolie is protocol agnostic programming langusge. Bridging two networks using different protocols means often the wrinting of a huge lines of code! A starting use case it could be an'api rest that must communicate with another using SOAP.

Hello world

Once defined all enviromnent variables it is possible to create the classic hello world with these few lines of code.

include "console.iol"

main {
          println@Console("foo")()
}
      

to execute a jolie script it is necessary to run the command jolie filename.ol

Client Server

In the second example, I'll show you how to create a little server and its little client. During this exercize I'll show you how to implement a service that returns the double of a number.

Files

We will need three files here:

  • An interface
  • A client
  • A server

Interface

The interface defines the way a service must communicate. In this case the way is RequestResponse.

interface raddoppiaInterface {
    RequestResponse: twice( int )( int )
}
      

Server

As you can see here we are not defining a domain to listen. We are just building a server that will listen twice method calls.

include "raddoppiaInterface.iol"
include "console.iol"

inputPort raddoppiaService {
    Location: "socket://localhost:8000"
    Protocol: sodep
    Interfaces: raddoppiaInterface
}

execution{concurrent}

main {
    twice(number)(result) {
        result = number * 2;
        println@Console("served")()
    }
}
      

Client

And finally a client. This client will send to the interface raddoppiaService, via method twice the number 6. Because of is a RequestResponse, the response will be returned into response variable.

Finally, the response value is sento to Console service, throw the method println.

include "console.iol"
include "raddoppiaInterface.iol"

outputPort raddoppiaService {
    Location: "socket://localhost:8000"
    Protocol: sodep
    Interfaces: raddoppiaInterface
}

main
{
    twice@raddoppiaService( 6 )( response );
    println@Console( response )()
}
      

Conclusions

Jolie programming language is interpreted. The engine is written in Java. It allow to manage protocol agnostic communications. This means the ieal use case of the language is a boudle of web services that needs to communicate each others.

It allow to write few lines of code to get a great power handly. The API allow huge amount of utilities.

Comments