Example usage for org.apache.commons.scxml.env Tracer Tracer

List of usage examples for org.apache.commons.scxml.env Tracer Tracer

Introduction

In this page you can find the example usage for org.apache.commons.scxml.env Tracer Tracer.

Prototype

public Tracer() 

Source Link

Document

Constructor.

Usage

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

/**
 * @param scxmlFileName The qualified xml file name, e.g. "/alma/acs/nc/sm/EventSubscriberStates.xml",
 *                      in the form that {@link Class#getResource(String)} can use to load the scxml
 *                      definition file from the classpath. 
 * @param logger//  w  w w.java  2s.c o m
 * @param actionDispatcher 
 * @param signalType enum class, needed to convert signal names to enum values.
 * @throws IllegalArgumentException if any of the args are <code>null</code> or if the <code>actionDispatcher</code>
 *                                  is not complete for all possible actions.
 */
public AcsScxmlEngine(String scxmlFileName, Logger logger, AcsScxmlActionDispatcher<A> actionDispatcher,
        Class<S> signalType) {

    this.logger = logger;
    this.actionDispatcher = actionDispatcher;
    this.signalType = signalType;

    // TODO decide if we want to insist here, or let the user check this beforehand
    if (!actionDispatcher.isActionMappingComplete()) {
        throw new IllegalArgumentException("actionDispatcher is not complete.");
    }

    errorTracer = new Tracer(); // create error tracer
    exprEvaluator = new JexlEvaluator(); // Evaluator evaluator = new ELEvaluator();
    eventDispatcher = new SimpleDispatcher(); // create event dispatcher
    exprContext = new JexlContext(); // set new context

    // Adding AcsScxmlActionDispatcher to the SM root context 
    // so that the generated action classes can get it from there and can delegate action calls.
    exprContext.set(AcsScxmlActionDispatcher.class.getName(), actionDispatcher);

    try {
        // load the scxml model
        loadModel(scxmlFileName);

        startExecution();

    } catch (Exception ex) {
        logger.log(Level.SEVERE, "Failed to load or start the state machine.", ex); // TODO
    }

}