Uploaded image for project: 'Commons SCXML'
  1. Commons SCXML
  2. SCXML-67

<state> can't have <parallel>

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 0.7
    • 0.8
    • None

    Description

      According to the latest SCXML W/D the <state> can have <parallel> as its child.
      But, Commons SCXML 0.7 doesn't seems to support that.

      The org.apache.commons.scxml.io.SCXMLParser can't parse this scxml doc.

      <?xml version="1.0"?>
      <scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0"
      initialstate="microwave">
      <state id="microwave">
      <initial>
      <transition target="parts"/>
      </initial>
      <parallel id="parts">
      <state id="oven">
      <initial>
      <transition target="oven2"/>
      </initial>
      <state id= "oven2">
      <transition event="exit" target="dest"/>
      </state>
      </state>
      <state id="door">
      <initial>
      <transition target="door2"/>
      </initial>
      <state id= "door2">
      <transition event="e" target="dest"/>
      </state>
      </state>
      </parallel>
      </state>
      <state id= "dest" final ="true"/>
      </scxml>

      The SCXML engine generates the following exception during parsing the scxml doc.
      Exception in thread "main" java.lang.ClassCastException: org.apache.commons.scxml.model.Parallel
      at org.apache.commons.scxml.io.ModelUpdater.updateState(ModelUpdater.java:213)
      at org.apache.commons.scxml.io.ModelUpdater.updateSCXML(ModelUpdater.java:78)
      at org.apache.commons.scxml.io.SCXMLParser.parse(SCXMLParser.java:268)
      at org.apache.commons.scxml.io.SCXMLParser.parse(SCXMLParser.java:152)
      at org.apache.commons.scxml.test.StandaloneUtils.execute(StandaloneUtils.java:80)
      at org.apache.commons.scxml.test.StandaloneJexlExpressions.main(StandaloneJexlExpressions.java:60)

      So, I fixed the 'updateState()' in org.apache.commons.scxml.io.ModelUpdater class like this
      (and also org.apache.commons.scxml.io.SCXMLSerializer.serializeState() )
      ..........
      } else {
      Iterator j = c.keySet().iterator();
      /* ---- your code ----
      while (j.hasNext())

      { updateState((State) c.get(j.next()), targets); }

      */
      /* ------- my fixed code ---------*/
      while (j.hasNext()) {
      TransitionTarget tt = (TransitionTarget) c.get(j.next());
      if (tt instanceof State)

      { updateState((State) tt, targets); }

      else

      { updateParallel((Parallel) tt, targets); }

      }
      /* ------------------------------------*/
      }
      } /* end of 'updateState()' */

      So, the engine works well.

      I think this is a critical bug.

      Attachments

        Activity

          People

            Unassigned Unassigned
            timecop Seongsoo Park
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: