Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Commons SCXML Frequently Asked Questions (Commons-SCXML FAQ)TableOfContents

...

Table of Contents

...

What is SCXML?

State Chart XML (SCXML) is a general-purpose event-based state machine language that can be used in many ways.

Do you have a simple example where Commons SCXML is used?

Wiki MarkupSure, take a look at the \[http://jakarta.apache.org/commons/sandbox/scxml/usecases/scxml-stopwatch .html stopwatch usecase\].

What is a Context? And what is an Evaluator?

...

  • The Context is a collection of variables that defines a variable "scope". Each <state> element within an SCXML document gets its own Context or variable scope.
  • The Evaluator is a component with the capability of parsing and evaluating expressions. It is the "expression language engine".

Wiki MarkupCommons SCXML currently provide implementations for \[http://jakarta.apache.org/commons/sandbox/scxml/apidocs/org/apache/commons/scxml/env/jexl/package-summary.html JEXL\] and \[http://jakarta.apache.org/commons/sandbox/scxml/apidocs/org/apache/commons/scxml/env/jsp/package-summary.html JSP 2.0 EL\].

Which expression languages does the Commons SCXML implementation support?

  • Wiki Markup\[http://jakarta.apache.org/commons/sandbox/scxml/apidocs/org/apache/commons/scxml/env/jexl/package-summary.html JEXL\] Wiki Markup\[http://jakarta.apache.org/commons/sandbox/scxml/apidocs/org/apache/commons/scxml/env/jsp/package-summary.html
  • JSP 2.0 EL\] \\

How do I try out the sample SCXML documents?

Wiki MarkupThe SCXML distribution provides utility classes that offer mock command line environments allowing users to try out samples. The core dependencies for Commons SCXML are Commons Digester (which introduces a transitive dependency on Commons BeanUtils, at the least) and Commons Logging. View the \[http://jakarta.apache.org/commons/sandbox/scxml/dependencies .html dependencies page\] for the recommended version numbers. It may be possible to use lower version numbers for the Commons dependencies.

An environment specific expression language is used in SCXML documents. Commons SCXML currently supports the use of JEXL or JSP 2.0 EL in SCXML documents.

...

You could set up something more elegant (a script, an ant task etc.), but that is what it boils down to. If the document is a well-formed SCXML document, you will be able to type ? or help at the console and you can follow the directions thereafter (to simulate events, set variable values, reset the state machine or quit).unmigrated-wiki-markup

A few examples are available as part of the \[http://svn.apache.org/repos/asf/jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/ Commons SCXML test suite\] (look in env packages as well). Enjoy, and feedback is always welcome.

Can I use more than one expression language in the same SCXML document?

...

How do I enable / control the logging within the Commons SCXML package?

Wiki MarkupCommons SCXML uses Commons Logging. See the \[http://jakarta.apache.org/commons/logging/ Commons Logging Website\] for more details.

Can multiple threads safely interact with an instance of SCXMLExecutor?

...

Here are two example from our usecases that have nothing to do with voice applications:

What are the core requirements of SCXML? Do I need to include the JSP and Servlet API or the Faces libraries? Do I need to include Commons JEXL or Commons EL?

...

You do not need to include JSP or Servlet or Faces libraries. These are meant to come in via the servlet container environment and the corresponding classes in the Commons SCXML codebase which have those dependencies are meant to be used only in JSP/Servlet/Faces environments.unmigrated-wiki-markup

In addition, you will need to choose an expression language for your SCXML documents. The recommended expression language for the Commons SCXML implementation is \[http://jakarta.apache.org/commons/jexl/ JEXL\]. Using JEXL for expressions introduces a dependency of Commons JEXL. For usecases in JSP-based environments, EL will be a prefered choice over JEXL, and if you choose to use JSP 2.0 EL, that introduces a dependency of Commons EL and a runtime dependency on the JSP API (again, these should come in via the servlet container).unmigrated-wiki-markup

See the \[http://jakarta.apache.org/commons/sandbox/scxml/dependencies .html dependencies page\] on the Commons SCXML website for details about the dependency versions.

Does Commons SCXML implement the entire Working Draft? Are there any parts of the SCXML draft that are not covered by Commons SCXML?

Wiki MarkupNo. Speaking in terms of the \[http://www.w3.org/TR/2005/WD-scxml-20050705/ July 2005 W3C SCXML Working Draft\] the items that are not covered are:

  • Multiple (simultaneous) targets for a single transition (Section 3.3.1)
  • JOIN (Section 4.3)
  • SYNCH (Section 4.4)

Is there an XML Schema associated with the SCXML Working Draft?

Wiki MarkupYes, a schema has been published, see appendix D of this \[http://www.w3.org/TR/2006/WD-scxml-20060124/ W3C SCXML Working Draft\].

Is the implementation currently Serializable, meaning that can an SCXMLExecutor be serialized, passed across a wire, be deserialized, and then continue processing events where it left off? If so, are there any limitations around listeners?

...

However, this has been implemented in trunk, so with the next release of Commons SCXML the SCXMLExecutor instances will be Serializable. Listeners and other associated user-supplied bits are expected to be Serializable.

How do I specify the initial substate when extracting a state descending from a <parallel> element into an external file?

Use the initialstate attribute of the scxml element in the external file, and delete the initial pseudostate element with the transition to the initial substate.

Example definition before extraction:

No Format

...
<parallel>
  <state id="a">
  <initial>
    <transition target="a.initial"/>
  </initial>
  <state id="a.initial>
  ...

Example definition after extraction:

No Format

...
<parallel>
  <state id="a" src="a.scxml"> 

Extracted definition:

No Format

...
<scxml
 ...
 initialstate="a.initial">
  <state id="a">
    <state id="a.initial">
    ... 

Ellipsis ... marks omitted elements or attributes.

Reason for this entry: I found it a bit confusing that there are two ways to express "initiality" of a (sub-)state, one by declaring initialstate, one by adding an operation, that is an unconditional initial transition. This is even more confusing during the "extract" refactoring, because I had to switch from the operational to the declarative method.