com.betfair.games
Class ApiClient

java.lang.Object
  extended by org.apache.commons.httpclient.HttpClient
      extended by com.betfair.games.ApiAdapter
          extended by com.betfair.games.ApiClient
All Implemented Interfaces:
java.lang.Runnable

public class ApiClient
extends ApiAdapter
implements java.lang.Runnable

An ApiClient is a runnable client extending the ApiAdapter. The purpose of an ApiClient is to gather the common features of a runnable http client making calls to the API using ApiAdapter. The ApiClient has no functional methods and it's run() method is empty. This is a superclass intended to be inherited by functional client classes that communicates with the ApiAdapter.

Version:
1.0.1
Author:
M Larsson

Constructor Summary
ApiClient(ApiApplication app)
          Constructs an ApiClient and a Thread for its execution.
ApiClient(ApiApplication app, java.lang.String service)
          Constructs an ApiClient and a Thread for its execution.
 
Method Summary
 java.lang.String getBaseResourceUrl()
          Returns the base resource url.
 long getSleep()
          Returns the number of milliseconds this client is supposed to sleep between each request while watching an API channel.
 boolean isWatching()
          Returns the watch status of the client.
 void run()
          The run method is empty and should be overridden by any client sub-class.
 void setBaseResourceUrl(java.lang.String url)
          Set the base resource url for the API service this client is using.
 void setSleep(int sec)
          Set the number of seconds this client is supposed to sleep between each request while watching an API channel.
 void startWatching()
          The client should now start to watch a specified API channel.
 void stopWatching()
          If the client is in a loop watching an API channel it should stop and must not resume unless the start() method is called again for the Thread.
 void wake()
          If the client is in a loop listening to an API channel and currently sleeping it is woke up to start listen again immediately.
 
Methods inherited from class com.betfair.games.ApiAdapter
createAgentInstanceID, get, get, getParam, getVersion, post, putParam
 
Methods inherited from class org.apache.commons.httpclient.HttpClient
executeMethod, executeMethod, executeMethod, getHost, getHostConfiguration, getHttpConnectionManager, getParams, getPort, getState, isStrictMode, setConnectionTimeout, setHostConfiguration, setHttpConnectionFactoryTimeout, setHttpConnectionManager, setParams, setState, setStrictMode, setTimeout
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ApiClient

public ApiClient(ApiApplication app)
          throws ApiAdapterException
Constructs an ApiClient and a Thread for its execution.

Parameters:
app - a reference to the application
Throws:
ApiAdapterException - if it is thrown by the ApiAdapter

ApiClient

public ApiClient(ApiApplication app,
                 java.lang.String service)
          throws ApiAdapterException
Constructs an ApiClient and a Thread for its execution.

Parameters:
app - a reference to the application
service - the Api service this client is using
Throws:
ApiAdapterException - if it is thrown by the ApiAdapter
Method Detail

stopWatching

public void stopWatching()
If the client is in a loop watching an API channel it should stop and must not resume unless the start() method is called again for the Thread.


startWatching

public void startWatching()
The client should now start to watch a specified API channel.


isWatching

public boolean isWatching()
Returns the watch status of the client. True if it is currently supposed to watch an API channel or false if it is not currently supposed to be watching.

Returns:
activity status of the client

wake

public void wake()
If the client is in a loop listening to an API channel and currently sleeping it is woke up to start listen again immediately.


setSleep

public void setSleep(int sec)
Set the number of seconds this client is supposed to sleep between each request while watching an API channel.


getSleep

public long getSleep()
Returns the number of milliseconds this client is supposed to sleep between each request while watching an API channel.

Returns:
the number of milliseconds to sleep

getBaseResourceUrl

public java.lang.String getBaseResourceUrl()
Returns the base resource url. The API service this client is using.

Returns:
a url to the specified service from the API server

setBaseResourceUrl

public void setBaseResourceUrl(java.lang.String url)
Set the base resource url for the API service this client is using.

Parameters:
url - url to the specified service from the API server

run

public void run()
The run method is empty and should be overridden by any client sub-class.

Specified by:
run in interface java.lang.Runnable