com.languagecomputer.api
Class SessionManager

java.lang.Object
  extended by com.languagecomputer.api.SessionManager

public final class SessionManager
extends Object

Session manager for accessing and creating Sessions that may be used to interact with LCC's natural language services.

Since:
1.0
Author:
Kirk Roberts

Constructor Summary
SessionManager(File configFile)
          Creates a new SessionManager with the given configFile.
 
Method Summary
 Session createNewSession()
          Factory method to create a new Session.
 File getConfigFile()
          Returns the configuration File that contains the options for the Services.
 Session getSession(String sessionID)
          Returns an existing Session, or creates a new one with the given sessionID.
 boolean initService(Class<?> service, Properties properties)
          Initializes the given service.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SessionManager

public SessionManager(File configFile)
Creates a new SessionManager with the given configFile.

Parameters:
configFile - The File that contains the configuration options of which Service classes to use.
Throws:
IllegalArgumentException - If the configFile is null.
Method Detail

getConfigFile

public File getConfigFile()
Returns the configuration File that contains the options for the Services.


createNewSession

public Session createNewSession()
                         throws IOException
Factory method to create a new Session.

Returns:
The new Session.
Throws:
IOException - If there was a problem with the configFile given to the constructor.

getSession

public Session getSession(String sessionID)
                   throws IOException
Returns an existing Session, or creates a new one with the given sessionID.

Parameters:
sessionID - The ID of the desired Session.
Returns:
The Session with the given sessionID.
Throws:
IOException - If there was a problem with the configFile given to the constructor.
IllegalArgumentException - If the sessionID is null.

initService

public boolean initService(Class<?> service,
                           Properties properties)
                    throws Exception
Initializes the given service. Calls the class's initService(Properties) method if it has not yet been called by this SessionManager with the given Properties.

Returns:
true if the initService method was called, or false if the optional method was not implemented.
Throws:
Exception - If the service throws an exception while initializing.


Copyright © 2009. All Rights Reserved.