Ports

In Jolie there are two kinds of ports:

  • input ports: which expose input operations to other services;
  • output ports: which define how to invoke the operations of other services.

Within each port, both input and output, it is possible to define three elements:

  • location;
  • protocol;
  • interfaces.

The Location defines where the service is listening for a message (in the case of input ports) or where the message has to be sent (in the case of output ports). The Protocol defines how Jolie will send or receive a message. It could defines both the transportation protocol (e.g. http) and the message format (e.g. json). Finally, Interfaces specify the list of the available operations and the related message types information. In particular, in case of an input port, an interfaces specifies the operation exhibited by the current service, whereas in the case of an output port it defines the operations which can be invoked by that service.

Usually we graphically represent outputPorts with red triangles and inputPort with yellow squares. As an example, in the diagram below we represent a client connected to a server by means of an outputPort defined in the client and an inputPort defined in the server.

The syntax of input and output ports

The syntax for input and output ports is, respectively:

inputPort id {
    location: URI
    protocol: p
    interfaces: iface_1,
                ...,
                iface_n
}
outputPort id {
    location: URI
    protocol: p
    interfaces: iface_1,
                ...,
                iface_n
}

where URI is a URI (Uniform Resource Identifier), defining the location of the port; id, p and iface_i are the identifiers representing, respectively, the name of the port, the data protocol to use, and the interfaces accessible through the port.

Locations

A location expresses the communication medium and the address a service uses for exposing its interface (input port) or invoking another service (output port).

A location must indicate the communication medium the port has to use and its related parameters in this form: medium[:parameters] where medium is a medium identifier and the optional parameters is a medium-specific string. Usually the medium parameters define the address where the service is actually located.

Jolie currently supports four media:

  • local (Jolie in-memory communication);
  • socket (TCP/IP sockets).
  • btl2cap (Bluetooth L2CAP);
  • rmi (Java RMI);
  • localsocket (Unix local sockets);

An example of a valid location is: "socket://www.mysite.com:80/", where socket:// is the location medium and the following part represents the address.

For a thorough description of the locations supported by Jolie and their parameters see Locations section.

Protocols

A protocol defines how data to be sent or received should be, respectively, encoded or decoded, following an isomorphism.

Protocols are referred by name. Examples of valid (supported) protocol names are:

  • http
  • https
  • soap
  • sodep (a binary protocol specifically developed for Jolie)
  • xmlrpc
  • jsonrpc

For a thorough description of the protocols supported by Jolie and their parameters see Protocols section.

Let us consider the following input port declaration:

inputPort SumInput {
    Location: "socket://localhost:8000/"
    Protocol: soap
    Interfaces: SumInterface
}

SumInput is an inputPort, and it exposes the operations defined in SumInterface interface. Such operations can be invoked at the TCP/IP socket localhost, on port 8000, and by encoding messages with the soap protocol.

Finally, let us define the SumServ outputPort, which is used to invoke the services exposed by SumInput:

outputPort SumServ {
    location: "socket://localhost:8000/"
    protocol: soap
    interfaces: SumInterface
}

Multiple ports

More than one input and one output ports can be defined into a service thus, enabling a service to receive messages from different location and different protocols.

As an example, in the following piece of service, two input ports and three outputPorts are declared:

...

outputPort OutputPort1 {
    location: "socket://localhost:9000/"
    protocol: sodep
    interfaces: Interface1
}

outputPort OutputPort2 {
    location: "socket://localhost:9001/"
    protocol: sodep
    interfaces: Interface2
}

outputPort OutputPort3 {
    location: "socket://localhost:9002/"
    protocol: sodep
    interfaces: Interface3
}

inputPort InputPort1 {
    location: "socket://localhost:8000/"
    protocol: soap
    interfaces: MyInterface
}

inputPort InputPort2 {
    location: "socket://localhost:8001/"
    protocol: sodep
    interfaces: MyInterface
}

...