org.jvoicexml.interpreter
Class JVoiceXmlSession

java.lang.Object
  extended by java.lang.Thread
      extended by org.jvoicexml.interpreter.JVoiceXmlSession
All Implemented Interfaces:
Runnable, Session

public final class JVoiceXmlSession
extends Thread
implements Session

Implementation of a Session.

Each session is started in a new thread with the session id as the name.

Version:
$Revision: 2910 $
Author:
Dirk Schnelle-Walka

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
JVoiceXmlSession(ImplementationPlatform ip, JVoiceXmlCore jvxml, ConnectionInformation connectionInformation)
          Constructs a new object.
 
Method Summary
 void addSessionListener(SessionListener listener)
          Adds the session listener.
 void call(URI uri)
          Handles a call request.
 CharacterInput getCharacterInput()
          Retrieves the DTMF input device.
 DocumentServer getDocumentServer()
          Retrieves a reference to the document server.
 GrammarProcessor getGrammarProcessor()
          Retrieves a reference to the grammar processor.
 ImplementationPlatform getImplementationPlatform()
          Retrieves a reference to the used implementation platform.
 ErrorEvent getLastError()
          Retrieves an error, if any, that happened during call processing.
 ScopeObserver getScopeObserver()
          Retrieves the scope observer for this session.
 ScriptingEngine getScriptingEngine()
          Retrieves the scripting engine.
 String getSessionID()
          Retrieves the universal unique identifier for this session.
 VoiceXmlInterpreterContext getVoiceXmlInterpreterContext()
          Retrieve the VoiceXmlInterpreterContext related to this session.
 void hangup()
          Closes this session.
 boolean hasEnded()
          Checks if this session has ended.
 void removeSessionListener(SessionListener listener)
          Removes the session listener.
 void run()
           Session working method.
 void waitSessionEnd()
          Delays until the session ends.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JVoiceXmlSession

public JVoiceXmlSession(ImplementationPlatform ip,
                        JVoiceXmlCore jvxml,
                        ConnectionInformation connectionInformation)
Constructs a new object.

Parameters:
ip - the implementation platform.
jvxml - the main object to retrieve further resources.
connectionInformation - the connection information to use
Method Detail

addSessionListener

public void addSessionListener(SessionListener listener)
Adds the session listener.

Specified by:
addSessionListener in interface Session
Parameters:
listener - the session listener to add.

removeSessionListener

public void removeSessionListener(SessionListener listener)
Removes the session listener.

Specified by:
removeSessionListener in interface Session
Parameters:
listener - the session listener to remove.

getSessionID

public String getSessionID()
Retrieves the universal unique identifier for this session.

Specified by:
getSessionID in interface Session
Returns:
Universal unique identifier for this session.

call

public void call(URI uri)
          throws ErrorEvent
Handles a call request.

Starts processing of the given application and returns immediately.

Since this method returns immediately, it offers no means to monitor the call processing and catch exceptions. Therefore clients are requested to use the Session.waitSessionEnd() method to monitor the session. Another way can be via the Telephony interface and calling Session.getLastError(). However, the latter option relies on the concrete implementation.

Starts this session in a new thread.

Specified by:
call in interface Session
Parameters:
uri - URI of the first document to load.
Throws:
ErrorEvent - Error initiating the call.

hangup

public void hangup()
Closes this session. After a session is closed, it can not be reopened e.g., to call another application.

Specified by:
hangup in interface Session

getCharacterInput

public CharacterInput getCharacterInput()
                                 throws NoresourceError,
                                        ConnectionDisconnectHangupEvent
Retrieves the DTMF input device.

Specified by:
getCharacterInput in interface Session
Returns:
DTMF input device.
Throws:
NoresourceError - Input device is not available.
ConnectionDisconnectHangupEvent - the user hung up

waitSessionEnd

public void waitSessionEnd()
                    throws ErrorEvent
Delays until the session ends.

Specified by:
waitSessionEnd in interface Session
Throws:
ErrorEvent - Error waiting for the end of the call.

hasEnded

public boolean hasEnded()
Checks if this session has ended.

Specified by:
hasEnded in interface Session
Returns:
true if the session has ended.

run

public void run()
Session working method.

Specified by:
run in interface Runnable
Overrides:
run in class Thread

getImplementationPlatform

public ImplementationPlatform getImplementationPlatform()
Retrieves a reference to the used implementation platform.

Returns:
The used implementation platform.

getDocumentServer

public DocumentServer getDocumentServer()
Retrieves a reference to the document server.

Returns:
The document server.

getGrammarProcessor

public GrammarProcessor getGrammarProcessor()
Retrieves a reference to the grammar processor.

Returns:
The grammar processor.
Since:
0.3

getVoiceXmlInterpreterContext

public VoiceXmlInterpreterContext getVoiceXmlInterpreterContext()
Retrieve the VoiceXmlInterpreterContext related to this session.

Returns:
The related context.

getScopeObserver

public ScopeObserver getScopeObserver()
Retrieves the scope observer for this session.

Returns:
The scope observer.

getScriptingEngine

public ScriptingEngine getScriptingEngine()
Retrieves the scripting engine.

Returns:
The scripting engine.
Since:
0.4

getLastError

public ErrorEvent getLastError()
Retrieves an error, if any, that happened during call processing.

Specified by:
getLastError in interface Session
Returns:
an error that happened during call processing, null if there was no error.


Copyright © 2005-2010JVoiceXML group.