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
-
Session(String, int)
- Create a session and connect.
-
addResponseListener(ResponseListener)
- Adds a ResponseListener.
-
connect()
- Connect to Gazebo and send a Meta request.
-
disconnect()
- Disconnect from Gazebo.
-
getDBNames()
- Get list of data source names from Gazebo.
-
getMergedAttributes()
- The application should use this to get metadata about
the data sources supported by the Gazebo service.
-
present(Present)
- Send a present request to Gazebo.
-
responseReceived(ResponseEvent)
- Handle an incoming response from Gazebo.
-
search(Query)
- Send a query to Gazebo.
-
search(Query, Vector)
- Send a query to Gazebo.
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
addResponseListener
public void addResponseListener(ResponseListener rl)
- Adds a ResponseListener.
Delegates this to the client, which further delegates it.
- Parameters:
- rl - the ResponseListener to add
connect
protected synchronized void connect()
- Connect to Gazebo and send a Meta request.
- See Also:
- MetaRequest
disconnect
public synchronized void disconnect()
- Disconnect from Gazebo.
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
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
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
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
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
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