ecologylab.services.distributed.legacy
Class ServicesClient

java.lang.Object
  extended by ecologylab.generic.Debug
      extended by ecologylab.services.distributed.legacy.ServicesClientBase
          extended by ecologylab.services.distributed.legacy.ServicesClient
All Implemented Interfaces:
ClientConstants, NetworkingConstants, ServerConstants

public class ServicesClient
extends ServicesClientBase
implements ServerConstants

Interface Ecology Lab Distributed Computing Services framework

Client to connect to ServicesServer.

Author:
blake, andruid

Field Summary
 
Fields inherited from class ecologylab.services.distributed.legacy.ServicesClientBase
objectRegistry, port, server, socket, translationSpace
 
Fields inherited from interface ecologylab.services.distributed.common.ServerConstants
GARBAGE_CONNECTION_CLEANUP_TIMEOUT, MAX_CONNECTIONS, MAXIMUM_TRANSMISSION_ERRORS
 
Fields inherited from interface ecologylab.services.distributed.common.NetworkingConstants
CHARACTER_ENCODING, CONTENT_LENGTH_STRING, CONTENT_LENGTH_STRING_LENGTH, DECODER, ENCODER, HTTP_HEADER_LINE_DELIMITER, HTTP_HEADER_TERMINATOR, MAX_HTTP_HEADER_LENGTH, MAX_PACKET_SIZE_BYTES, MAX_PACKET_SIZE_CHARACTERS, UNIQUE_IDENTIFIER_STRING
 
Fields inherited from interface ecologylab.services.distributed.common.ClientConstants
RECONNECT_ATTEMPTS, WAIT_BEWTEEN_RECONNECT_ATTEMPTS
 
Constructor Summary
ServicesClient(int port)
          Create a client that will connect on the provided port.
ServicesClient(int port, TranslationSpace messageSpace)
           
ServicesClient(java.lang.String server, int port)
           
ServicesClient(java.lang.String server, int port, TranslationSpace messageSpace)
           
ServicesClient(java.lang.String server, int port, TranslationSpace messageSpace, Scope objectRegistry)
           
 
Method Summary
 boolean connected()
          Determine if we are connected.
protected  boolean createConnection()
           
 void disconnect()
          Disconnect from the server (if connected).
 ResponseMessage sendMessage(RequestMessage requestMessage)
          Send a message to the ServicesServer to get a service performed,
 java.lang.String toString()
           
 
Methods inherited from class ecologylab.services.distributed.legacy.ServicesClientBase
connect, generateUid, getServer, getUidNoIncrement, isServerRunning, processResponse, setServer, translateXMLStringToResponseMessage, translateXMLStringToResponseMessage, waitForConnect
 
Methods inherited from class ecologylab.generic.Debug
classSimpleName, closeLoggingFile, debug, debug, debug, debug, debugA, debugA, debugA, debugI, debugI, debugI, error, error, getClassName, getClassName, getInteractive, getPackageName, getPackageName, getPackageName, initialize, level, level, level, logToFile, print, print, println, println, println, println, println, println, printlnA, printlnA, printlnA, printlnI, printlnI, printlnI, printlnI, setLoggingFile, show, show, superString, toggleInteractive, toString, warning, warning, weird, weird
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ServicesClient

public ServicesClient(int port)
Create a client that will connect on the provided port. Assume localhost

Parameters:
port - The localhost port to connect.

ServicesClient

public ServicesClient(int port,
                      TranslationSpace messageSpace)

ServicesClient

public ServicesClient(java.lang.String server,
                      int port)

ServicesClient

public ServicesClient(java.lang.String server,
                      int port,
                      TranslationSpace messageSpace)

ServicesClient

public ServicesClient(java.lang.String server,
                      int port,
                      TranslationSpace messageSpace,
                      Scope objectRegistry)
Method Detail

createConnection

protected boolean createConnection()
Specified by:
createConnection in class ServicesClientBase

toString

public java.lang.String toString()
Overrides:
toString in class Debug

connected

public boolean connected()
Determine if we are connected.

Specified by:
connected in class ServicesClientBase
Returns:
True if connected, false if not.

disconnect

public void disconnect()
Disconnect from the server (if connected).

Specified by:
disconnect in class ServicesClientBase

sendMessage

public ResponseMessage sendMessage(RequestMessage requestMessage)
Send a message to the ServicesServer to get a service performed,

Specified by:
sendMessage in class ServicesClientBase
Parameters:
requestMessage -
Returns:
The ResponseMessage from the server. This could be null, which means that communication with the server failed. Reasons for failure include:
  • 1) IOException: the socket connection broke somehow.
  • 2) XmlTranslationException: The message was malformed or translation failed strangely.
  • 3) The server closed its output stream (occurs whenever a StopMessage is sent).