com.languagecomputer.api
Class BaseWebClient<T extends BaseWebService>

java.lang.Object
  extended by com.languagecomputer.api.BaseWebClient<T>
All Implemented Interfaces:
Service
Direct Known Subclasses:
AnnotationMetaServiceWebClient, AnswerExtractionServiceWebClient, AnswerFusionServiceWebClient, AttributeServiceWebClient, CoreferenceServiceWebClient, DocumentRetrievalServiceWebClient, DocumentServiceWebClient, EntityServiceWebClient, EventServiceWebClient, IndexServiceWebClient, QuestionAnsweringServiceWebClient, QuestionProcessingServiceWebClient, SpatialServiceWebClient, TemporalServiceWebClient

public abstract class BaseWebClient<T extends BaseWebService>
extends Object
implements Service

Base web client wrapper for the services. Handles the register/unregister functionality.

Since:
1.0
Author:
Kirk Roberts

Constructor Summary
BaseWebClient(ServiceConfig serviceConfig)
          Creates a new BaseWebClient with the ServiceConfig.
 
Method Summary
protected  void disconnect()
          "Disconnects" the current remote web service, only needs to be called when switching servers.
abstract  String getName()
          Returns the name of the service to use for URL lookup.
 String getSessionID()
          Returns the current session identifier, or null if there currently is no session.
protected  T getWebService()
          Returns the BaseWebService to use for this BaseWebClient.
protected abstract
<T extends BaseWebService>
Class<T>
getWebServiceClass()
          Returns the BaseWebService class this BaseWebClient wraps.
 String registerSession()
          Registers a new session with the remote service.
 boolean sessionRegistered()
          Convenience method for determining if there is currently a registered session.
 void setSession(Session session)
          Ignored: since this is a web client, this method should never be called.
 void setSessionID(String sessionID)
          Sets the session identifier to use for this BaseWebClient.
 void unregisterSession()
          Unregisters the current session with the remote service.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BaseWebClient

public BaseWebClient(ServiceConfig serviceConfig)
Creates a new BaseWebClient with the ServiceConfig.

Method Detail

setSession

public void setSession(Session session)
Ignored: since this is a web client, this method should never be called. BaseWebClients are created directly, not by the Session object.

Specified by:
setSession in interface Service

getName

public abstract String getName()
Returns the name of the service to use for URL lookup.

Specified by:
getName in interface Service

getWebServiceClass

protected abstract <T extends BaseWebService> Class<T> getWebServiceClass()
Returns the BaseWebService class this BaseWebClient wraps.


setSessionID

public void setSessionID(String sessionID)
Sets the session identifier to use for this BaseWebClient.


getSessionID

public String getSessionID()
Returns the current session identifier, or null if there currently is no session.

Throws:
IllegalStateException - If the BaseWebClient has not registered a session yet.

sessionRegistered

public boolean sessionRegistered()
Convenience method for determining if there is currently a registered session.

See Also:
registerSession()

getWebService

protected T getWebService()
                                          throws Exception
Returns the BaseWebService to use for this BaseWebClient. Loads the proper web service location and timeouts.

Throws:
Exception

disconnect

protected void disconnect()
"Disconnects" the current remote web service, only needs to be called when switching servers. The web service reconnects/disconnects with every call, so this method exists just to remove the current web service pointer, so that on the next call to getWebService() a new server can be connected to (specified through the ServiceConfig).


registerSession

public String registerSession()
                       throws Exception
Registers a new session with the remote service.

Throws:
Exception
See Also:
getSessionID()

unregisterSession

public void unregisterSession()
                       throws Exception
Unregisters the current session with the remote service.

Throws:
Exception


Copyright © 2009. All Rights Reserved.