1. Development Environment

To use ABS API you need to prepare an environment that supports Java features.

  1. Install a version of Java 8 from OpenJDK releases [Java8].

  2. If you develop on Eclipse, install a milestone version of next eclipse Luna [EclipseLuna].

  3. To support Java 8 syntax on eclipse Luna, you need to install a beta version of JDK8 support [EclipseLunaJava8].

2. Build from source

To use the API, you can either download the latest build [APILastBuild] or build it from source.

To build from source, assuming that Git is available, checkout the source:

git clone https://github.com/CrispOSS/abs-api

And then, make a build using Maven 3+:

mvn clean install

3. A first example

The first example demonstrates how to implement the “ping-pong” example using ABS API. Let IPing and IPong be interfaces that define the interfaces.

IPing and IPong interfaces
interface IPing {
	void ping();
}

interface IPong {
	String pong(String msg);
}

An implementation of either interface can turn into an actor given that it implements the interface abs.api.Actor:

Ping implementation as an actor
class Ping implements IPing, abs.api.Actor {
	public void ping() {
		// implementation details
	}
}

and the same goes for the other:

Pong implementation as an actor
class Pong implements IPong, abs.api.Actor {
	public String pong(String msg) {
		// implementation details
	}
}

In a context that an instance of Ping can be created using an instance of Pong, then the ping actor can send a message to pong an wait for the result:

Send a message to an actor and wait for the result
// somewhere inside `ping` method of Ping
Future<String> result = invoke(pong, "pong", pingMessage);
// continues to use
String pongMessage = result.get();

The above message is a direct request to call a specific method of interface IPing with the provided arguments. A message can also be an executable object:

Send a message using a lambda expression
Future<String> result = send(pong, () -> {
	return pingMessage;
});
String pongMessage = result.get();

An actor may refer to the sender of a message that it has received during an invocation of one of its methods:

The notion of the sender of a message
// inside a method
send(sender(), aNewMessage);