org.otfeed
Interface IConnection

All Known Implementing Classes:
OTEngine

public interface IConnection

Defines contract for the connection to the OpenTick service.

This is the central interface of the API. It allows one to prepare and submit a request for data.

Note that connection is asynchronous, which means that connection/login process might still be in progress by the time user gets object implementing this interface. But even if so, nothing prevents user from using it: submitted requests will be queued and sent as soon as connection is established.

Implementations must be thread-safe. All implementations provided by org.otfeed driver are thread-safe.


Method Summary
 IRequest prepareRequest(ICommand command)
          Prepares a request.
 void runInEventThread(java.lang.Runnable job)
          Schedules a job for execution in the event-dispatching thread.
 void shutdown()
          Closes connection to the server.
 void waitForCompletion()
          Blocks till connection terminates (on error, or as a result of calling shutdown() method).
 boolean waitForCompletion(long millis)
          Blocks for the earliest of (i) connection termination, or (ii) timeout expiration.
 

Method Detail

shutdown

void shutdown()
Closes connection to the server. All pending requests will receive onError message.


waitForCompletion

void waitForCompletion()
Blocks till connection terminates (on error, or as a result of calling shutdown() method).


waitForCompletion

boolean waitForCompletion(long millis)
Blocks for the earliest of (i) connection termination, or (ii) timeout expiration.

Parameters:
millis - for how long to block.
Returns:
true if connection has terminated, false if timeout has expired.

runInEventThread

void runInEventThread(java.lang.Runnable job)
Schedules a job for execution in the event-dispatching thread. All listener methods are called by event-dispatching thread. To avoid a need to make listener objects thread-safe, programmer can instead use this method when there is a need to interact with listener objects from a different thread. Note that these jobs will be executed in order they were sumbitted. Also, these jobs are considered a priority for the event thread.

Parameters:
job - a job to be submitted.

prepareRequest

IRequest prepareRequest(ICommand command)
Prepares a request. This is the main functionality of IConnection interface. It allowas caller to prepare a request to the OpenTick server.

Command parameter must be one of the known request commands, see org.otfeed.command package. See also: IRequest.

Parameters:
command - object describing request parameters.
Returns:
IRequest handle.


Copyright © 2007 Mike Kroutikov. All Rights Reserved.