org.jvoicexml.Session - java examples

Here are the examples of the java api org.jvoicexml.Session taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

74 Examples 7

19 View Complete Implementation : HelloWorldDemo.java
Copyright GNU Lesser General Public License v2.1
Author : JVoiceXML
/**
 * Calls the VoiceXML interpreter context to process the given xml doreplacedent.
 * @param uri URI of the first doreplacedent to load
 * @exception JVoiceXMLEvent
 *            Error processing the call.
 */
private void interpretDoreplacedent(final URI uri) throws JVoiceXMLEvent {
    JVoiceXml jvxml;
    try {
        jvxml = (JVoiceXml) context.lookup("JVoiceXml");
    } catch (javax.naming.NamingException ne) {
        LOGGER.error("error obtaining JVoiceXml", ne);
        return;
    }
    final ConnectionInformation client = new BasicConnectionInformation("desktop", "jsapi20", "jsapi20");
    final Session session = jvxml.createSession(client);
    session.call(uri);
    session.waitSessionEnd();
    session.hangup();
}

19 View Complete Implementation : ObjectTagDemo.java
Copyright GNU Lesser General Public License v2.1
Author : JVoiceXML
/**
 * Calls the VoiceXML interpreter context to process the given XML doreplacedent.
 *
 * @param uri
 *            URI of the first doreplacedent to load
 * @exception JVoiceXMLEvent
 *                Error processing the call.
 */
private void interpretDoreplacedent(final URI uri) throws JVoiceXMLEvent {
    JVoiceXml jvxml;
    try {
        jvxml = (JVoiceXml) context.lookup("JVoiceXml");
    } catch (javax.naming.NamingException ne) {
        LOGGER.error("error obtaining JVoiceXml", ne);
        return;
    }
    final ConnectionInformation client = new BasicConnectionInformation("desktop", "jsapi20", "jsapi20");
    final Session session = jvxml.createSession(client);
    session.call(uri);
    session.waitSessionEnd();
    session.hangup();
}

19 View Complete Implementation : MMIContext.java
Copyright GNU Lesser General Public License v2.1
Author : JVoiceXML
/**
 * replacedociated a communication channel object with MMI request identifiers.
 * @author Dirk Schnelle-Walka
 * @version $Revision$
 * @since 0.7.6
 */
public final clreplaced MMIContext {

    /**
     * The replacedociated communication channel.
     */
    private Object channel;

    /**
     * An replacedociated session.
     */
    private Session session;

    /**
     * State of this session.
     */
    private ModalityComponentState state;

    /**
     * The target URI.
     */
    private String target;

    /**
     * The current contentURL.
     */
    private URI contentURL;

    /**
     * The request Identifier.
     */
    private String requestId;

    /**
     * The context identifier.
     */
    private final String contextId;

    /**
     * Constructs a new object.
     * @param ctxId the context id
     * @exception URISyntaxException
     *            the given context id does not denote a valid URI
     */
    public MMIContext(final String ctxId) throws URISyntaxException {
        contextId = ctxId;
    }

    /**
     * Constructs a new object.
     * @param reqId the request id
     * @param ctxId the context id
     * @exception URISyntaxException
     *            the given context id does not denote a valid URI
     */
    public MMIContext(final String reqId, final String ctxId) throws URISyntaxException {
        contextId = ctxId;
        requestId = reqId;
    }

    /**
     * Retrieves the context identifier.
     * @return the context identifier
     */
    public String getContextId() {
        return contextId;
    }

    /**
     * Gets the value of the requestID property.
     *
     * @return possible object is {@link String }
     */
    public String getRequestId() {
        return requestId;
    }

    /**
     * Sets the request identifier.
     * @param value the request identifier
     */
    public void setRequestId(final String value) {
        requestId = value;
    }

    /**
     * Retrieves the channel.
     * @return the channel
     */
    public Object getChannel() {
        return channel;
    }

    /**
     * Sets the channel.
     * @param ch the channel.
     */
    public void setChannel(final Object ch) {
        channel = ch;
    }

    /**
     * Retrieves the session.
     * @return the session
     */
    public Session getSession() {
        return session;
    }

    /**
     * Sets the session.
     * @param sess the session.
     */
    public void setSession(final Session sess) {
        session = sess;
    }

    /**
     * Retrieves the state of this session.
     * @return the current state
     */
    public ModalityComponentState getState() {
        return state;
    }

    /**
     * Sets the new state for this session.
     * @param value the new state
     */
    public void setState(final ModalityComponentState value) {
        state = value;
    }

    /**
     * Retrieves the target address for communication issues.
     * @return the target address
     */
    public String getTarget() {
        return target;
    }

    /**
     * Sets the target address for communication issues..
     * @param value the target address
     */
    public void setTarget(final String value) {
        target = value;
    }

    /**
     * Retrieves the content URL.
     * @return the content URL
     */
    public URI getContentURL() {
        return contentURL;
    }

    /**
     * Sets the content URL.
     * @param value the content URL
     */
    public void setContentURL(final URI value) {
        contentURL = value;
    }

    /**
     * Sets the content URL.
     * @param value the content URL
     * @throws URISyntaxException
     *         the given value does not denote a valid URI
     */
    public void setContentURL(final String value) throws URISyntaxException {
        if ((value == null) || value.isEmpty()) {
            contentURL = null;
        } else {
            final URI uri = new URI(value);
            setContentURL(uri);
        }
    }
}

19 View Complete Implementation : JVoiceXmlSkeleton.java
Copyright GNU Lesser General Public License v2.1
Author : JVoiceXML
/**
 * {@inheritDoc}
 */
public Session createSession(final ConnectionInformation client) throws RemoteException {
    if (jvxml == null) {
        return null;
    }
    final Session session;
    try {
        session = jvxml.createSession(client);
    } catch (ErrorEvent ee) {
        LOGGER.error("unable to create session", ee);
        throw new RemoteException("unable to create session", ee);
    }
    final Skeleton sessionSkeleton = new SessionSkeleton(context, session);
    final Stub sessionStub = new SessionStub(session.getSessionId());
    JVoiceXmlJndiSupport.bind(context, sessionSkeleton, sessionStub);
    return (Session) sessionStub;
}

19 View Complete Implementation : SubdialogDemo.java
Copyright GNU Lesser General Public License v2.1
Author : JVoiceXML
/**
 * The main method.
 *
 * @param args
 *            Command line arguments. None expected.
 */
public static void main(final String[] args) {
    LOGGER.info("Starting 'subdialog' demo for JVoiceXML...");
    LOGGER.info("(c) 2010-2017 by JVoiceXML group - " + "http://jvoicexml.sourceforge.net/");
    final GenericClient client = new GenericClient();
    try {
        final URI dialog = SubdialogDemo.clreplaced.getResource("/subdialog.vxml").toURI();
        final Session session = client.call(dialog, "jsapi20", "jsapi20", "desktop");
        session.waitSessionEnd();
        session.hangup();
    } catch (NamingException e) {
        LOGGER.fatal(e.getMessage(), e);
        return;
    } catch (ErrorEvent e) {
        LOGGER.fatal(e.getMessage(), e);
        return;
    } catch (UnsupportedResourceIdentifierException e) {
        LOGGER.fatal(e.getMessage(), e);
        return;
    } catch (URISyntaxException e) {
        LOGGER.fatal(e.getMessage(), e);
        return;
    } finally {
        client.close();
    }
}

19 View Complete Implementation : JVoiceXmlImplementationPlatform.java
Copyright GNU Lesser General Public License v2.1
Author : JVoiceXML
/**
 * {@inheritDoc}
 */
public void setSession(final Session currentSession) {
    session = currentSession;
}

19 View Complete Implementation : MarcDemo.java
Copyright GNU Lesser General Public License v2.1
Author : JVoiceXML
/**
 * Calls the VoiceXML interpreter context to process the given XML doreplacedent.
 * @param uri URI of the first doreplacedent to load
 * @exception JVoiceXMLEvent
 *            Error processing the call.
 */
private void interpretDoreplacedent(final URI uri) throws JVoiceXMLEvent {
    JVoiceXml jvxml;
    try {
        jvxml = (JVoiceXml) context.lookup("JVoiceXml");
    } catch (javax.naming.NamingException ne) {
        LOGGER.error("error obtaining JVoiceXml", ne);
        return;
    }
    final ConnectionInformation client = new BasicConnectionInformation("desktop", "marc", "jsapi20");
    final Session session = jvxml.createSession(client);
    session.call(uri);
    session.waitSessionEnd();
    session.hangup();
}

19 View Complete Implementation : JVoiceXmlImplementationPlatform.java
Copyright GNU Lesser General Public License v2.1
Author : JVoiceXML
/**
 * Basic implementation of an {@link ImplementationPlatform}.
 *
 * <p>
 * User actions and system output are not handled by this clreplaced but forwarded to
 * the corresponding {@link ExternalResource}s.
 * </p>
 *
 * <p>
 * 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.
 * </p>
 *
 * @author Dirk Schnelle-Walka
 */
public final clreplaced JVoiceXmlImplementationPlatform implements SpokenInputListener, SynthesizedOutputListener, TelephonyListener, ImplementationPlatform, Configurable {

    /**
     * Logger for this clreplaced.
     */
    private static final Logger LOGGER = LogManager.getLogger(JVoiceXmlImplementationPlatform.clreplaced);

    /**
     * Timeout in msec to wait until the resource is not busy.
     */
    private static final int BUSY_WAIT_TIMEOUT = 1000;

    /**
     * Pool of synthesizer output resource factories.
     */
    private final KeyedResourcePool<SynthesizedOutput> synthesizerPool;

    /**
     * Lock for the synthesizer pool.
     */
    private final Object synthesizerPoolLock;

    /**
     * Pool of user input resource factories.
     */
    private final KeyedResourcePool<SpokenInput> recognizerPool;

    /**
     * Lock for the recognizer pool.
     */
    private final Object recognizerPoolLock;

    /**
     * Pool of user calling resource factories.
     */
    private final KeyedResourcePool<Telephony> telephonyPool;

    /**
     * Lock for the telephony pool.
     */
    private final Object telephonyPoolLock;

    /**
     * Connection information to use.
     */
    private final ConnectionInformation info;

    /**
     * The output device.
     */
    private JVoiceXmlSystemOutput output;

    /**
     * Support for audio input.
     */
    private JVoiceXmlUserInput input;

    /**
     * Input not busy notification lock.
     */
    private final Object inputLock;

    /**
     * Support for DTMF input.
     */
    private volatile BufferedDtmfInput dtmfInput;

    /**
     * The calling device.
     */
    private JVoiceXmlCallControl call;

    /**
     * The event bus to communicate events back to the interpreter.
     */
    private EventBus eventbus;

    /**
     * A timer to get the noinput timeout.
     */
    private TimerThread timer;

    /**
     * The name of the mark last executed by the SSML processor.
     */
    private String markname;

    /**
     * Flag set to <code>true</code> if the implementation platform is closed.
     */
    private boolean closed;

    /**
     * Flag set to {@code true} if the caller hung up the phone.
     */
    private boolean hungup;

    /**
     * The current session.
     */
    private Session session;

    /**
     * The prompt acreplacedulator methods are implemented as a delegate.
     */
    private final JVoiceXmlPromptAcreplacedulator promptAcreplacedulator;

    /**
     * A reaper to monitor that the platform is returned within a predefined
     * timespan.
     */
    private ImplementationPlatformReaper reaper;

    /**
     * Constructs a new Implementation platform.
     *
     * <p>
     * This method should not be called by any application. The implementation
     * platform is accessible via the <code>Session</code>
     * </p>
     *
     * @param telePool
     *            pool of telephony resource factories
     * @param synthesizedOutputPool
     *            pool of synthesized output resource factories
     * @param spokenInputPool
     *            pool of spoken input resource factories
     * @param connectionInformation
     *            connection information container
     *
     * @see org.jvoicexml.Session
     */
    JVoiceXmlImplementationPlatform(final KeyedResourcePool<Telephony> telePool, final KeyedResourcePool<SynthesizedOutput> synthesizedOutputPool, final KeyedResourcePool<SpokenInput> spokenInputPool, final ConnectionInformation connectionInformation) {
        this(telePool, synthesizedOutputPool, spokenInputPool, new BufferedDtmfInput(), connectionInformation);
    }

    /**
     * Constructs a new Implementation platform.
     *
     * <p>
     * This method should not be called by any application. The implementation
     * platform is accessible via the <code>Session</code>
     * </p>
     *
     * @param telePool
     *            pool of telephony resource factories
     * @param synthesizedOutputPool
     *            pool of synthesized output resource factories
     * @param spokenInputPool
     *            pool of spoken input resource factories
     * @param bufferedCharacterInput
     *            buffer character input for this platform
     * @param connectionInformation
     *            connection information container
     *
     * @see org.jvoicexml.Session
     */
    JVoiceXmlImplementationPlatform(final KeyedResourcePool<Telephony> telePool, final KeyedResourcePool<SynthesizedOutput> synthesizedOutputPool, final KeyedResourcePool<SpokenInput> spokenInputPool, final BufferedDtmfInput bufferedCharacterInput, final ConnectionInformation connectionInformation) {
        info = connectionInformation;
        telephonyPool = telePool;
        telephonyPoolLock = new Object();
        synthesizerPool = synthesizedOutputPool;
        synthesizerPoolLock = new Object();
        recognizerPool = spokenInputPool;
        recognizerPoolLock = new Object();
        dtmfInput = bufferedCharacterInput;
        inputLock = new Object();
        promptAcreplacedulator = new JVoiceXmlPromptAcreplacedulator(this);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void init(final Configuration configuration) throws ConfigurationException {
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public SystemOutput getSystemOutput() throws NoresourceError, ConnectionDisconnectHangupEvent {
        synchronized (this) {
            if (hungup) {
                throw new ConnectionDisconnectHangupEvent("caller hung up");
            }
            if (closed) {
                throw new NoresourceError("implementation platform closed");
            }
        }
        final String type = info.getSystemOutput();
        synchronized (synthesizerPoolLock) {
            if (output == null) {
                final SynthesizedOutput synthesizer = getExternalResourceFromPool(synthesizerPool, type);
                output = new JVoiceXmlSystemOutput(synthesizer, session);
                output.addListener(this);
                LOGGER.info("borrowed system output of type '" + type + "'");
            }
            return output;
        }
    }

    /**
     * Returns a previously borrowed system output to the pool.
     */
    private void returnSystemOutput() {
        synchronized (synthesizerPoolLock) {
            if (output == null) {
                return;
            }
            if (!hungup && !closed && output.isBusy()) {
                if (LOGGER.isDebugEnabled()) {
                    LOGGER.debug("output still busy. returning when queue is" + " empty");
                }
                maybeStartReaper();
            } else {
                maybeStopReaper();
                final JVoiceXmlSystemOutput systemOutput = output;
                output = null;
                final String type = info.getSystemOutput();
                if (LOGGER.isDebugEnabled()) {
                    LOGGER.debug("returning system output of type '" + type + "'...");
                }
                systemOutput.removeListener(this);
                final SynthesizedOutput synthesizedOutput = systemOutput.getSynthesizedOutput();
                returnExternalResourceToPool(synthesizerPool, synthesizedOutput);
                LOGGER.info("returned system output of type '" + type + "'");
            }
        }
    }

    /**
     * Starts a reaper if not already started.
     *
     * @since 0.7.7
     */
    private void maybeStartReaper() {
        if (reaper != null) {
            return;
        }
        reaper = new ImplementationPlatformReaper(this);
        reaper.start();
    }

    /**
     * Stops a reaper if not already stopped.
     *
     * @since 0.7.7
     */
    private void maybeStopReaper() {
        if (reaper == null) {
            return;
        }
        reaper.stopReaping();
        reaper = null;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void waitOutputQueueEmpty() {
        if (output == null) {
            return;
        }
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("waiting for empty output queue...");
        }
        final SynthesizedOutput synthesizedOutput = output.getSynthesizedOutput();
        synthesizedOutput.waitQueueEmpty();
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("...output queue empty.");
        }
    }

    /**
     * {@inheritDoc}
     */
    public void waitNonBargeInPlayed() {
        if (output == null) {
            return;
        }
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("waiting for non-barge-in played...");
        }
        final SynthesizedOutput synthesizedOutput = output.getSynthesizedOutput();
        synthesizedOutput.waitNonBargeInPlayed();
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("...non-barge-in played.");
        }
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public UserInput getUserInput() throws NoresourceError, ConnectionDisconnectHangupEvent {
        synchronized (this) {
            if (hungup) {
                throw new ConnectionDisconnectHangupEvent("caller hung up");
            }
            if (closed) {
                throw new NoresourceError("implementation platform closed");
            }
        }
        final String type = info.getUserInput();
        synchronized (recognizerPoolLock) {
            if (input == null) {
                final SpokenInput spokenInput = getExternalResourceFromPool(recognizerPool, type);
                input = new JVoiceXmlUserInput(spokenInput, dtmfInput);
                input.addListener(this);
                LOGGER.info("borrowed user input of type '" + type + "'");
            }
        }
        return input;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public boolean isUserInputActive() {
        synchronized (info) {
            return input != null;
        }
    }

    /**
     * Returns a previously obtained user input to the pool.
     */
    private void returnUserInput() {
        synchronized (recognizerPoolLock) {
            if (input == null) {
                return;
            }
            if (!hungup && !closed && input.isBusy()) {
                if (LOGGER.isDebugEnabled()) {
                    LOGGER.debug("input still busy. returning when recognition" + " is stopped");
                }
            } else {
                final JVoiceXmlUserInput userInput = input;
                input = null;
                final String type = info.getUserInput();
                if (LOGGER.isDebugEnabled()) {
                    LOGGER.debug("returning user input of type '" + type + "'...");
                }
                userInput.removeListener(this);
                final SpokenInput spokenInput = userInput.getSpokenInput();
                returnExternalResourceToPool(recognizerPool, spokenInput);
                LOGGER.info("returned user input of type '" + type + "'");
            }
        }
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public DtmfInput getCharacterInput() throws NoresourceError, ConnectionDisconnectHangupEvent {
        synchronized (this) {
            if (hungup) {
                throw new ConnectionDisconnectHangupEvent("caller hung up");
            }
            if (closed) {
                throw new NoresourceError("implementation platform closed");
            }
        }
        return dtmfInput;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public CallControl getCallControl() throws NoresourceError, ConnectionDisconnectHangupEvent {
        synchronized (this) {
            if (hungup) {
                throw new ConnectionDisconnectHangupEvent("caller hung up");
            }
            if (closed) {
                throw new NoresourceError("implementation platform closed");
            }
        }
        // In contrast to SystemOutput and UserInput the CallControl
        // resource may be used concurrently.
        // So we must not have a semapreplaced to avoid shared use.
        final String type = info.getCallControl();
        synchronized (telephonyPoolLock) {
            if (call == null) {
                final Telephony telephony = getExternalResourceFromPool(telephonyPool, type);
                telephony.addListener(this);
                call = new JVoiceXmlCallControl(telephony);
                LOGGER.info("borrowed call control of type '" + type + "'");
            }
            return call;
        }
    }

    /**
     * Returns a previously obtained call control to the pool.
     */
    private void returnCallControl() {
        synchronized (telephonyPoolLock) {
            if (call == null) {
                return;
            }
            // TODO It may happen that two threads borrow this call control
            // and one returns it before the second set it to busy.
            // In this case the resource is returned although the second still
            // possesses it.
            if (!hungup && !closed && call.isBusy()) {
                if (LOGGER.isDebugEnabled()) {
                    LOGGER.debug("call control still busy. returning when queue" + " is empty");
                }
            } else {
                final JVoiceXmlCallControl callControl = call;
                call = null;
                final String type = info.getCallControl();
                if (LOGGER.isDebugEnabled()) {
                    LOGGER.debug("returning call control of type '" + type + "'...");
                }
                final Telephony telephony = callControl.getTelephony();
                returnExternalResourceToPool(telephonyPool, telephony);
                LOGGER.info("returned call control of type '" + type + "'");
            }
        }
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void close() {
        synchronized (this) {
            if (closed) {
                return;
            }
            closed = true;
        }
        LOGGER.info("closing implementation platform");
        maybeStopReaper();
        if (output != null) {
            if (!hungup) {
                // If the user did not hang up, wait until all output has been
                // played.
                waitOutputQueueEmpty();
            }
        }
        if (timer != null) {
            timer.stopTimer();
            timer = null;
        }
        if (input != null) {
            if (hungup) {
                input.stopRecognition(null);
            } else {
                try {
                    waitInputNotBusy();
                } catch (Exception e) {
                    LOGGER.warn("error waiting for input not busy", e);
                }
            }
        }
        LOGGER.info("returning aqcuired resources");
        returnSystemOutput();
        returnUserInput();
        returnCallControl();
        LOGGER.info("implementation platform closed");
    }

    /**
     * Delays until the input is no more busy.
     */
    private void waitInputNotBusy() {
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("waiting for empty input not busy...");
        }
        while (input.isBusy()) {
            synchronized (info) {
                try {
                    inputLock.wait(BUSY_WAIT_TIMEOUT);
                } catch (InterruptedException e) {
                    if (LOGGER.isDebugEnabled()) {
                        LOGGER.debug("waiting for input not busy interrupted", e);
                    }
                    return;
                }
            }
        }
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("...input not busy.");
        }
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void setEventBus(final EventBus bus) {
        eventbus = bus;
    }

    /**
     * The user has started to speak.
     *
     * @param type
     *            the mode type of te recognizer that started
     */
    private void inputStarted(final ModeType type) {
        // No need to wait for input
        if (timer != null) {
            timer.stopTimer();
            timer = null;
        }
        if (output == null) {
            return;
        }
        // Try cancel the output only, if the platform supports SPEECH bargeins.
        final Collection<BargeInType> types = input.getSupportedBargeInTypes();
        if (types.contains(BargeInType.SPEECH)) {
            return;
        }
        if (LOGGER.isDebugEnabled()) {
            if (type == null) {
                LOGGER.debug("input started 'unknown mode':" + " stopping system output...");
            } else {
                LOGGER.debug("input started: '" + type.getMode() + "' stopping system output...");
            }
        }
        try {
            output.cancelOutput(BargeInType.SPEECH);
        } catch (NoresourceError nre) {
            LOGGER.warn("unable to stop speech output", nre);
            return;
        }
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("...system output stopped");
        }
    }

    /**
     * The user made an utterance that matched an active grammar.
     *
     * @param result
     *            the accepted recognition result.
     */
    public void resultAccepted(final RecognitionResult result) {
        LOGGER.info("accepted recognition '" + result.getUtterance() + "'");
        if (eventbus != null) {
            result.setMark(markname);
            final RecognitionEvent recognitionEvent = new RecognitionEvent(input.getSpokenInput(), session.getSessionId(), result);
            eventbus.publish(recognitionEvent);
        }
        markname = null;
        synchronized (inputLock) {
            inputLock.notifyAll();
        }
    }

    /**
     * The user made an utterance that did not match an active grammar.
     *
     * @param result
     *            the rejected recognition result.
     */
    public void resultRejected(final RecognitionResult result) {
        LOGGER.info("rejected recognition '" + result.getUtterance() + "'");
        if (eventbus != null) {
            result.setMark(markname);
            final NomatchEvent noMatchEvent = new NomatchEvent(input.getSpokenInput(), session.getSessionId(), result);
            eventbus.publish(noMatchEvent);
        }
        synchronized (inputLock) {
            inputLock.notifyAll();
        }
    }

    /**
     * Retrieves a new {@link ExternalResource} from the pool.
     *
     * @param pool
     *            the resource pool.
     * @param key
     *            key of the resource to retrieve.
     * @param <T>
     *            type of the resource.
     * @return obtained resource.
     * @throws NoresourceError
     *             Error obtaining an instance from the pool.
     *
     * @since 0.5.5
     */
    private <T extends ExternalResource> T getExternalResourceFromPool(final KeyedResourcePool<T> pool, final String key) throws NoresourceError {
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("obtaining resource '" + key + "' from pool...");
        }
        final T resource = pool.borrowObject(key);
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("connecting external resource (" + resource.getClreplaced().getCanonicalName() + ").");
        }
        try {
            resource.connect(info);
        } catch (IOException ioe) {
            try {
                pool.returnObject(key, resource);
            } catch (Exception e) {
                LOGGER.error("error returning resource to pool", e);
            }
            throw new NoresourceError("error connecting to resource: " + ioe.getMessage(), ioe);
        }
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("...connected");
        }
        return resource;
    }

    /**
     * Returns the audio file output resource to the pool.
     *
     * @param pool
     *            the pool to which to return the resource.
     * @param resource
     *            the resource to return.
     * @param <T>
     *            type of the resource.
     */
    private <T extends ExternalResource> void returnExternalResourceToPool(final KeyedResourcePool<T> pool, final T resource) {
        final String type = resource.getType();
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("returning external resource '" + type + "' (" + resource.getClreplaced().getCanonicalName() + ") to pool...");
            LOGGER.debug("disconnecting external resource.");
        }
        resource.disconnect(info);
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("...disconnected");
        }
        try {
            pool.returnObject(type, resource);
        } catch (NoresourceError e) {
            LOGGER.error("error returning external resource to pool", e);
        }
        LOGGER.info("returned external resource '" + type + "' (" + resource.getClreplaced().getCanonicalName() + ") to pool");
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void inputStatusChanged(final SpokenInputEvent event) {
        if (event.isType(RecognitionStartedEvent.EVENT_TYPE)) {
            // Start the timer with a default timeout if there were no
            // prompts to queue.
            final SpeakableText lastSpeakable = promptAcreplacedulator.getLastSpeakableText();
            if (lastSpeakable == null) {
                startTimer();
            }
        } else if (event.isType(InputStartedEvent.EVENT_TYPE)) {
            final InputStartedEvent started = (InputStartedEvent) event;
            final ModeType modeType = started.getMode();
            inputStarted(modeType);
        } else if (event.isType(RecognitionEvent.EVENT_TYPE)) {
            final RecognitionEvent recognitionEvent = (RecognitionEvent) event;
            final RecognitionResult result = recognitionEvent.getRecognitionResult();
            resultAccepted(result);
        } else if (event.isType(NomatchEvent.EVENT_TYPE)) {
            final NomatchEvent nomatch = (NomatchEvent) event;
            final RecognitionResult result = nomatch.getRecognitionResult();
            resultRejected(result);
        } else if (event.isType(RecognitionStoppedEvent.EVENT_TYPE)) {
            recognitionStopped();
        } else {
            LOGGER.warn("unknown spoken input event " + event);
        }
        eventbus.publish(event);
    }

    /**
     * Starts the <code>noinput</code> timer with the given timeout that has
     * been collected by the {@link org.jvoicexml.PromptAcreplacedulator}.
     */
    private synchronized void startTimer() {
        if (timer != null) {
            return;
        }
        final long timeout = promptAcreplacedulator.getPromptTimeout();
        if (timeout > 0) {
            timer = new TimerThread(eventbus, timeout);
            timer.start();
        }
    }

    /**
     * The recognition has been stopped.
     */
    private void recognitionStopped() {
        LOGGER.info("recognition stopped");
        if (timer != null) {
            timer.stopTimer();
            timer = null;
        }
        if (call != null) {
            LOGGER.info("will stop call recording");
            try {
                call.stopRecord();
            } catch (NoresourceError ex) {
                ex.printStackTrace();
            }
            LOGGER.info("done stop record request");
        }
        if (hungup) {
            returnUserInput();
        }
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void telephonyCallAnswered(final TelephonyEvent event) {
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void dtmfInput(final char dtmf) {
        dtmfInput.addDtmf(dtmf);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void telephonyCallHungup(final TelephonyEvent event) {
        synchronized (this) {
            // Ignore the event if we are already closing the connection
            if (hungup) {
                return;
            }
            hungup = true;
        }
        LOGGER.info("telephony connection closed");
        // Publish a corresponding event
        if (eventbus != null) {
            final JVoiceXMLEvent hangupEvent = new ConnectionDisconnectHangupEvent("caller hung up");
            eventbus.publish(hangupEvent);
        }
        // Immediately return the resources
        LOGGER.info("returning aqcuired resources");
        returnSystemOutput();
        returnUserInput();
        returnCallControl();
        LOGGER.info("implementation platform closed");
    }

    /**
     * {@inheritDoc}
     */
    public void telephonyCallTransferred(final TelephonyEvent event) {
        LOGGER.info("call transfered to '" + event.getParam() + "'");
        if (eventbus != null) {
            final String uri = (String) event.getParam();
            final JVoiceXMLEvent transferEvent = new TransferEvent(uri, null);
            eventbus.publish(transferEvent);
        }
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void telephonyMediaEvent(final TelephonyEvent event) {
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void outputStatusChanged(final SynthesizedOutputEvent event) {
        // Forward this to the event bus
        if (eventbus != null) {
            eventbus.publish(event);
        }
        if (event.isType(OutputStartedEvent.EVENT_TYPE)) {
            final OutputStartedEvent outputStartedEvent = (OutputStartedEvent) event;
            final SpeakableText startedSpeakable = outputStartedEvent.getSpeakable();
            if (LOGGER.isDebugEnabled()) {
                LOGGER.debug("output started " + startedSpeakable);
            }
        } else if (event.isType(OutputEndedEvent.EVENT_TYPE)) {
            final OutputEndedEvent outputEndedEvent = (OutputEndedEvent) event;
            final SpeakableText endedSpeakable = outputEndedEvent.getSpeakable();
            outputEnded(endedSpeakable);
        } else if (event.isType(QueueEmptyEvent.EVENT_TYPE)) {
            if (LOGGER.isDebugEnabled()) {
                LOGGER.debug("output queue is empty");
            }
        } else if (event.isType(MarkerReachedEvent.EVENT_TYPE)) {
            final MarkerReachedEvent markReachedEvent = (MarkerReachedEvent) event;
            markname = markReachedEvent.getMark();
            LOGGER.info("reached mark '" + markname + "'");
        } else {
            LOGGER.warn("unknown synthesized output event " + event);
        }
    }

    /**
     * The output of the given speakable has ended.
     *
     * @param speakable
     *            the speakable.
     */
    private void outputEnded(final SpeakableText speakable) {
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("output ended " + speakable.getSpeakableText());
        }
        if (call != null) {
            if (LOGGER.isDebugEnabled()) {
                LOGGER.info("will stop call playing");
            }
            try {
                call.stopPlay();
            } catch (NoresourceError ex) {
                LOGGER.warn("error stopping play", ex);
            }
            if (LOGGER.isDebugEnabled()) {
                LOGGER.info("done stop play request");
            }
        }
        if (hungup) {
            returnSystemOutput();
            return;
        }
        if (eventbus == null) {
            return;
        }
        // The timer is only needed within the field.
        final SpeakableText lastSpeakable = promptAcreplacedulator.getLastSpeakableText();
        if (speakable.equals(lastSpeakable)) {
            if (LOGGER.isDebugEnabled()) {
                LOGGER.debug("reached last speakable. starting timer");
            }
            startTimer();
        }
    }

    /**
     * {@inheritDoc}
     */
    public void setSession(final Session currentSession) {
        session = currentSession;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void outputError(final ErrorEvent error) {
        reportError(error);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void inputError(final ErrorEvent error) {
        reportError(error);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void telephonyError(final ErrorEvent error) {
        reportError(error);
    }

    /**
     * Reports an error that happened while communicating with the user.
     *
     * @param error
     *            the error
     * @since 0.7.4
     */
    private void reportError(final ErrorEvent error) {
        if (eventbus == null) {
            LOGGER.warn("no event observer. unable to propagate an error", error);
            return;
        }
        eventbus.publish(error);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void startPromptQueuing(final long timeout) {
        promptAcreplacedulator.startPromptQueuing(timeout);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void queuePrompt(final SpeakableText speakable) {
        promptAcreplacedulator.queuePrompt(speakable);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void renderPrompts(final String sessionId, final DoreplacedentServer server, final CallControlProperties props) throws BadFetchError, NoresourceError, ConnectionDisconnectHangupEvent {
        promptAcreplacedulator.renderPrompts(sessionId, server, props);
    }
}

19 View Complete Implementation : ScriptDemo.java
Copyright GNU Lesser General Public License v2.1
Author : JVoiceXML
/**
 * Call the VoiceXML interpreter context to process the given XML doreplacedent.
 *
 * @param uri
 *            URI of the first doreplacedent to load
 * @exception JVoiceXMLEvent
 *                Error processing the call.
 */
private void interpretDoreplacedent(final URI uri) throws JVoiceXMLEvent {
    JVoiceXml jvxml;
    try {
        jvxml = (JVoiceXml) context.lookup("JVoiceXml");
    } catch (javax.naming.NamingException ne) {
        LOGGER.error("error obtaining JVoiceXml", ne);
        return;
    }
    final ConnectionInformation client = new BasicConnectionInformation("desktop", "jsapi20", "jsapi20");
    final Session session = jvxml.createSession(client);
    session.call(uri);
    /**
     * @todo Enable remote access to the scripting engine.
     */
    // final VoiceXmlInterpreterContext context =
    // session.getVoiceXmlInterpreterContext();
    // final Session session = jvxml.createSession(null, application);
    // // add a test-var to the application, see test1.xml how to use it.
    // final ScriptingEngine scripting = context.getScriptingEngine();
    // scripting.setVariable("demovar1", "'test me please!'");
    session.waitSessionEnd();
    session.hangup();
}

19 View Complete Implementation : TextConnection.java
Copyright GNU Lesser General Public License v2.1
Author : JVoiceXML
/**
 * {@inheritDoc}
 */
@Override
public void run() {
    Throwable error = null;
    try {
        final ConnectionInformation client = new ConnectedTextConnectionInformation(socket);
        final Session session = jvxml.createSession(client);
        session.call(uri);
        session.waitSessionEnd();
        socket.close();
        socket = null;
    } catch (ErrorEvent e) {
        error = e;
    } catch (URISyntaxException e) {
        error = e;
    } catch (IOException e) {
        error = e;
    }
    // Close the connection in case of an error.
    if (error != null) {
        LOGGER.error(error.getMessage(), error);
        try {
            if (socket != null) {
                socket.close();
            }
        } catch (IOException e) {
            LOGGER.error(e.getMessage(), e);
        }
    }
}

19 View Complete Implementation : WebServiceDemo.java
Copyright GNU Lesser General Public License v2.1
Author : JVoiceXML
/**
 * The main method.
 * @param args Command line arguments. None expected.
 */
public static void main(final String[] args) {
    LOGGER.info("Starting 'hello world' demo for JVoiceXML...");
    LOGGER.info("(c) 2005-2012 by JVoiceXML group - " + "http://jvoicexml.sourceforge.net/");
    // final GenericClient client = new GenericClient();
    final File file = new File("conf/jvxml/vxml/webservicedemo.vxml");
    final URI dialog = file.toURI();
    try {
        final ConnectionInformation client = new BasicConnectionInformation("desktop", "mobicents", "mobicents");
        // Session session = client.call(dialog, "jsapi10", "jsapi10",
        // "desktop");
        Context context = new InitialContext();
        JVoiceXml jvxml = (JVoiceXml) context.lookup("JVoiceXml");
        final Session session = jvxml.createSession(client);
        session.call(dialog);
        Thread.sleep(10000);
        session.waitSessionEnd();
        session.hangup();
    } catch (NamingException e) {
        LOGGER.fatal(e.getMessage(), e);
        return;
    } catch (ErrorEvent e) {
        LOGGER.fatal(e.getMessage(), e);
        return;
    } catch (Exception e) {
        LOGGER.fatal(e.getMessage(), e);
        return;
    }
}

19 View Complete Implementation : LoggingReceiver.java
Copyright GNU Lesser General Public License v2.1
Author : JVoiceXML
/**
 * Sets the current session.
 *
 * @param current
 *            The current session.
 */
public void setSession(final Session current) {
    session = current;
}

19 View Complete Implementation : GotoDemo.java
Copyright GNU Lesser General Public License v2.1
Author : JVoiceXML
/**
 * The main method.
 *
 * @param args
 *            Command line arguments. None expected.
 */
public static void main(final String[] args) {
    LOGGER.info("Starting the goto demo for JVoiceXML...");
    LOGGER.info("(c) 2019 by JVoiceXML group - " + "http://jvoicexml.sourceforge.net/");
    final GenericClient client = new GenericClient();
    try {
        final URI dialog = GotoDemo.clreplaced.getResource("/helloworld.vxml").toURI();
        Session session = client.call(dialog, "jsapi20", "jsapi20", "desktop");
        session.waitSessionEnd();
        session.hangup();
    } catch (NamingException e) {
        LOGGER.fatal(e.getMessage(), e);
    } catch (NoresourceError e) {
        LOGGER.info("do you have the jsapi20 implementation platform" + " configured?");
        LOGGER.fatal(e.getMessage(), e);
    } catch (ErrorEvent e) {
        LOGGER.fatal(e.getMessage(), e);
    } catch (UnsupportedResourceIdentifierException e) {
        LOGGER.fatal(e.getMessage(), e);
    } catch (URISyntaxException e) {
        LOGGER.fatal(e.getMessage(), e);
    } finally {
        client.close();
    }
}

19 View Complete Implementation : TextCall.java
Copyright GNU Lesser General Public License v2.1
Author : JVoiceXML
/**
 * Call simulates a real telephone call. This is done with creation of a new
 * JVoiceXML session and a TextServer that can be used to notice all events.
 *
 * @author Raphael Groner
 * @author Dirk Schnelle-Walka
 * @since 0.7.7
 */
public final clreplaced TextCall implements Call {

    /**
     * Logger for this clreplaced.
     */
    private static final Logger LOGGER = Logger.getLogger(TextCall.clreplaced);

    /**
     * Known call listeners.
     */
    private final Collection<CallListener> listeners;

    /**
     * The text server.
     */
    private TextServer server;

    /**
     * Used port number.
     */
    private int portNumber;

    /**
     * Buffered messages from JVoiceXml.
     */
    private OutputMessageBuffer outputBuffer;

    /**
     * Monitor to wait until JVoiceXML is ready to accept input.
     */
    private InputMonitor inputMonitor;

    /**
     * The last captured output.
     */
    private SsmlDoreplacedent lastOutput;

    /**
     * The last observed error.
     */
    private JVoiceXMLEvent lastError;

    /**
     * Server port number to use. Port number must be greater than 1024.
     */
    public static final int DEFAULT_SERVER_PORT = 6000;

    /**
     * The active session.
     */
    private Session session;

    /**
     * Constructs a new object with the default server port.
     *
     * @throws InterruptedException
     *             error initializing the output buffer
     */
    public TextCall() throws InterruptedException {
        this(DEFAULT_SERVER_PORT);
    }

    /**
     * Constructs a new call.
     *
     * @param hostname
     *            the host name to use for the {@link TextServer}
     * @param port
     *            number to use for the {@link TextServer}.
     * @throws InterruptedException
     *             error initializing the output buffer
     */
    public TextCall(final String hostname, final int port) throws InterruptedException {
        portNumber = port;
        server = new TextServer(hostname, portNumber);
        server.setAutoAcknowledge(false);
        outputBuffer = new OutputMessageBuffer(server);
        server.addTextListener(outputBuffer);
        inputMonitor = new InputMonitor();
        server.addTextListener(inputMonitor);
        listeners = new java.util.ArrayList<CallListener>();
    }

    /**
     * Constructs a new call.
     *
     * @param port
     *            number to use for the {@link TextServer}.
     * @throws InterruptedException
     *             error initializing the output buffer
     */
    public TextCall(final int port) throws InterruptedException {
        this(null, port);
    }

    /**
     * Adds the given listener of messages received from the JVoiceXML. This
     * allows for further investigation of the behavior.
     *
     * @param listener
     *            the listener to add
     */
    public void addTextListener(final TextListener listener) {
        server.addTextListener(listener);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void call(final File file) {
        final URI uri = file.toURI();
        call(uri);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void call(final URI uri) {
        LOGGER.info("calling '" + uri + "'");
        try {
            lastError = null;
            final Context context = new InitialContext();
            final JVoiceXml jvxml = (JVoiceXml) context.lookup("JVoiceXml");
            // Start the text server
            server.start();
            server.waitStarted();
            // run the dialog
            final ConnectionInformation info = server.getConnectionInformation();
            session = jvxml.createSession(info);
            session.call(uri);
            for (CallListener listener : listeners) {
                listener.called(uri);
            }
        } catch (Exception | ErrorEvent e) {
            final replacedertionError error = new replacedertionError(e.getMessage(), e);
            notifyError(error);
            throw error;
        }
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public SsmlDoreplacedent getNextOutput() {
        replacedert.replacedertNotNull("no active session", session);
        try {
            lastOutput = outputBuffer.nextMessage();
            for (CallListener listener : listeners) {
                listener.heard(lastOutput);
            }
            LOGGER.info("heard '" + lastOutput + "'");
            return lastOutput;
        } catch (InterruptedException | JVoiceXMLEvent | IOException e) {
            try {
                lastError = session.getLastError();
            } catch (ErrorEvent ex) {
                final replacedertionError error = new replacedertionError(ex);
                notifyError(error);
                throw error;
            }
            if (lastError != null) {
                final replacedertionError error = new replacedertionError(lastError);
                notifyError(error);
                throw error;
            }
            final replacedertionError error = new replacedertionError(e);
            notifyError(error);
            throw error;
        }
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public SsmlDoreplacedent getNextOutput(final long timeout) {
        replacedert.replacedertNotNull("no active session", session);
        try {
            lastOutput = outputBuffer.nextMessage(timeout);
            replacedert.replacedertNotNull("Received SSML must not be null", lastOutput);
            for (CallListener listener : listeners) {
                listener.heard(lastOutput);
            }
            LOGGER.info("heard '" + lastOutput + "'");
            return lastOutput;
        } catch (InterruptedException | TimeoutException | JVoiceXMLEvent | IOException e) {
            try {
                lastError = session.getLastError();
            } catch (ErrorEvent ex) {
                final replacedertionError error = new replacedertionError(ex);
                notifyError(error);
                throw error;
            }
            if (lastError != null) {
                final replacedertionError error = new replacedertionError(lastError);
                notifyError(error);
                throw error;
            }
            final replacedertionError error = new replacedertionError(e);
            notifyError(error);
            throw error;
        }
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public SsmlDoreplacedent getLastOutput() {
        return lastOutput;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void hears(final String utterance) {
        replacedert.replacedertNotNull("no active session", session);
        final SsmlDoreplacedent doreplacedent = getNextOutput();
        replacedert.replacedertNotNull("Received SSML must not be null", doreplacedent);
        final Speak speak = doreplacedent.getSpeak();
        final String output = speak.getTextContent();
        replacedert.replacedertEquals(utterance, output);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void hears(final String utterance, final long timeout) {
        replacedert.replacedertNotNull("no active session", session);
        final SsmlDoreplacedent doreplacedent = getNextOutput(timeout);
        replacedert.replacedertNotNull("Received SSML must not be null", doreplacedent);
        final Speak speak = doreplacedent.getSpeak();
        final String output = speak.getTextContent();
        replacedert.replacedertEquals(utterance, output);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void hearsAudio(final URI uri) {
        replacedert.replacedertNotNull("no active session", session);
        final SsmlDoreplacedent doreplacedent = getNextOutput();
        replacedert.replacedertNotNull("Received SSML must not be null", doreplacedent);
        replacedertAudioSource(doreplacedent, uri);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void hearsAudio(final URI uri, final long timeout) {
        replacedert.replacedertNotNull("no active session", session);
        final SsmlDoreplacedent doreplacedent = getNextOutput(timeout);
        replacedert.replacedertNotNull("Received SSML must not be null", doreplacedent);
        replacedertAudioSource(doreplacedent, uri);
    }

    /**
     * Checks if the given URI is in the source attribute of the received audio.
     *
     * @param doreplacedent
     *            the doreplacedent to check
     * @param uri
     *            the expected audio source URI
     */
    private void replacedertAudioSource(final SsmlDoreplacedent doreplacedent, final URI uri) {
        final VoiceXmlUnitNamespaceContext context = new VoiceXmlUnitNamespaceContext();
        context.addPrefix("ssml", Speak.DEFAULT_XMLNS);
        try {
            XPathreplacedert.replacedertEquals(context, doreplacedent, "/ssml:speak/ssml:audio/@src", uri.toString());
        } catch (XPathExpressionException e) {
            replacedert.fail(e.getMessage());
        }
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void say(final String utterance) {
        say(utterance, 0);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void say(final String utterance, final long timeout) {
        replacedert.replacedertNotNull("no active session", session);
        try {
            if (timeout == 0) {
                inputMonitor.waitUntilExpectingInput();
            } else {
                inputMonitor.waitUntilExpectingInput(timeout);
            }
            server.sendInput(utterance);
            for (CallListener listener : listeners) {
                listener.said(utterance);
            }
            LOGGER.info("say '" + utterance + "'");
        } catch (InterruptedException | IOException | TimeoutException | JVoiceXMLEvent e) {
            try {
                lastError = session.getLastError();
            } catch (ErrorEvent ex) {
                final replacedertionError error = new replacedertionError(ex);
                notifyError(error);
                throw error;
            }
            if (lastError != null) {
                final replacedertionError error = new replacedertionError(lastError);
                notifyError(error);
                throw error;
            }
            final replacedertionError error = new replacedertionError(e);
            notifyError(error);
            throw error;
        }
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void enter(final String digits) {
        replacedert.replacedertNotNull("no active session", session);
        DtmfInput input = null;
        try {
            inputMonitor.waitUntilExpectingInput();
            input = session.getDtmfInput();
        } catch (JVoiceXMLEvent | InterruptedException | TimeoutException e) {
            throw new replacedertionError(e);
        }
        for (int i = 0; i < digits.length(); i++) {
            final char ch = digits.charAt(i);
            input.addDtmf(ch);
        }
        for (CallListener listener : listeners) {
            listener.entered(digits);
        }
        LOGGER.info("entered '" + digits + "'");
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void enter(final String digits, final long timeout) {
        replacedert.replacedertNotNull("no active session", session);
        DtmfInput input = null;
        try {
            if (timeout == 0) {
                inputMonitor.waitUntilExpectingInput();
            } else {
                inputMonitor.waitUntilExpectingInput(timeout);
            }
            input = session.getDtmfInput();
        } catch (JVoiceXMLEvent | InterruptedException | TimeoutException e) {
            throw new replacedertionError(e);
        }
        for (int i = 0; i < digits.length(); i++) {
            final char ch = digits.charAt(i);
            input.addDtmf(ch);
        }
        for (CallListener listener : listeners) {
            listener.entered(digits);
        }
        LOGGER.info("entered '" + digits + "'");
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void waitUnitExpectingInput() {
        replacedert.replacedertNotNull("no active session", session);
        try {
            inputMonitor.waitUntilExpectingInput();
        } catch (InterruptedException | TimeoutException | JVoiceXMLEvent e) {
            try {
                lastError = session.getLastError();
            } catch (ErrorEvent ex) {
                final replacedertionError error = new replacedertionError(ex);
                notifyError(error);
                throw error;
            }
            if (lastError != null) {
                final replacedertionError error = new replacedertionError(lastError);
                notifyError(error);
                throw error;
            }
            final replacedertionError error = new replacedertionError(e);
            notifyError(error);
            throw error;
        }
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void waitUnitExpectingInput(final long timeout) {
        replacedert.replacedertNotNull("no active session", session);
        try {
            if (timeout == 0) {
                inputMonitor.waitUntilExpectingInput();
            } else {
                inputMonitor.waitUntilExpectingInput(timeout);
            }
        } catch (InterruptedException | TimeoutException | JVoiceXMLEvent e) {
            try {
                lastError = session.getLastError();
            } catch (ErrorEvent ex) {
                final replacedertionError error = new replacedertionError(ex);
                notifyError(error);
                throw error;
            }
            if (lastError != null) {
                final replacedertionError error = new replacedertionError(lastError);
                notifyError(error);
                throw error;
            }
            final replacedertionError error = new replacedertionError(e);
            notifyError(error);
            throw error;
        }
    }

    /**
     * Notifies all listeners about the given error.
     *
     * @param error
     *            the caught error
     */
    private void notifyError(final replacedertionError error) {
        for (CallListener listener : listeners) {
            listener.error(error);
        }
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void hangup() {
        if (outputBuffer.hasReceivedDisconnect()) {
            try {
                outputBuffer.acknowledgeBye();
            } catch (InterruptedException | IOException e) {
                if (LOGGER.isDebugEnabled()) {
                    LOGGER.debug("error acknowledging a BYE", e);
                }
            }
        }
        if (session != null) {
            session.hangup();
            for (CallListener listener : listeners) {
                listener.hungup();
            }
            LOGGER.info("remote hungup");
            session = null;
        }
        server.stopServer();
        LOGGER.info("server stopped");
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public JVoiceXMLEvent getLastError() {
        if (session != null) {
            try {
                return session.getLastError();
            } catch (ErrorEvent e) {
                return lastError;
            }
        }
        return lastError;
    }
}

19 View Complete Implementation : BaseCallManager.java
Copyright GNU Lesser General Public License v2.1
Author : JVoiceXML
/**
 * {@inheritDoc}
 */
@Override
public final void terminalDisconnected(final Terminal terminal) {
    synchronized (sessions) {
        final Session session = sessions.get(terminal);
        if (session == null) {
            return;
        }
        session.hangup();
        sessions.remove(terminal);
        LOGGER.info("hung up session for terminal '" + terminal.getName() + "'");
    }
}

19 View Complete Implementation : LUISDemo.java
Copyright GNU Lesser General Public License v2.1
Author : JVoiceXML
/**
 * Call the voicexml interpreter context to process the given xml doreplacedent.
 *
 * @param uri
 *            uri of the first doreplacedent to load
 * @exception JVoiceXMLEvent
 *                Error processing the call.
 * @throws InterruptedException
 * @throws IOException
 */
private void interpretDoreplacedent(final URI uri) throws JVoiceXMLEvent, InterruptedException, IOException {
    final JVoiceXml jvxml;
    try {
        jvxml = (JVoiceXml) context.lookup(JVoiceXml.clreplaced.getSimpleName());
    } catch (javax.naming.NamingException ne) {
        LOGGER.error("error obtaining JVoiceXml", ne);
        return;
    }
    if (jvxml == null) {
        LOGGER.error("unable to obtain a referece to JVoiceXML");
        return;
    }
    final ConnectionInformation client = server.getConnectionInformation();
    final Session session = jvxml.createSession(client);
    session.call(uri);
    synchronized (lock) {
        lock.wait();
    }
    server.sendInput("I want a large pizza with salami");
    synchronized (lock) {
        lock.wait();
    }
    server.sendInput("yes");
    session.waitSessionEnd();
    session.hangup();
}

19 View Complete Implementation : MMIContext.java
Copyright GNU Lesser General Public License v2.1
Author : JVoiceXML
/**
 * Sets the session.
 * @param sess the session.
 */
public void setSession(final Session sess) {
    session = sess;
}

19 View Complete Implementation : MixedInitiativeDemo.java
Copyright GNU Lesser General Public License v2.1
Author : JVoiceXML
/**
 * Call the voicexml interpreter context to process the given xml doreplacedent.
 *
 * @param uri
 *            uri of the first doreplacedent to load
 * @exception JVoiceXMLEvent
 *                Error processing the call.
 */
private void interpretDoreplacedent(final URI uri) throws JVoiceXMLEvent {
    final JVoiceXml jvxml;
    try {
        jvxml = (JVoiceXml) context.lookup("JVoiceXml");
    } catch (javax.naming.NamingException ne) {
        LOGGER.error("error obtaining JVoiceXml", ne);
        return;
    }
    final ConnectionInformation client = new BasicConnectionInformation("desktop", "jsapi20", "jsapi20");
    final Session session = jvxml.createSession(client);
    session.call(uri);
    session.waitSessionEnd();
    session.hangup();
}

19 View Complete Implementation : TestParamParser.java
Copyright GNU Lesser General Public License v2.1
Author : JVoiceXML
/**
 * Test case for {@link org.jvoicexml.interpreter.ParamParser}.
 *
 * @author Dirk Schnelle-Walka
 * @version $Revision$
 * @since 0.6
 */
public final clreplaced TestParamParser {

    /**
     * Mapped doreplacedent repository.
     */
    private DoreplacedentMap map;

    /**
     * The server object to test.
     */
    private JVoiceXmlDoreplacedentServer server;

    /**
     * the current session id.
     */
    private Session session;

    /**
     * {@inheritDoc}
     */
    @Before
    public void setUp() throws Exception {
        map = DoreplacedentMap.getInstance();
        server = new JVoiceXmlDoreplacedentServer();
        server.addSchemeStrategy(new MappedDoreplacedentStrategy());
        server.setDoreplacedentStorage(Mockito.mock(DoreplacedentStorage.clreplaced));
        server.start();
        final ImplementationPlatform platform = new MockImplementationPlatform();
        final JVoiceXmlCore jvxml = Mockito.mock(JVoiceXmlCore.clreplaced);
        final Configuration configuration = Mockito.mock(Configuration.clreplaced);
        Mockito.when(jvxml.getConfiguration()).thenReturn(configuration);
        final Profile profile = Mockito.mock(Profile.clreplaced);
        final SsmlParsingStrategyFactory factory = Mockito.mock(SsmlParsingStrategyFactory.clreplaced);
        Mockito.when(profile.getSsmlParsingStrategyFactory()).thenReturn(factory);
        session = new JVoiceXmlSession(platform, jvxml, null, profile);
    }

    /**
     * Test method for
     * {@link org.jvoicexml.interpreter.ParamParser#getParameters()}.
     *
     * @exception Exception
     *                Test failed.
     * @exception JVoiceXMLEvent
     *                Test failed.
     */
    @Test
    public void testGetParameters() throws Exception, JVoiceXMLEvent {
        String test = "actor";
        final URI uri = map.getUri("/test");
        map.addDoreplacedent(uri, test);
        final DataModel model = Mockito.mock(DataModel.clreplaced);
        Mockito.when(model.evaluateExpression("last", Object.clreplaced)).thenReturn("Buchholz");
        final VoiceXmlDoreplacedent doc = new VoiceXmlDoreplacedent();
        final Vxml vxml = doc.getVxml();
        final Form form = vxml.appendChild(Form.clreplaced);
        final ObjectTag object = form.appendChild(ObjectTag.clreplaced);
        final Param param1 = object.appendChild(Param.clreplaced);
        param1.setName("firstname");
        param1.setValue("Horst");
        final Param param2 = object.appendChild(Param.clreplaced);
        param2.setName("lastname");
        param2.setExpr("last");
        final Param param3 = object.appendChild(Param.clreplaced);
        param3.setName("job");
        param3.setValue(uri.toString());
        param3.setValuetype(ParamValueType.REF);
        param3.setType("text/plain");
        final ParamParser parser = new ParamParser(object, model, server, session);
        final Map<String, Object> params = parser.getParameters();
        replacedert.replacedertEquals("Horst", params.get("firstname"));
        replacedert.replacedertEquals("Buchholz", params.get("lastname"));
        replacedert.replacedertEquals(test, params.get("job"));
    }

    /**
     * Test method for
     * {@link org.jvoicexml.interpreter.ParamParser#getParameters()}.
     *
     * @exception Exception
     *                Test failed.
     * @exception JVoiceXMLEvent
     *                Test failed.
     */
    @Test
    public void testGetParametersErrorBadFetch() throws Exception, JVoiceXMLEvent {
        final VoiceXmlDoreplacedent doc = new VoiceXmlDoreplacedent();
        final Vxml vxml = doc.getVxml();
        final Form form = vxml.appendChild(Form.clreplaced);
        final ObjectTag object = form.appendChild(ObjectTag.clreplaced);
        final Param param1 = object.appendChild(Param.clreplaced);
        param1.setName("firstname");
        param1.setValue("Horst");
        object.appendChild(Param.clreplaced);
        final ParamParser parser = new ParamParser(object, null, server, session);
        BadFetchError error = null;
        try {
            parser.getParameters();
        } catch (BadFetchError e) {
            error = e;
        }
        replacedert.replacedertNotNull("ParamParser should have thrown an error.badfetch", error);
    }

    /**
     * Test method for
     * {@link org.jvoicexml.interpreter.ParamParser#getParameters()}.
     *
     * @exception Exception
     *                Test failed.
     * @exception JVoiceXMLEvent
     *                Test failed.
     */
    @Test
    public void testGetParametersInvalidUri() throws Exception, JVoiceXMLEvent {
        final DataModel model = Mockito.mock(DataModel.clreplaced);
        Mockito.when(model.evaluateExpression("last", Object.clreplaced)).thenReturn("Buchholz");
        final VoiceXmlDoreplacedent doc = new VoiceXmlDoreplacedent();
        final Vxml vxml = doc.getVxml();
        final Form form = vxml.appendChild(Form.clreplaced);
        final ObjectTag object = form.appendChild(ObjectTag.clreplaced);
        final Param param1 = object.appendChild(Param.clreplaced);
        param1.setName("firstname");
        param1.setValue("Horst");
        final Param param2 = object.appendChild(Param.clreplaced);
        param2.setName("lastname");
        param2.setExpr("last");
        final Param param3 = object.appendChild(Param.clreplaced);
        param3.setName("job");
        param3.setValue("%invaliduri%");
        param3.setValuetype(ParamValueType.REF);
        param3.setType("text/plain");
        final ParamParser parser = new ParamParser(object, model, server, session);
        BadFetchError error = null;
        try {
            parser.getParameters();
        } catch (BadFetchError e) {
            error = e;
        }
        replacedert.replacedertNotNull("ParamParser should have thrown an error.badfetch", error);
    }

    /**
     * Test method for
     * {@link org.jvoicexml.interpreter.ParamParser#getParameterValues()}.
     *
     * @exception Exception
     *                Test failed.
     * @exception JVoiceXMLEvent
     *                Test failed.
     */
    @Test
    public void testGetParameterValues() throws Exception, JVoiceXMLEvent {
        String test = "actor";
        final URI uri = map.getUri("/test");
        map.addDoreplacedent(uri, test);
        final DataModel model = Mockito.mock(DataModel.clreplaced);
        Mockito.when(model.evaluateExpression("last", Object.clreplaced)).thenReturn("Buchholz");
        final VoiceXmlDoreplacedent doc = new VoiceXmlDoreplacedent();
        final Vxml vxml = doc.getVxml();
        final Form form = vxml.appendChild(Form.clreplaced);
        final ObjectTag object = form.appendChild(ObjectTag.clreplaced);
        final Param param1 = object.appendChild(Param.clreplaced);
        param1.setName("firstname");
        param1.setValue("Horst");
        final Param param2 = object.appendChild(Param.clreplaced);
        param2.setName("lastname");
        param2.setExpr("last");
        final Param param3 = object.appendChild(Param.clreplaced);
        param3.setName("job");
        param3.setValue(uri.toString());
        param3.setValuetype(ParamValueType.REF);
        param3.setType("text/plain");
        final ParamParser parser = new ParamParser(object, model, server, session);
        final Collection<Object> params = parser.getParameterValues();
        replacedert.replacedertEquals(3, params.size());
        final Iterator<Object> iterator = params.iterator();
        replacedert.replacedertEquals("Horst", iterator.next());
        replacedert.replacedertEquals("Buchholz", iterator.next());
        replacedert.replacedertEquals(test, iterator.next());
    }
}

19 View Complete Implementation : RecordDemo.java
Copyright GNU Lesser General Public License v2.1
Author : JVoiceXML
/**
 * The main method.
 *
 * @param args
 *            Command line arguments. None expected.
 */
public static void main(final String[] args) {
    LOGGER.info("Starting 'record' demo for JVoiceXML...");
    LOGGER.info("(c) 2008-2017 by JVoiceXML group - " + "http://jvoicexml.sourceforge.net/");
    final GenericClient client = new GenericClient();
    try {
        final URI uri = RecordDemo.clreplaced.getResource("/record.vxml").toURI();
        Session session = client.call(uri, "jsapi20", "mary", "desktop");
        session.waitSessionEnd();
        session.hangup();
    } catch (NamingException e) {
        LOGGER.fatal(e.getMessage(), e);
    } catch (NoresourceError e) {
        LOGGER.info("do you have the jsapi20 implementation platform" + " configured?");
        LOGGER.fatal(e.getMessage(), e);
    } catch (ErrorEvent e) {
        LOGGER.fatal(e.getMessage(), e);
    } catch (UnsupportedResourceIdentifierException e) {
        LOGGER.fatal(e.getMessage(), e);
    } catch (URISyntaxException e) {
        LOGGER.fatal(e.getMessage(), e);
    } finally {
        client.close();
    }
}

19 View Complete Implementation : TestMMICallManager.java
Copyright GNU Lesser General Public License v2.1
Author : JVoiceXML
/**
 * Test for {@link MMICallManager#createSession(java.net.URI)}.
 * @exception Exception
 *            test failed
 * @exception JVoiceXMLEvent
 *            test failed
 */
@Test
public void testCreateSession() throws Exception, JVoiceXMLEvent {
    final Session session = cm.createSession(null);
    replacedert.replacedertNotNull(session);
    cm.cleanupSession(session);
}

19 View Complete Implementation : SimpleInputDemo.java
Copyright GNU Lesser General Public License v2.1
Author : JVoiceXML
/**
 * The main method.
 * @param args Command line arguments. None expected.
 */
public static void main(final String[] args) {
    LOGGER.info("Starting 'simple input' demo for JVoiceXML...");
    LOGGER.info("(c) 2014-2017 by JVoiceXML group - " + "http://jvoicexml.sourceforge.net/");
    final GenericClient client = new GenericClient();
    try {
        final URI dialog = SimpleInputDemo.clreplaced.getResource("/simpleexample.vxml").toURI();
        final Session session = client.call(dialog, "jsapi20", "jsapi20", "desktop");
        session.waitSessionEnd();
        session.hangup();
    } catch (NamingException e) {
        LOGGER.fatal(e.getMessage(), e);
    } catch (NoresourceError e) {
        LOGGER.info("do you have the jsapi20 implementation platform" + " configured?");
        LOGGER.fatal(e.getMessage(), e);
    } catch (ErrorEvent e) {
        LOGGER.fatal(e.getMessage(), e);
    } catch (UnsupportedResourceIdentifierException e) {
        LOGGER.fatal(e.getMessage(), e);
    } catch (URISyntaxException e) {
        LOGGER.fatal(e.getMessage(), e);
    } finally {
        client.close();
    }
}

19 View Complete Implementation : BaseCallManager.java
Copyright GNU Lesser General Public License v2.1
Author : JVoiceXML
/**
 * Creates a session for the given terminal and initiates a call at
 * JVoiceXml.
 *
 * @param term
 *            the connecting terminal
 * @param parameters
 *            additional parameters
 * @return created session.
 * @exception ErrorEvent
 *                Error creating the session.
 */
public final Session createSession(final org.jvoicexml.callmanager.Terminal term, final CallParameters parameters) throws ErrorEvent {
    final String name = term.getName();
    final ConfiguredApplication application = applications.get(name);
    if (application == null) {
        throw new BadFetchError("No application defined for terminal '" + name + "'");
    }
    parameters.setTerminal(term);
    final ConnectionInformation remote;
    try {
        remote = clientFactory.createConnectionInformation(this, application, parameters);
    } catch (ConnectionInformationCreationException e) {
        throw new NoresourceError(e.getMessage(), e);
    }
    // Create a session and initiate a call at JVoiceXML.
    final Session session = jvxml.createSession(remote);
    final URI uri = application.getUriObject();
    session.call(uri);
    return session;
}

19 View Complete Implementation : JVoiceXmlBrowser.java
Copyright GNU Lesser General Public License v2.1
Author : JVoiceXML
/**
 * Interface to the JVoiceXml VoiceXML browser.
 *
 * @author Dirk Schnelle-Walka
 * @author Aurelian Maga
 */
public final clreplaced JVoiceXmlBrowser implements IVoiceXMLBrowser {

    /**
     * Reference to the related browserProcess.
     */
    protected VoiceXMLBrowserProcess browserProcess;

    /**
     * URL of the application to launch.
     */
    private String launchUrl;

    /**
     * Location of the security policy.
     */
    private String policy;

    /**
     * RMI provider URL.
     */
    private String providerUrl;

    /**
     * Initial context factory for JNDI.
     */
    private String initialContextFactory;

    /**
     * Receiver port.
     */
    private int port;

    /**
     * Debugging level.
     */
    private String level;

    /**
     * The current session.
     */
    private Session session;

    /**
     * The remote connection information
     */
    private ConnectionInformation info;

    /**
     * Text client port number
     */
    private int textPort;

    /**
     * The text server
     */
    private TextServer textServer;

    /**
     * Constructs a new object.
     */
    public JVoiceXmlBrowser() {
    }

    /**
     * Retrieves the inital context.
     *
     * @return The initial context to use, <code>null</code> in case of an
     *         error.
     */
    private Context getContext() {
        logMessage("obtaining the initial context...");
        /**
         * @todo Find a better solution to set the system properties.
         */
        System.setProperty("java.security.policy", policy);
        final Hashtable<String, String> env = new Hashtable<String, String>();
        env.put(Context.INITIAL_CONTEXT_FACTORY, initialContextFactory);
        env.put(Context.PROVIDER_URL, providerUrl);
        env.put("java.naming.rmi.security.manager", "true");
        final Context context;
        try {
            context = new InitialContext(env);
        } catch (javax.naming.NamingException ne) {
            ne.printStackTrace();
            logMessage(ne.getMessage());
            return null;
        }
        logMessage("got initial context");
        return context;
    }

    private void startTextServer() {
        logMessage("starting text server...");
        textServer = new TextServer(textPort);
        final TextServerListener textServerListener = new TextServerListener(this);
        textServer.addTextListener(textServerListener);
        textServer.start();
        logMessage("text server started");
    }

    private ConnectionInformation getClient() {
        ConnectionInformation info = null;
        try {
            info = textServer.getConnectionInformation();
        } catch (UnknownHostException uhe) {
            logMessage(uhe.getMessage());
        }
        return info;
    }

    private Session getSession(final Context context, ConnectionInformation info) {
        logMessage("creating a JVoiceXML session...");
        final JVoiceXml jvxml;
        try {
            jvxml = (JVoiceXml) context.lookup("JVoiceXml");
        } catch (javax.naming.NamingException ne) {
            Throwable root = ne.getRootCause();
            if (root == null) {
                logMessage(ne.getMessage());
            } else {
                logMessage(root.getMessage());
            }
            return null;
        }
        try {
            return jvxml.createSession(info);
        } catch (ErrorEvent ee) {
            logMessage(ee.getMessage());
            return null;
        }
    }

    /**
     * Calls the voicexml interpreter context to process the given application.
     *
     * @param context
     *            The current JNDI context.
     */
    private void interpret(final Context context) {
        logMessage("calling application...");
        final URI uri;
        try {
            uri = new URI(launchUrl);
        } catch (java.net.URISyntaxException use) {
            logMessage(use.getMessage());
            return;
        }
        try {
            session.call(uri);
            final SessionListener listener = new SessionListener(session, this);
            listener.start();
        } catch (org.jvoicexml.event.JVoiceXMLEvent e) {
            e.printStackTrace();
        }
    }

    /**
     * Starts the logging receiver.
     *
     * @return Started logging receiver.
     */
    private LoggingReceiver startLoggingReceiver() {
        logMessage("starting logging receiver...");
        final JVoiceXmlPlugin plugin = JVoiceXmlPlugin.getDefault();
        final LoggingReceiver receiver = plugin.getReceiver();
        receiver.setBrowser(this);
        receiver.setSession(session);
        receiver.setLevel(level);
        if (!receiver.connect(port)) {
            return null;
        }
        if (!receiver.isStarted()) {
            final Thread thread = new Thread(receiver);
            thread.setDaemon(true);
            thread.start();
        }
        logMessage("logging receiver started");
        return receiver;
    }

    /**
     * {@inheritDoc}
     */
    public void start() {
        final Context context = getContext();
        if (context == null) {
            return;
        }
        startTextServer();
        info = getClient();
        if (info == null) {
            stop();
            return;
        }
        session = getSession(context, info);
        if (session == null) {
            stop();
            return;
        }
        startLoggingReceiver();
        interpret(context);
    }

    /**
     * {@inheritDoc}
     */
    public void stop() {
        if (browserProcess == null) {
            return;
        }
        if (textServer != null) {
            textServer.stopServer();
        }
        final JVoiceXmlPlugin plugin = JVoiceXmlPlugin.getDefault();
        final LoggingReceiver receiver = plugin.getReceiver();
        receiver.close();
        receiver.setBrowser(null);
        try {
            if (session != null) {
                logMessage("stopping session...");
                session.hangup();
                session = null;
                logMessage("session closed");
            }
        } catch (Exception e) {
            logMessage(e.getMessage());
        } finally {
            final DebugEvent[] event = new DebugEvent[2];
            event[0] = new DebugEvent(browserProcess, DebugEvent.TERMINATE);
            event[1] = new DebugEvent(browserProcess.getLaunch(), DebugEvent.CHANGE);
            DebugPlugin.getDefault().fireDebugEventSet(event);
            browserProcess.setTerminated(true);
        }
    }

    /**
     * {@inheritDoc}
     */
    public void sendInput(final VoiceXMLBrowserInput input) {
        int inputType = input.getInputType();
        if (inputType == VoiceXMLBrowserInput.TYPE_DTMF) {
            final String dtmf = input.getInput().toString();
            sendDtmf(dtmf);
        } else if (inputType == VoiceXMLBrowserInput.TYPE_VOICE) {
            final String text = input.getInput().toString();
            sendText(text);
        }
    }

    /**
     * Sends the DTMF to the browser.
     *
     * @param dtmf
     *            The DTMF to send.
     */
    private void sendDtmf(final String dtmf) {
        final DtmfInput input;
        try {
            input = session.getDtmfInput();
        } catch (NoresourceError nre) {
            logMessage(nre.getMessage());
            return;
        } catch (ConnectionDisconnectHangupEvent e) {
            logMessage(e.getMessage());
            return;
        }
        final char dtmfChar = dtmf.charAt(0);
        input.addDtmf(dtmfChar);
    }

    /**
     * Sends the TEXT to the browser.
     *
     * @param text
     *            The TEXT to send.
     */
    private void sendText(final String text) {
        try {
            textServer.sendInput(text);
        } catch (IOException ioe) {
            logMessage(ioe.getMessage());
            return;
        }
    }

    /**
     * {@inheritDoc}
     */
    public void setProperty(final String name, final Object value) {
        if (IVoiceXMLBrowserConstants.LAUNCH_URL.equals(name)) {
            launchUrl = value.toString();
        } else if (JVoiceXmlPluginConstants.JNDI_POLICY.equals(name)) {
            policy = value.toString();
        } else if (JVoiceXmlPluginConstants.JNDI_CONTEXT_FACTORY.equals(name)) {
            initialContextFactory = value.toString();
        } else if (JVoiceXmlPluginConstants.JNDI_PROVIDER_URL.equals(name)) {
            providerUrl = value.toString();
        } else if (JVoiceXmlPluginConstants.LOGGING_PORT.equals(name)) {
            final Integer configuredPort = (Integer) value;
            port = configuredPort.intValue();
        } else if (JVoiceXmlPluginConstants.LOGGING_LEVEL.equals(name)) {
            level = value.toString();
        } else if (JVoiceXmlPluginConstants.TEXT_PORT.equals(name)) {
            final Integer configuredPort = (Integer) value;
            textPort = configuredPort.intValue();
        }
    }

    /**
     * {@inheritDoc}
     */
    public boolean hasCapability(final String capability) {
        if (IVoiceXMLBrowser.CAPABILITY_LOG_EVENT.equals(capability)) {
            return true;
        } else if (IVoiceXMLBrowser.CAPABILITY_INTERACTIVE.equals(capability)) {
            return true;
        } else if (IVoiceXMLBrowser.CAPABILITY_DTMF.equals(capability)) {
            return true;
        }
        return false;
    }

    /**
     * {@inheritDoc}
     */
    public void setProcess(final VoiceXMLBrowserProcess process) {
        browserProcess = process;
    }

    /**
     * {@inheritDoc}
     */
    public VoiceXMLBrowserProcess getProcess() {
        return browserProcess;
    }

    /**
     * Convenience method to send a log message to the debug panel.
     *
     * @param date
     *            Logging time stamp.
     * @param message
     *            The message.
     */
    void logMessage(final Date date, final String message) {
        final DebugEvent[] event = new DebugEvent[1];
        event[0] = new DebugEvent(this, DebugEvent.MODEL_SPECIFIC, IVoiceXMLBrowserConstants.EVENT_LOG_MESSAGE);
        final VoiceXMLLogMessage log = new VoiceXMLLogMessage(date, message);
        event[0].setData(log);
        DebugPlugin.getDefault().fireDebugEventSet(event);
    }

    /**
     * Convenience method to send a log message to the debug panel.
     *
     * @param message
     *            The message.
     */
    void logMessage(final String message) {
        if (message == null) {
            return;
        }
        final Date now = new Date();
        logMessage(now, message);
    }

    @Override
    public void hangup() {
        if (session == null) {
            return;
        }
        logMessage("hanging up...");
        session.hangup();
        session = null;
    }
}

19 View Complete Implementation : GenericClient.java
Copyright GNU Lesser General Public License v2.1
Author : JVoiceXML
/**
 * Calls JVoiceXML with the given URI and the specified platform
 * configuration.
 * @param uri the URI to call
 * @param info the connection information to use.
 * @return JVoiceXML session for the call
 * @throws NamingException
 *         JVoiceXML server could not be found.
 * @throws ErrorEvent
 *         if an error occurs when calling JVoiceXML
 */
public Session call(final URI uri, final ConnectionInformation info) throws NamingException, ErrorEvent {
    final JVoiceXml jvoicexml = getJVoiceXml();
    if (jvoicexml == null) {
        throw new NoresourceError("JVoiceXML server could not be found");
    }
    final Session session = jvoicexml.createSession(info);
    if (session == null) {
        throw new NoresourceError("Session unavailable, no usable implementation");
    } else {
        session.call(uri);
    }
    return session;
}

19 View Complete Implementation : HelloWorldDemo.java
Copyright GNU Lesser General Public License v2.1
Author : JVoiceXML
/**
 * The main method.
 * @param args Command line arguments. None expected.
 */
public static void main(final String[] args) {
    LOGGER.info("Starting 'hello world' demo for JVoiceXML...");
    LOGGER.info("(c) 2005-2012 by JVoiceXML group - " + "http://jvoicexml.sourceforge.net/");
    // final GenericClient client = new GenericClient();
    final File file = new File("conf/jvxml/vxml/CRBTPromotion.vxml");
    // final File file = new File("conf/jvxml/vxml/CRBTPromotion.vxml");
    final URI dialog = file.toURI();
    try {
        org.util.ExLog.debug("hello you");
        final ConnectionInformation client = new BasicConnectionInformation("mobicents", "mobicents", "mobicents");
        // Session session = client.call(dialog, "jsapi10", "jsapi10",
        // "desktop");
        Context context = new InitialContext();
        JVoiceXml jvxml = (JVoiceXml) context.lookup("JVoiceXml");
        final Session session = jvxml.createSession(client);
        session.call(dialog);
        Thread.sleep(10000);
        session.waitSessionEnd();
        session.hangup();
        System.out.println();
    } catch (NamingException e) {
        LOGGER.fatal(e.getMessage(), e);
        return;
    } catch (ErrorEvent e) {
        LOGGER.fatal(e.getMessage(), e);
        return;
    } catch (Exception e) {
        LOGGER.fatal(e.getMessage(), e);
        return;
    }
}

19 View Complete Implementation : LoggingReceiver.java
Copyright GNU Lesser General Public License v2.1
Author : JVoiceXML
/**
 * Server for <code>LoggingEvent</code>s sent over the socket appender of
 * JVoiceXml.
 *
 * @author Dirk Schnelle
 */
clreplaced LoggingReceiver implements Runnable {

    /**
     * Reference to the browser.
     */
    private JVoiceXmlBrowser browser;

    /**
     * The current session.
     */
    private Session session;

    /**
     * A connected client (JvoiceXml)
     */
    private Socket client;

    /**
     * The level to monitor.
     */
    private Level level;

    /**
     * Flag, if the thread is started.
     */
    private boolean started;

    /**
     * Constructs a new object.
     */
    public LoggingReceiver() {
        started = false;
    }

    /**
     * Sets the borwoser.
     *
     * @param jvxml
     *            The browser.
     */
    public void setBrowser(JVoiceXmlBrowser jvxml) {
        browser = jvxml;
    }

    /**
     * Sets the current session.
     *
     * @param current
     *            The current session.
     */
    public void setSession(final Session current) {
        session = current;
    }

    /**
     * Sets the minimal logging level.
     *
     * @param lev
     *            The minimal logging level.
     */
    public void setLevel(final String lev) {
        level = Level.toLevel(lev);
    }

    /**
     * Connects to the JVoiceXml socket appender.
     *
     * <p>
     * If the connection is already established, this method returns
     * immediately. Otherwise, a new server socket is opened, waiting for log4j
     * to connect. This may take a while until a timeout of the socket appender
     * occurs to reconnect.
     * </p>
     *
     * @param port
     *            Port to listen at.
     * @return <code>true</code> if a connection could be established.
     */
    public boolean connect(final int port) {
        if (client != null) {
            try {
                client.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        try {
            InetAddress localhost = Inet4Address.getLocalHost();
            client = new Socket(localhost, port);
        } catch (java.io.IOException ioe) {
            ioe.printStackTrace();
            return false;
        }
        browser.logMessage("connected");
        return true;
    }

    /**
     * Checks, if this thread is started.
     *
     * @return <code>true</code> if the thread is started.
     */
    public boolean isStarted() {
        return started;
    }

    /**
     * {@inheritDoc}
     */
    public void run() {
        if (client == null) {
            return;
        }
        started = true;
        try {
            final InputStream in = client.getInputStream();
            final ObjectInputStream oin = new ObjectInputStream(in);
            while (client.isConnected()) {
                final LoggingEvent event = (LoggingEvent) oin.readObject();
                logMessage(event);
            }
            oin.close();
            in.close();
        } catch (java.io.IOException ioe) {
            ioe.printStackTrace();
        } catch (ClreplacedNotFoundException cnfe) {
            cnfe.printStackTrace();
        }
        started = false;
    }

    /**
     * Convenience method to send a log message to the debug pane. The event is
     * displayed, if a session exists and the configured logging level is equal
     * or greater to the level of the <code>logevent</code>.
     *
     * @param logevent
     *            The received logging message.
     */
    private void logMessage(final LoggingEvent logevent) {
        if (session == null) {
            return;
        }
        final String id = session.getSessionID();
        final String threadName = logevent.getThreadName();
        if (!id.equalsIgnoreCase(threadName)) {
            return;
        }
        final Level currentLevel = logevent.getLevel();
        if (!currentLevel.isGreaterOrEqual(level)) {
            return;
        }
        final long timestamp = logevent.timeStamp;
        final Date date = new Date(timestamp);
        final String message = logevent.getMessage().toString();
        browser.logMessage(date, message);
    }

    /**
     * Closes the receiver and all open connections.
     */
    public void close() {
        if (client != null) {
            if (browser != null) {
                browser.logMessage("closing connection...");
            }
            try {
                client.close();
            } catch (java.io.IOException ioe) {
                ioe.printStackTrace();
            } finally {
                client = null;
            }
            if (browser != null) {
                browser.logMessage("...conection closed");
            }
        }
        session = null;
    }
}

19 View Complete Implementation : ConsoleClient.java
Copyright GNU Lesser General Public License v2.1
Author : JVoiceXML
/**
 * Running thread.
 *
 * @param uri
 *            the URI to call
 * @exception Exception
 *                error communicating with JVoiceXML
 * @exception JVoiceXMLEvent
 *                error running the application
 */
private void run(final URI uri) throws Exception, JVoiceXMLEvent {
    final Context context = new InitialContext();
    final JVoiceXml jvxml = (JVoiceXml) context.lookup("JVoiceXml");
    server = new TextServer(4242);
    server.addTextListener(this);
    server.start();
    synchronized (lock) {
        lock.wait();
    }
    LOGGER.info("server started");
    final ConnectionInformation info = server.getConnectionInformation();
    final Session session = jvxml.createSession(info);
    LOGGER.info("calling application at '" + uri + "'...");
    session.call(uri);
}

19 View Complete Implementation : SipCallManagerSession.java
Copyright GNU Lesser General Public License v2.1
Author : JVoiceXML
/**
 * @param jvxmlSession the jvxmlSession to set
 */
public void setJvxmlSession(Session jvxmlSession) {
    this.jvxmlSession = jvxmlSession;
}

19 View Complete Implementation : MMICallManager.java
Copyright GNU Lesser General Public License v2.1
Author : JVoiceXML
/**
 * Creates a session. Created sessions must be cleaned up after the session
 * has ended using {@link #cleanupSession(Session)}.
 *
 * @param data call meta data
 * @return created session
 * @throws ErrorEvent
 *             error creating the session
 * @throws UnsupportedResourceIdentifierException
 *             error in the URI scheme
 */
public Session createSession(final CallMetadata data) throws ErrorEvent, UnsupportedResourceIdentifierException {
    final ConnectionInformationController controller = factory.createConnectionInformation(call, output, input);
    final ConnectionInformation info = controller.getConnectionInformation();
    if (info instanceof ConnectionInformationCallMetadataModifiable) {
        final ConnectionInformationCallMetadataModifiable modifiable = (ConnectionInformationCallMetadataModifiable) info;
        modifiable.setProfile(MmiProfile.NAME);
        modifiable.setCalledDevice(data.getCalledDevice());
        modifiable.setCallingDevice(data.getCallingDevice());
        modifiable.setProtocolName(data.getProtocolName());
        modifiable.setProtocolVersion(data.getProtocolVersion());
    }
    final Session session = jvxml.createSession(info);
    sessions.put(session, controller);
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("session '" + session.getSessionId() + "' created");
    }
    return session;
}

19 View Complete Implementation : SessionSkeleton.java
Copyright GNU Lesser General Public License v2.1
Author : JVoiceXML
/**
 * Skeleton for the {@link Session}.
 *
 * @author Dirk Schnelle-Walka
 * @since 0.4
 * @see org.jvoicexml.Session
 */
final clreplaced SessionSkeleton extends UnicastRemoteObject implements RemoteSession, Skeleton {

    /**
     * The serial version UID.
     */
    private static final long serialVersionUID = 7903915853416003896L;

    /**
     * Logger for this clreplaced.
     */
    private static final Logger LOGGER = LogManager.getLogger(SessionSkeleton.clreplaced);

    /**
     * The encapsulated <code>ApplicationRegistry</code>.
     */
    private Session session;

    /**
     * The JNDI context to use.
     */
    private final Context context;

    /**
     * Constructs a new object.
     *
     * @throws RemoteException
     *             Error creating the remote object.
     */
    SessionSkeleton() throws RemoteException {
        context = null;
    }

    /**
     * Constructs a new object with the given session.
     *
     * @param ctx
     *            the current JNDI context
     * @param sess
     *            The session
     * @throws RemoteException
     *             Error creating the remote object.
     */
    SessionSkeleton(final Context ctx, final Session sess) throws RemoteException {
        context = ctx;
        session = sess;
    }

    /**
     * {@inheritDoc}
     */
    public String getSkeletonName() {
        return RemoteSession.clreplaced.getSimpleName() + "." + session.getSessionId();
    }

    /**
     * {@inheritDoc}
     */
    public Application call(final URI uri) throws RemoteException {
        if (session == null) {
            return null;
        }
        try {
            final Application application = session.call(uri);
            final String id = session.getSessionId();
            final ApplicationSkeleton skeleton = new ApplicationSkeleton(id, application);
            final ApplicationStub stub = new ApplicationStub(id);
            JVoiceXmlJndiSupport.bind(context, skeleton, stub);
            return stub;
        } catch (ErrorEvent event) {
            LOGGER.error(event.getMessage(), event);
            throw new RemoteException(event.getMessage(), event);
        }
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Application getApplication() throws RemoteException {
        if (session == null) {
            return null;
        }
        return session.getApplication();
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public DtmfInput getDtmfInput() throws RemoteException {
        if (session == null) {
            return null;
        }
        try {
            final String id = session.getSessionId();
            final DtmfInput input = session.getDtmfInput();
            final Skeleton skeleton = new DtmfInputSkeleton(id, input);
            final DtmfInput characterInput = new DtmfInputStub(id);
            final Stub stub = (Stub) characterInput;
            JVoiceXmlJndiSupport.bind(context, skeleton, stub);
            return characterInput;
        } catch (NoresourceError error) {
            throw new RemoteException(error.getMessage(), error);
        } catch (ConnectionDisconnectHangupEvent error) {
            throw new RemoteException(error.getMessage(), error);
        }
    }

    /**
     * {@inheritDoc}
     */
    public void waitSessionEnd() throws RemoteException {
        if (session == null) {
            return;
        }
        try {
            session.waitSessionEnd();
        } catch (ErrorEvent event) {
            LOGGER.error(event.getMessage(), event);
            throw new RemoteException(event.getMessage(), event);
        }
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public boolean hasEnded() throws RemoteException {
        if (session == null) {
            return true;
        }
        return session.hasEnded();
    }

    /**
     * {@inheritDoc}
     */
    public ErrorEvent getLastError() throws RemoteException {
        if (session == null) {
            return null;
        }
        try {
            return session.getLastError();
        } catch (ErrorEvent event) {
            LOGGER.error(event.getMessage(), event);
            throw new RemoteException(event.getMessage(), event);
        }
    }

    /**
     * {@inheritDoc}
     */
    public void hangup() throws RemoteException {
        if (session == null) {
            return;
        }
        session.hangup();
        UnicastRemoteObject.unexportObject(this, true);
    }
}

19 View Complete Implementation : HelloWorldDemo.java
Copyright GNU Lesser General Public License v2.1
Author : JVoiceXML
/**
 * The main method.
 *
 * @param args
 *            Command line arguments. None expected.
 */
public static void main(final String[] args) {
    LOGGER.info("Starting 'hello world' demo for JVoiceXML...");
    LOGGER.info("(c) 2005-2017 by JVoiceXML group - " + "http://jvoicexml.sourceforge.net/");
    final GenericClient client = new GenericClient();
    try {
        final URI dialog = HelloWorldDemo.clreplaced.getResource("/helloworld.vxml").toURI();
        Session session = client.call(dialog, "jsapi20", "jsapi20", "desktop");
        session.waitSessionEnd();
        session.hangup();
    } catch (NamingException e) {
        LOGGER.fatal(e.getMessage(), e);
    } catch (NoresourceError e) {
        LOGGER.info("do you have the jsapi20 implementation platform" + " configured?");
        LOGGER.fatal(e.getMessage(), e);
    } catch (ErrorEvent e) {
        LOGGER.fatal(e.getMessage(), e);
    } catch (UnsupportedResourceIdentifierException e) {
        LOGGER.fatal(e.getMessage(), e);
    } catch (URISyntaxException e) {
        LOGGER.fatal(e.getMessage(), e);
    } finally {
        client.close();
    }
}

19 View Complete Implementation : MMICallManager.java
Copyright GNU Lesser General Public License v2.1
Author : JVoiceXML
/**
 * Cleanup of the resources when creating the session.
 *
 * @param session
 *            the session
 */
public void cleanupSession(final Session session) {
    final ConnectionInformationController controller = sessions.get(session);
    if (controller == null) {
        if (LOGGER.isDebugEnabled()) {
            LOGGER.info("no controller known for session '" + session.getSessionId() + "'");
        }
        return;
    }
    try {
        controller.cleanup();
    } finally {
        sessions.remove(session);
    }
}

19 View Complete Implementation : BaseCallManager.java
Copyright GNU Lesser General Public License v2.1
Author : JVoiceXML
/**
 * {@inheritDoc}
 */
@Override
public final void terminalConnected(final Terminal terminal, final CallParameters parameters) {
    try {
        final Session session = createSession(terminal, parameters);
        synchronized (sessions) {
            sessions.put(terminal, session);
        }
    } catch (ErrorEvent e) {
        LOGGER.error("error creating the session", e);
    }
}

19 View Complete Implementation : MockImplementationPlatform.java
Copyright GNU Lesser General Public License v2.1
Author : JVoiceXML
/**
 * {@inheritDoc}
 */
public void setSession(final Session currentSession) {
}

19 View Complete Implementation : JVoiceXmlStub.java
Copyright GNU Lesser General Public License v2.1
Author : JVoiceXML
/**
 * {@inheritDoc}
 */
public Session createSession(final ConnectionInformation client) throws ErrorEvent {
    final RemoteJVoiceXml jvxml = getSkeleton();
    Session session;
    try {
        if (client instanceof BasicConnectionInformation) {
            final Context context = getContext();
            final Map<?, ?> env = context.getEnvironment();
            final BasicConnectionInformation basic = (BasicConnectionInformation) client;
            if (basic.getCalledDevice() == null) {
                final Object prov = env.get(Context.PROVIDER_URL);
                basic.setCalledDevice(new URI(prov.toString()));
            }
            if (basic.getCallingDevice() == null) {
                final InetAddress localhost = InetAddress.getLocalHost();
                final URI uri = TcpUriFactory.createUri(localhost);
                basic.setCallingDevice(uri);
            }
            if (basic.getProtocolName() == null) {
                basic.setProtocolName("rmi");
            }
        }
        session = jvxml.createSession(client);
    } catch (java.rmi.RemoteException re) {
        clearSkeleton();
        session = null;
        final ErrorEvent event = getErrorEvent(re);
        if (event == null) {
            re.printStackTrace();
        } else {
            throw event;
        }
    } catch (NamingException e) {
        clearSkeleton();
        session = null;
        e.printStackTrace();
    } catch (URISyntaxException e) {
        clearSkeleton();
        session = null;
        e.printStackTrace();
    } catch (UnknownHostException e) {
        clearSkeleton();
        session = null;
        e.printStackTrace();
    }
    // Reuse the context on the client.
    if (session instanceof SessionStub) {
        final SessionStub sessionStub = (SessionStub) session;
        final Context context = getContext();
        sessionStub.setContext(context);
    }
    return session;
}

19 View Complete Implementation : SessionListener.java
Copyright GNU Lesser General Public License v2.1
Author : JVoiceXML
/**
 * Listener to wait for the end of the session.
 *
 * @author Dirk Schnelle
 */
clreplaced SessionListener extends Thread {

    /**
     * The session to listen at.
     */
    private final Session session;

    /**
     * The current browser.
     */
    private final JVoiceXmlBrowser browser;

    /**
     * Constructs a new object.
     *
     * @param sess
     *            The current session.
     * @param jvxml
     *            The current browser.
     */
    public SessionListener(final Session sess, final JVoiceXmlBrowser jvxml) {
        super();
        setDaemon(true);
        session = sess;
        browser = jvxml;
    }

    /**
     * {@inheritDoc}
     */
    public void run() {
        try {
            session.waitSessionEnd();
        } catch (org.jvoicexml.event.JVoiceXMLEvent e) {
            final Throwable cause = e.getCause();
            browser.logMessage(cause.getMessage());
        } finally {
            browser.logMessage("session terminated");
        }
    }
}

18 View Complete Implementation : MmiDetailedSessionListener.java
Copyright GNU Lesser General Public License v2.1
Author : JVoiceXML
/**
 * {@inheritDoc}
 */
@Override
public void sessionStarted(final Session session) {
}

18 View Complete Implementation : VoiceModalityComponent.java
Copyright GNU Lesser General Public License v2.1
Author : JVoiceXML
/**
 * Tries to find the context for the given session.
 *
 * @param session
 *            the session that maybe replacedociated with an MMI context
 * @return found context, <code>null</code> if there is no context for that
 *         session
 */
private MMIContext findContext(final Session session) {
    final String sessionId = session.getSessionId();
    synchronized (contexts) {
        for (String contextId : contexts.keySet()) {
            final MMIContext context = contexts.get(contextId);
            final Session other = context.getSession();
            if (other != null) {
                final String otherSessionId = other.getSessionId();
                if (otherSessionId.equals(sessionId)) {
                    return context;
                }
            }
        }
    }
    return null;
}

18 View Complete Implementation : EmbeddedJVoiceXML.java
Copyright GNU Lesser General Public License v2.1
Author : JVoiceXML
/**
 * Calls the VoiceXML interpreter context to process the given XML doreplacedent.
 *
 * @param uri
 *            URI of the first doreplacedent to load
 * @exception JVoiceXMLEvent
 *                error processing the call.
 * @throws InterruptedException
 *                error waiting for JVoiceXML
 * @throws UnknownHostException
 */
private synchronized void interpretDoreplacedent(final URI uri) throws JVoiceXMLEvent, InterruptedException, UnknownHostException {
    final EmbeddedTextConfiguration config = new EmbeddedTextConfiguration();
    jvxml = new JVoiceXmlMain(config);
    jvxml.addListener(this);
    jvxml.start();
    wait();
    final TextServer server = new TextServer(4242);
    server.start();
    server.waitStarted();
    final ConnectionInformation client = server.getConnectionInformation();
    final Session session = jvxml.createSession(client);
    session.call(uri);
    session.waitSessionEnd();
    session.hangup();
    server.stopServer();
    jvxml.shutdown();
}

18 View Complete Implementation : TextDemo.java
Copyright GNU Lesser General Public License v2.1
Author : JVoiceXML
/**
 * Runs the text demo in sequential mod, i.e. {@link #MAX_SESSIONS} sessions
 * will be called subsequently.
 */
public void sequentialMode() {
    try {
        final Context context = new InitialContext();
        final JVoiceXml jvxml = (JVoiceXml) context.lookup(JVoiceXml.clreplaced.getSimpleName());
        final URI dialog = TextDemo.clreplaced.getResource("/helloworld.vxml").toURI();
        for (int i = 0; i < MAX_SESSIONS; i++) {
            final TextServer server = new TextServer(14242);
            server.start();
            server.waitStarted();
            LOGGER.info("initiating  calls " + i + "...");
            final ConnectionInformation info = server.getConnectionInformation();
            final Session session = jvxml.createSession(info);
            session.call(dialog);
            LOGGER.info("waiting for the end of session...");
            session.waitSessionEnd();
            session.hangup();
            server.stopServer();
            LOGGER.info("...done with call " + i);
        }
    } catch (NamingException | ErrorEvent | UnknownHostException | URISyntaxException | InterruptedException e) {
        LOGGER.fatal(e.getMessage(), e);
        return;
    }
}

18 View Complete Implementation : TextDemo.java
Copyright GNU Lesser General Public License v2.1
Author : JVoiceXML
/**
 * Runs the text demo in parallel mode, i.e. {@link #MAX_SESSIONS} sessions
 * will be called parallel.
 */
public void parallelMode() {
    final TextServer[] servers = new TextServer[MAX_SESSIONS];
    for (int i = 0; i < MAX_SESSIONS; i++) {
        final TextServer server = new TextServer(14242 + i);
        server.addTextListener(new TextDemo());
        server.start();
        servers[i] = server;
    }
    try {
        final Context context = new InitialContext();
        final JVoiceXml jvxml = (JVoiceXml) context.lookup(JVoiceXml.clreplaced.getSimpleName());
        final URI dialog = TextDemo.clreplaced.getResource("/helloworld.vxml").toURI();
        LOGGER.info("initiating " + MAX_SESSIONS + " calls...");
        final Session[] sessions = new Session[MAX_SESSIONS];
        for (int i = 0; i < MAX_SESSIONS; i++) {
            final ConnectionInformation info = servers[i].getConnectionInformation();
            final Session session = jvxml.createSession(info);
            sessions[i] = session;
        }
        for (int i = 0; i < MAX_SESSIONS; i++) {
            sessions[i].call(dialog);
        }
        LOGGER.info("waiting for the end of all sessions...");
        for (int i = 0; i < MAX_SESSIONS; i++) {
            sessions[i].waitSessionEnd();
            sessions[i].hangup();
        }
        LOGGER.info("...done");
    } catch (NamingException | ErrorEvent | UnknownHostException | URISyntaxException e) {
        LOGGER.fatal(e.getMessage(), e);
        return;
    }
}

18 View Complete Implementation : EmbeddedJVXML.java
Copyright GNU Lesser General Public License v2.1
Author : JVoiceXML
public Session createSession(MgcpCallTerminal call) {
    try {
        // get JNDI client connection;
        jndiClient = new MobicentsConnectionInformation(call, "mobicents", "mobicents");
        final Session session = jvxml.createSession(jndiClient);
        return session;
    } catch (JVoiceXMLEvent ev) {
        ExLog.exception(LOGGER, ev);
    } catch (Exception ex) {
        ExLog.exception(LOGGER, ex);
    }
    return null;
}

18 View Complete Implementation : SipCallManager.java
Copyright GNU Lesser General Public License v2.1
Author : JVoiceXML
/**
 * {@inheritDoc}
 */
@Override
public void sessionEnded(final Session session) {
    String id = session.getSessionId();
    // workaround to deal with two id's
    // maps the voicexml sessionid to sip session id
    // needed for case when the voicxml session ends before a hang up and
    // need to get to close the sip session
    // get the sip sesison id
    // remove the session id mapping
    final String sipId;
    synchronized (ids) {
        sipId = ids.get(id);
        ids.remove(id);
    }
    // clean up the session
    cleanupSession(sipId);
}

18 View Complete Implementation : SipCallManagerSession.java
Copyright GNU Lesser General Public License v2.1
Author : JVoiceXML
public clreplaced SipCallManagerSession {

    private String id;

    private SipSession pbxSession;

    private SipSession mrcpSession;

    private SpeechClient speechClient;

    private TelephonyClient telephonyClient;

    private Session jvxmlSession;

    public SipCallManagerSession(String id, SipSession pbxSession, SipSession mrcpSession, SpeechClient speechClient, TelephonyClient telephonyClient) {
        super();
        this.id = id;
        this.pbxSession = pbxSession;
        this.mrcpSession = mrcpSession;
        this.speechClient = speechClient;
        this.telephonyClient = telephonyClient;
    }

    /**
     * @return the id
     */
    public String getId() {
        return id;
    }

    /**
     * @param id the id to set
     */
    public void setId(String id) {
        this.id = id;
    }

    /**
     * @return the jvxmlSession
     */
    public Session getJvxmlSession() {
        return jvxmlSession;
    }

    /**
     * @param jvxmlSession the jvxmlSession to set
     */
    public void setJvxmlSession(Session jvxmlSession) {
        this.jvxmlSession = jvxmlSession;
    }

    /**
     * @return the pbxSession
     */
    public SipSession getPbxSession() {
        return pbxSession;
    }

    /**
     * @param pbxSession the pbxSession to set
     */
    public void setPbxSession(SipSession pbxSession) {
        this.pbxSession = pbxSession;
    }

    /**
     * @return the mrcpSession
     */
    public SipSession getMrcpSession() {
        return mrcpSession;
    }

    /**
     * @param mrcpSession the mrcpSession to set
     */
    public void setMrcpSession(SipSession mrcpSession) {
        this.mrcpSession = mrcpSession;
    }

    /**
     * @return the speechClient
     */
    public SpeechClient getSpeechClient() {
        return speechClient;
    }

    /**
     * @param speechClient the speechClient to set
     */
    public void setSpeechClient(SpeechClient speechClient) {
        this.speechClient = speechClient;
    }

    /**
     * @return the telephonyClient
     */
    public TelephonyClient getTelephonyClient() {
        return telephonyClient;
    }

    /**
     * @param telephonyClient the telephonyClient to set
     */
    public void setTelephonyClient(TelephonyClient telephonyClient) {
        this.telephonyClient = telephonyClient;
    }
}

18 View Complete Implementation : simple.java
Copyright GNU Lesser General Public License v2.1
Author : JVoiceXML
@Test
public void testSimple() {
    final String path = "rc/helloworld.vxml";
    final TextServer server = new TextServer(4242);
    server.start();
    URI dialog = new File(path).toURI();
    try {
        final Session session = jvxml.createSession(server.getConnectionInformation());
        session.call(dialog);
        session.waitSessionEnd();
        session.hangup();
    } catch (UnknownHostException | ErrorEvent e) {
        e.printStackTrace();
        fail(e.getMessage());
    } finally {
        server.stopServer();
    }
}

17 View Complete Implementation : TestObjectExecutorThread.java
Copyright GNU Lesser General Public License v2.1
Author : JVoiceXML
/**
 * Set up the test environment.
 *
 * @exception Exception
 *                set up failed
 */
@Before
public void setUp() throws Exception {
    lock = new Object();
    event = null;
    // Create mock objects for the tests
    context = Mockito.mock(VoiceXmlInterpreterContext.clreplaced);
    final EventBus bus = new EventBus();
    Mockito.when(context.getEventBus()).thenReturn(bus);
    final Session session = Mockito.mock(Session.clreplaced);
    Mockito.when(context.getSession()).thenReturn(session);
}

17 View Complete Implementation : MmiDetailedSessionListener.java
Copyright GNU Lesser General Public License v2.1
Author : JVoiceXML
/**
 * {@inheritDoc}
 */
@Override
public void sessionEnded(final Session session) {
    // Remove this instance asynchronously to avoid a concurrent
    // modification exception
    final DetailedSessionListener listener = this;
    final Thread thread = new Thread() {

        @Override
        public void run() {
            final JVoiceXmlSession jvxmlSession = (JVoiceXmlSession) session;
            jvxmlSession.removeSessionListener(listener);
        }
    };
    thread.start();
}

17 View Complete Implementation : EmbeddedJVXML.java
Copyright GNU Lesser General Public License v2.1
Author : JVoiceXML
/**
 * Calls the VoiceXML interpreter context to process the given XML doreplacedent.
 *
 * @param uri
 *            URI of the first doreplacedent to load
 * @exception JVoiceXMLEvent
 *                error processing the call.
 * @throws InterruptedException
 *                error waiting for JVoiceXML
 */
private synchronized void interpretDoreplacedent(final URI uri) throws JVoiceXMLEvent, InterruptedException {
    JVoiceXmlConfiguration config = new JVoiceXmlConfiguration();
    jvxml = new JVoiceXmlMain(config);
    jvxml.addListener(this);
    jvxml.start();
    wait();
    final ConnectionInformation client = new BasicConnectionInformation("desktop", "jsapi10", "jsapi10");
    final Session session = jvxml.createSession(client);
    session.call(uri);
    session.waitSessionEnd();
    session.hangup();
}

16 View Complete Implementation : TestJVoiceXmlDocumentServer.java
Copyright GNU Lesser General Public License v2.1
Author : JVoiceXML
/**
 * Test method for
 * {@link JVoiceXmlDoreplacedentServer#getAudioInputStream(String, URI)}.
 *
 * @since 0.7.2
 * @exception Exception
 *                Test failed.
 * @exception JVoiceXMLEvent
 *                Test failed.
 */
@Test
public void testGetAudioInputStream() throws Exception, JVoiceXMLEvent {
    final URL file = this.getClreplaced().getResource("/test.wav");
    final Session session = Mockito.mock(Session.clreplaced);
    Mockito.when(session.getSessionId()).thenReturn(UUID.randomUUID().toString());
    final String sessionId = session.getSessionId();
    final AudioInputStream in = server.getAudioInputStream(sessionId, file.toURI());
    replacedert.replacedertNotNull(in);
}