APIClient

public final class APIClient

This class permits users to access the API methods.

Note that whilst APIClient is threadsafe, other API objects are not unless they explicitly state otherwise.

Fields

AUTHENTICATION_HEADER_KEY

static final Metadata.Key<String> AUTHENTICATION_HEADER_KEY

Constructors

APIClient

public APIClient()

Methods

addListener

public synchronized void addListener(ServerStatusListener listener)

finalize

public void finalize()

getChannel

public Channel getChannel()

Internal API

getObject

public synchronized Object getObject(long id)

Internal API

getOrCreateObject

public synchronized <T> T getOrCreateObject(long id, BiFunction<APIClient, Long, T> creator)

Internal API

markObjectAsDestroyed

public synchronized void markObjectAsDestroyed(long id)

Internal API

recordNewObject

public synchronized void recordNewObject(long id, Object value)

Internal API

removeListener

public synchronized void removeListener(ServerStatusListener listener)

setClientIdentifer

public synchronized void setClientIdentifer(String client)

startServer

public void startServer(String serverPath)

Starts the server process on the given path. This must be called before creating any instances of APIClient.

Parameters:
  • serverPath – an absolute path to the coco-platform-server executable. This will be passed directly to the the constructor of ProcessBuilder.
Throws:
  • IOException – if any error is encountered whilst trying to start the server.

startServer

public void startServer(String serverPath, String licensesPath)

startServer

public void startServer(String serverPath, String licensesPath, boolean allowLicenseServer)

Starts the server process on the given path. This must be called before creating any instances of APIClient.

Parameters:
  • serverPath – an absolute path to the coco-platform-server executable. This will be passed directly to the the constructor of ProcessBuilder.
  • licensesPath – an absolute path to where the coco license can be found, if they are stored in a non-standard location. This is equivalent to the –override-licenses option to coco.
Throws:
  • IOException – if any error is encountered whilst trying to start the server.

stopServer

public void stopServer()

Shuts down the server cleanly