org.jvoicexml.implementation.jvxml
Class JVoiceXmlImplementationPlatform

java.lang.Object
  extended by org.jvoicexml.implementation.jvxml.JVoiceXmlImplementationPlatform
All Implemented Interfaces:
Configurable, SpokenInputListener, SynthesizedOutputListener, TelephonyListener, ImplementationPlatform, PromptAccumulator

public final class JVoiceXmlImplementationPlatform
extends Object
implements SpokenInputListener, SynthesizedOutputListener, TelephonyListener, ImplementationPlatform, Configurable

Basic implementation of an ImplementationPlatform.

User actions and system output are not handled by this class but forwarded to the corresponding ExternalResources.

External resources are considered to be in a pool. The implementation platform is able to retrieve them from the pool and push them back. This means that all resources that have been borrowed from the implementation platform must be returned to it if they are no longer used.

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

Method Summary
 void close()
          Closes all open resources.
 CallControl getCallControl()
          Retrieves the calling device.
 CharacterInput getCharacterInput()
          Retrieves the DTMF input device.
 SystemOutput getSystemOutput()
          Retrieves the audio output device.
 UserInput getUserInput()
          Retrieves the user input device.
 boolean hasUserInput()
          Checks, if there is an acquired user input device.
 void init(Configuration configuration)
          Initializes this component with data from the given configuration object.
 void inputError(ErrorEvent error)
          An error occured while an output processes an input.
 void inputStatusChanged(SpokenInputEvent event)
          Notification about status changes in the SpokenInput.
 void outputError(ErrorEvent error)
          An error occurred while an output processes an output.
 void outputStatusChanged(SynthesizedOutputEvent event)
          Notification about status changes in the SynthesizedOutput.
 void queuePrompt(SpeakableText speakable)
          Queues the given prompt without rendereing it.
 void renderPrompts(String sessionId, DocumentServer server, CallControlProperties props)
          Notifies the implementation platform about the end of the prompt queuing that has been started by PromptAccumulator.setPromptTimeout(long).
 void resultAccepted(RecognitionResult result)
          The user made an utterance that matched an active grammar.
 void resultRejected(RecognitionResult result)
          The user made an utterance that did not match an active grammar.
 void setEventHandler(EventObserver observer)
          Sets the event observer to communicate events back to the interpreter.
 void setExternalRecognitionListener(ExternalRecognitionListener listener)
          Sets an external recognition listener and starts it.
 void setExternalSynthesisListener(ExternalSynthesisListener listener)
          Sets an external synthesis listener and starts it.
 void setPromptTimeout(long timeout)
          Sets the default timeout to use.
 void setSession(Session currentSession)
          Sets the current session.
 void telephonyCallAnswered(TelephonyEvent event)
          Invoked when the Telephony implementation triggered a call answered event.
 void telephonyCallHungup(TelephonyEvent event)
          Invoked when the Telephony implementation triggered a call hangup event.
 void telephonyCallTransferred(TelephonyEvent event)
          Invoked when the Telephony implementation triggered a transfer event.
 void telephonyError(ErrorEvent error)
          An error occured while communicating over the telephony.
 void telephonyMediaEvent(TelephonyEvent event)
          Invoked when the Telephony implementation triggered an event.
 void waitNonBargeInPlayed()
          Delays until all prompts are played that do not allow for barge-in.
 void waitOutputQueueEmpty()
          Delays until all prompts are played.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

init

public void init(Configuration configuration)
          throws ConfigurationException
Initializes this component with data from the given configuration object.

Specified by:
init in interface Configurable
Parameters:
configuration - the current configuration, maybe null
Throws:
ConfigurationException - error initializing the component.

setExternalRecognitionListener

public void setExternalRecognitionListener(ExternalRecognitionListener listener)
Sets an external recognition listener and starts it.

Parameters:
listener - the external recognition listener.
Since:
0.6

setExternalSynthesisListener

public void setExternalSynthesisListener(ExternalSynthesisListener listener)
Sets an external synthesis listener and starts it.

Parameters:
listener - the external synthesis listener.
Since:
0.6

getSystemOutput

public SystemOutput getSystemOutput()
                             throws NoresourceError,
                                    ConnectionDisconnectHangupEvent
Retrieves the audio output device.

Specified by:
getSystemOutput in interface ImplementationPlatform
Returns:
Audio output device to use, never null.
Throws:
NoresourceError - Output device is not available.
ConnectionDisconnectHangupEvent - the user hung up

waitOutputQueueEmpty

public void waitOutputQueueEmpty()
Delays until all prompts are played. This is needed e.g. for recording to ensure that we do not record and play prompts in parallel.

Specified by:
waitOutputQueueEmpty in interface ImplementationPlatform

waitNonBargeInPlayed

public void waitNonBargeInPlayed()
Delays until all prompts are played that do not allow for barge-in.

Specified by:
waitNonBargeInPlayed in interface ImplementationPlatform

getUserInput

public UserInput getUserInput()
                       throws NoresourceError,
                              ConnectionDisconnectHangupEvent
Retrieves the user input device.

Specified by:
getUserInput in interface ImplementationPlatform
Returns:
User input device to use, never null.
Throws:
NoresourceError - Input device is not available.
ConnectionDisconnectHangupEvent - the user hung up

hasUserInput

public boolean hasUserInput()
Checks, if there is an acquired user input device.

Specified by:
hasUserInput in interface ImplementationPlatform
Returns:
true if there is an acquired user input device.

getCharacterInput

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

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

getCallControl

public CallControl getCallControl()
                           throws NoresourceError,
                                  ConnectionDisconnectHangupEvent
Retrieves the calling device.

Specified by:
getCallControl in interface ImplementationPlatform
Returns:
Calling device to use, never null.
Throws:
NoresourceError - Calling device is not available.
ConnectionDisconnectHangupEvent - the user hung up

close

public void close()
Closes all open resources.

Specified by:
close in interface ImplementationPlatform

setEventHandler

public void setEventHandler(EventObserver observer)
Sets the event observer to communicate events back to the interpreter.

Specified by:
setEventHandler in interface ImplementationPlatform
Parameters:
observer - The event observer.

resultAccepted

public void resultAccepted(RecognitionResult result)
The user made an utterance that matched an active grammar.

Parameters:
result - the accepted recognition result.

resultRejected

public void resultRejected(RecognitionResult result)
The user made an utterance that did not match an active grammar.

Parameters:
result - the rejected recognition result.

inputStatusChanged

public void inputStatusChanged(SpokenInputEvent event)
Notification about status changes in the SpokenInput.

Specified by:
inputStatusChanged in interface SpokenInputListener
Parameters:
event - the input event..

telephonyCallAnswered

public void telephonyCallAnswered(TelephonyEvent event)
Invoked when the Telephony implementation triggered a call answered event.

Specified by:
telephonyCallAnswered in interface TelephonyListener
Parameters:
event - the event.

telephonyCallHungup

public void telephonyCallHungup(TelephonyEvent event)
Invoked when the Telephony implementation triggered a call hangup event.

Specified by:
telephonyCallHungup in interface TelephonyListener
Parameters:
event - the event.

telephonyCallTransferred

public void telephonyCallTransferred(TelephonyEvent event)
Invoked when the Telephony implementation triggered a transfer event.

Specified by:
telephonyCallTransferred in interface TelephonyListener
Parameters:
event - the event.

telephonyMediaEvent

public void telephonyMediaEvent(TelephonyEvent event)
Invoked when the Telephony implementation triggered an event.

Specified by:
telephonyMediaEvent in interface TelephonyListener
Parameters:
event - the event.

outputStatusChanged

public void outputStatusChanged(SynthesizedOutputEvent event)
Notification about status changes in the SynthesizedOutput.

Specified by:
outputStatusChanged in interface SynthesizedOutputListener
Parameters:
event - the output event.

setSession

public void setSession(Session currentSession)
Sets the current session.

Specified by:
setSession in interface ImplementationPlatform
Parameters:
currentSession - the current session.

outputError

public void outputError(ErrorEvent error)
An error occurred while an output processes an output.

This method is intended to feed back errors that happen while the SystemOutput processes an output asynchronously. Errors that happen while the output is queued should be reported by throwing an appropriate error in the SystemOutput.queueSpeakable(org.jvoicexml.SpeakableText, String, org.jvoicexml.DocumentServer) method.

Specified by:
outputError in interface SynthesizedOutputListener
Parameters:
error - the error

inputError

public void inputError(ErrorEvent error)
An error occured while an output processes an input.

This method is intended to feed back errors that happen while the UserInput processes an input asynchronously.

Specified by:
inputError in interface SpokenInputListener
Parameters:
error - the error

telephonyError

public void telephonyError(ErrorEvent error)
An error occured while communicating over the telephony.

This method is intended to feed back errors that happen while the CallControl processes an output asynchronously.

Specified by:
telephonyError in interface TelephonyListener
Parameters:
error - the error

setPromptTimeout

public void setPromptTimeout(long timeout)
Sets the default timeout to use.

This method is intended to be called prior to queuing prompts via PromptAccumulator.queuePrompt(SpeakableText), so it also clears the list of queued prompts.

Specified by:
setPromptTimeout in interface PromptAccumulator
Parameters:
timeout - default timeout.

queuePrompt

public void queuePrompt(SpeakableText speakable)
Queues the given prompt without rendereing it.

After all prompts have been queued, the end of prompt queuing must be indicated by #renderPrompts(String, DocumentServer).

Specified by:
queuePrompt in interface PromptAccumulator
Parameters:
speakable - the prompt to queue.

renderPrompts

public void renderPrompts(String sessionId,
                          DocumentServer server,
                          CallControlProperties props)
                   throws BadFetchError,
                          NoresourceError,
                          ConnectionDisconnectHangupEvent
Notifies the implementation platform about the end of the prompt queuing that has been started by PromptAccumulator.setPromptTimeout(long).

It is assumed that the PromptAccumulator has knowledge about the ImplementationPlatform to render the output.

Specified by:
renderPrompts in interface PromptAccumulator
Parameters:
sessionId - the current session id
server - the document server to use
props - properties for the call control
Throws:
BadFetchError - error queuing the prompt
NoresourceError - Output device is not available.
ConnectionDisconnectHangupEvent - the user hung up


Copyright © 2005-2010JVoiceXML group.