All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class ncsa.gazebo.ctk.Session

java.lang.Object
   |
   +----ncsa.gazebo.ctk.ResultSetGenerator
           |
           +----ncsa.gazebo.ctk.Session

public class Session
extends ResultSetGenerator
implements ResponseListener
Session represents an interaction with Gazebo, from connecting, retrieving metadata, searching, to delivering results.

Typical Usage:

Create a Session whenever you want to search a Gazebo instance or get metadata about the data sources it supports. This is in essence the main "entry point" to the CTK. After creating the Session, register ResponseListener and ResultSetListeners with it using addResponseListener and addResultSetListener. Execute a search request by passing a Query to search. Retrieve results from ResultSets which the Session will delivered to the ResultSetListeners. When you're done, call disconnect.

Life Cycle:

Created by the application each time a new query needs to be executed. Destroyed by the application when that query is no longer needed.

See Also:
Client, ResultSet, MetaResponse, Query, ResultSet, ResultSetListener, Response, ResponseListener

Constructor Index

 o Session(String, int)
Create a session and connect.

Method Index

 o addResponseListener(ResponseListener)
Adds a ResponseListener.
 o connect()
Connect to Gazebo and send a Meta request.
 o disconnect()
Disconnect from Gazebo.
 o getDBNames()
Get list of data source names from Gazebo.
 o getMergedAttributes()
The application should use this to get metadata about the data sources supported by the Gazebo service.
 o present(Present)
Send a present request to Gazebo.
 o responseReceived(ResponseEvent)
Handle an incoming response from Gazebo.
 o search(Query)
Send a query to Gazebo.
 o search(Query, Vector)
Send a query to Gazebo.

Constructors

 o Session
 public Session(String host,
                int port) throws CTKException
Create a session and connect.

Parameters:
host - the host of the Gazebo server
port - the port of the Gazebo server

Methods

 o addResponseListener
 public void addResponseListener(ResponseListener rl)
Adds a ResponseListener. Delegates this to the client, which further delegates it.

Parameters:
rl - the ResponseListener to add
 o connect
 protected synchronized void connect()
Connect to Gazebo and send a Meta request.

See Also:
MetaRequest
 o disconnect
 public synchronized void disconnect()
Disconnect from Gazebo.

 o search
 public synchronized boolean search(Query q)
Send a query to Gazebo.

Parameters:
q - the Query to send
Returns:
true if the query was successfully sent
 o search
 public synchronized boolean search(Query q,
                                    Vector dbNames)
Send a query to Gazebo.

Parameters:
q - the Query to send
dbNames - the names of the DBs to search
Returns:
true if the query was successfully sent
 o present
 public synchronized boolean present(Present p)
Send a present request to Gazebo. Note: the application should never call this; instead, call ResultSet.fetchBrief/Full.

Parameters:
p - the Present request
Returns:
true if the present request was sent successfully
See Also:
ResultSet
 o responseReceived
 public void responseReceived(ResponseEvent re)
Handle an incoming response from Gazebo. This is called because Session acts as Client's ResponseListener, and should not be called by the application.

Parameters:
re - the ResponseEvent
 o getMergedAttributes
 public synchronized AttributeContainer getMergedAttributes()
The application should use this to get metadata about the data sources supported by the Gazebo service. It can be called anytime after the Session is created, but will not return until Gazebo has returned a MetaResponse. It will time out after 20 seconds, if no MetaResponse is received.

Returns:
the merged attributes of the DBs Gazebo can search, null on timeout
See Also:
AttributeContainer
 o getDBNames
 public synchronized Vector getDBNames()
Get list of data source names from Gazebo. Waits if MetaResponse has not come in yet; times out after 20 seconds.

Returns:
list of DB names, null on timeout
See Also:
MetaResponse

All Packages  Class Hierarchy  This Package  Previous  Next  Index