Example usage for org.apache.commons.scxml.model ModelException getMessage

List of usage examples for org.apache.commons.scxml.model ModelException getMessage

Introduction

In this page you can find the example usage for org.apache.commons.scxml.model ModelException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:alma.acs.nc.sm.generic.AcsScxmlEngine.java

/**
 * Sends a signal (event) to the state machine.
 * /*w  ww .j  a v a  2 s  .  co  m*/
 * The call is synchronous and returns only when the state machine has gone through all transitions/actions, 
 * where of course a /do activity would still continue to run asynchronously.
 * Note that the underlying SCXML engine also supports asynchronous sending of multiple events
 * at a time, but we do not expose this feature in ACS.
 * <p>
 * TODO: How can the client find out whether the signal was applicable 
 *       for the current state or was ignored?
 *       
 * @return True - if all the states are final and there are not events
 *         pending from the last step. False - otherwise.
 */
public synchronized boolean fireSignal(S signal) {
    TriggerEvent evnt = new TriggerEvent(signal.name(), TriggerEvent.SIGNAL_EVENT, null);
    try {
        exec.triggerEvent(evnt);
    } catch (ModelException e) {
        logger.info(e.getMessage());
    }
    return exec.getCurrentStatus().isFinal();
}

From source file:alma.acs.nc.sm.generic.AcsScxmlEngine.java

/**
 * Loads the SCXML model from an XML file stored inside of a jar file on the classpath.
 * <p>/*from ww  w .j  av  a2s.  co  m*/
 * TODO: define and throw exception in case of load/parse failure.
 * 
 * @param scxmlFileName The qualified xml file name, e.g. "/alma/acs/nc/sm/generated/EventSubscriberSCXML.xml"
 */
public void loadModel(final String scxmlFileName) {

    try {
        // TODO: Pass InputSource instead of String,
        // because the xml file may be inside a component impl jar file
        // which is not visible to the classloader of this generic SMEngine class.
        URL scxmlUrl = getClass().getResource(scxmlFileName);

        if (scxmlUrl == null) {
            logger.severe(
                    "Failed to load the scxml definition file '" + scxmlFileName + "' from the classpath.");
            // TODO ex;
        }

        List<CustomAction> scxmlActions = actionDispatcher.getScxmlActionMap();
        scxml = SCXMLParser.parse(scxmlUrl, errorTracer, scxmlActions);
        logger.fine("Loaded SCXML file " + scxmlUrl.toString() + "...");
    } catch (ModelException e) {
        logger.severe("Could not load model: " + e.getMessage());
    } catch (SAXException e) {
        logger.severe("Could not load model: " + e.getMessage());
    } catch (IOException e) {
        logger.severe("Could not load model: " + e.getMessage());
    }
}

From source file:alma.acs.nc.sm.generic.AcsScxmlEngine.java

/**
 * Starts SCXML execution.// w w w .java 2s .co  m
 * <p>
 * TODO: define and throw exception in case of model failure.
 */
public void startExecution() {

    try {
        exec = new SCXMLExecutor(exprEvaluator, eventDispatcher, errorTracer);

        // make sure scxml is a valid SCXML doc -> ToBeDone

        exec.addListener(scxml, errorTracer);
        exec.setRootContext(exprContext);

        exec.setStateMachine(scxml);
        //         @TODO: When do we need a java invoker?
        //         exec.registerInvokerClass("java", SMJavaInvoker.class);
        exec.go();
    } catch (ModelException e) {
        logger.severe("Could not start SM execution: " + e.getMessage());
    }

    logger.fine("Started SM execution ...");
}

From source file:org.finra.datagenerator.engine.scxml.SCXMLEngineTest.java

/**
 * Throws exception when reaching end state
 *//*from ww w .j  av  a2s .  c o  m*/
@Test
public void testExceptionAtEndState() {
    SCXMLEngine e = new SCXMLEngine();
    InputStream is = SCXMLEngineTest.class.getResourceAsStream("/bigtest.xml");
    e.setModelByInputFileStream(is);

    String errorMessageExpected = "Could not achieve required bootstrap without reaching end state";
    try {
        e.bfs(4000); // too many
        Assert.fail("Oops! We wait for '" + errorMessageExpected + "' error message here "
                + "(bootstrap size is too big for this model), but don't have it!");
    } catch (ModelException ex) {
        Assert.assertEquals("Oops! We have '" + ex.getMessage()
                + "' modelException error message, but we wait for " + "'" + errorMessageExpected + "' here!",
                ex.getMessage(), errorMessageExpected);
    }
}