public class Pathfinder extends Object
The Pathfinder class is the main entry point to the Pathfinder API. To create the Pathfinder class you need a valid application identifier provided from your Pathfinder service manager, we provide the ability to get an application identifier from thepathfinder.xyz. The connection also requires a JWT in the form of a String to authenticate the user. The URI to your pathfinder provider is also required to initiate the connection.
The default cluster is available via the getDefaultCluster() method. Any other cluster available to
the user may be obtained through the getCluster(String) method, where the path is of the form
"/default/clusterName/subclusterName/subsubclusterName".
Note, when connecting thePathfinder object the thread is blocked until the web socket to the
Pathfinder service is opened.
Pathfinder pathfinder = new Pathfinder("myAppId", "UserJWT");
pathfinder.connect();
Cluster cluster = pathfinder.getCluster("/default/cluster1/subcluster2");
MyClusterListener clusterListener = new MyClusterListener();
cluster.addListener(clusterListener);
cluster.connect();
// more code ...
pathfinder.close();| Modifier and Type | Field and Description |
|---|---|
protected static String |
CLUSTER
Cluster model name used in requests to the Pathfinder server.
|
protected static String |
COMMODITY
Commodity model name used in requests to the Pathfinder server.
|
private static Logger |
logger
Logs all messages
|
private PathfinderServices |
services
Keeps track of all the Pathfinder models and connection to the server.
|
protected static String |
TRANSPORT
Transport model name used in requests to the Pathfinder server.
|
private URI |
webSocketUrl
URL to the Pathfinder server being connected to.
|
| Modifier | Constructor and Description |
|---|---|
|
Pathfinder(String applicationIdentifier,
String userCredentials)
Constructs a Pathfinder object.
|
protected |
Pathfinder(String applicationIdentifier,
String userCredentials,
URI webSocketUrl)
Constructs a Pathfinder object.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the web socket connection to the Pathfinder server with a normal close condition.
|
void |
close(CloseReason reason)
Closes the web socket connection to the Pathfinder server, if it is still open, with the specified reason.
|
void |
connect()
Establishes a connection to the Pathfinder server, if the connection is not already open.
|
Cluster |
getCluster(String path)
Gets an unconnected cluster pointing to the path specified.
|
Commodity |
getCommodity(String path)
Gets an unconnected commodity pointing to the path specified.
|
Cluster |
getDefaultCluster()
Gets an unconnected cluster pointing to the default cluster for the application identifier provided.
|
protected long |
getReceivedMessageCount()
Returns the number of web socket messages received from the Pathfinder server.
|
protected long |
getSentMessageCount()
Returns the number of web socket messages sent to the Pathfinder server.
|
Transport |
getTransport(String path)
Gets an unconnected transport pointing to the path specified.
|
boolean |
isConnected()
Returns true if the web socket connection to the Pathfinder server is open.
|
protected static String CLUSTER
protected static String COMMODITY
protected static String TRANSPORT
private PathfinderServices services
private URI webSocketUrl
private static Logger logger
public Pathfinder(String applicationIdentifier, String userCredentials)
applicationIdentifier - application Identifier provided by a Pathfinder service provideruserCredentials - JWT of the user's credentialsprotected Pathfinder(String applicationIdentifier, String userCredentials, URI webSocketUrl)
applicationIdentifier - application Identifier provided by a Pathfinder service provideruserCredentials - JWT of the user's credentialswebSocketUrl - URL to the Pathfinder web socket service providerpublic void connect()
throws IOException
IOException - problem connecting the Pathfinder serverpublic Cluster getDefaultCluster()
public Cluster getCluster(String path)
path - to the clusterpublic Commodity getCommodity(String path)
path - to the commoditypublic Transport getTransport(String path)
path - to the transportpublic boolean isConnected()
protected long getSentMessageCount()
protected long getReceivedMessageCount()
public void close()
throws IOException
IOException - If there was error closing the connection.public void close(CloseReason reason) throws IOException
reason - The reason to close the connection.IOException - If there was error closing the connection.