Installation and Download

The CO2 middleware exposes a REST API you can use to advertise new contracts, create sessions and interact with other participants whose contracts are compliant with yours.

Java API

Download the latest version of the CO2 middleware Java API at http://co2.unica.it/downloads/co2api/.

Groovysh

The easiest way to try out the Java API is through a REPL (read-eval-print loop). Waiting the cooming soon release of Java 9, which will include JShell, we suggest the REPL provided by the Groovy language.

Install Groovy by following the instructions here or searching for the groovy package in your linux distro.

Open a new terminal and start groovish, then type "hello world"

"hello world"
===> hello world

In order to make the API available in the REPL, you have to save them within $HOME/.groovy/lib/. Then create the file $HOME/.groovy/groovysh.rc and add the following line

import co2api.*

Restart groovysh and try to use the APIs:

usr = "testuser1@gmail.com"
===> testuser1@gmail.com

pwd = "testuser1"
===> testuser1

co2 = new CO2ServerConnection(usr,pwd)
===> co2api.CO2ServerConnection

co2.serverTime
===> 1485427940351