List of usage examples for org.apache.commons.scxml.env.jexl JexlEvaluator JexlEvaluator
public JexlEvaluator()
From source file:com.korwe.thecore.scxml.ScxmlMessageProcessor.java
@Override public void initialize(String sessionId) { super.initialize(sessionId); try {/*w ww.ja va 2 s. co m*/ String scxmlPath = CoreConfig.getInstance().getProperty("scxml_path"); if (LOG.isDebugEnabled()) { LOG.debug("SCXML path = " + scxmlPath); } File scfile = new File(scxmlPath); if (LOG.isDebugEnabled()) { LOG.debug("Absolute path: [" + scfile.getAbsolutePath() + "]"); } InputSource source = new InputSource(new BufferedReader(new FileReader(scxmlPath))); scxml = SCXMLParser.parse(source, new SimpleErrorHandler()); exec = new SCXMLExecutor(new JexlEvaluator(), new SimpleDispatcher(), new SimpleErrorReporter()); exec.setStateMachine(scxml); exec.addListener(scxml, new SimpleSCXMLListener()); exec.registerInvokerClass("x-coremessage", SendCoreMessageInvoker.class); Context context = new JexlContext(); context.set("sessionId", sessionId); context.set("lastMsg", null); exec.setRootContext(context); exec.go(); } catch (Exception e) { LOG.error("Failed to parse SCXML", e); } }
From source file:core.AbstractStateMachine.java
/** * Convenience constructor, object instantiation incurs parsing cost. * * @param scxmlDocument The URL pointing to the SCXML document that * describes the "lifecycle" of the * instances of this class. *///from w w w . ja v a 2 s . c o m public AbstractStateMachine(final URL scxmlDocument) { // default is JEXL this(scxmlDocument, new JexlContext(), new JexlEvaluator()); }
From source file:ch.shaktipat.saraswati.internal.common.AbstractStateMachine.java
/** * Convenience constructor, object instantiation incurs parsing cost. * * @param scxmlDocument The URL pointing to the SCXML document that * describes the "lifecycle" of the * instances of this class. *///from w w w . j a v a 2 s.c o m public AbstractStateMachine(final URL scxmlDocument) { // default is JEXL this(scxmlDocument, new org.apache.commons.scxml.env.jexl.JexlContext(), new JexlEvaluator()); }
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/*ww w . jav a 2 s.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 } }
From source file:ch.shaktipat.saraswati.internal.common.AbstractStateMachine.java
/** * Convenience constructor.//from w ww . j a v a 2 s . c o m * * @param stateMachine The parsed SCXML instance that * describes the "lifecycle" of the * instances of this class. * * @since 0.7 */ public AbstractStateMachine(final SCXML stateMachine) { // default is JEXL this(stateMachine, new JexlContext(), new JexlEvaluator()); }
From source file:com.headstrong.fusion.statemachine.SCXMLStateMachine.java
private Evaluator getEvaluator() { return new JexlEvaluator(); }
From source file:org.dishevelled.piccolo.identify.StateMachineSupport.java
/** * Create a new state machine support class to be delegated to * by the specified delegator with the specified state machine. * * @param delegator object delegating to this state machine support * class, must not be null/* www. jav a2 s . c o m*/ * @param stateMachine state machine for this support class, must * not be null */ StateMachineSupport(final Object delegator, final SCXML stateMachine) { if (delegator == null) { throw new IllegalArgumentException("delegator must not be null"); } if (stateMachine == null) { throw new IllegalArgumentException("stateMachine must not be null"); } this.delegator = delegator; Evaluator evaluator = new JexlEvaluator(); EventDispatcher dispatcher = new SimpleDispatcher(); ErrorReporter errorReporter = new NoopErrorReporter(); Context rootContext = new JexlContext(); SCXMLListener listener = new SCXMLListener() { @Override public void onEntry(final TransitionTarget entered) { invoke(entered.getId()); } @Override public void onExit(final TransitionTarget exited) { // empty } @Override public void onTransition(final TransitionTarget to, final TransitionTarget from, final Transition transition) { // empty } }; executor = new SCXMLExecutor(evaluator, dispatcher, errorReporter); executor.setStateMachine(stateMachine); executor.setSuperStep(false); executor.setRootContext(rootContext); executor.addListener(stateMachine, listener); try { executor.go(); } catch (ModelException e) { // ignore } }