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

Provide a state machine support class to allow for delegation.

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Won't Do
    • 0.6
    • None
    • None

    Description

      This is not completely thought out yet, but if folks like the idea I might persue it further.

      I would like to use AbstractStateMachine but cannot extend from it:

      class B extends A /*, AbstractStateMachine */ {
      // copy source from AbstractStateMachine here
      }

      I propose here a StateMachineSupport class that provides for use by subclassing and for use by delegation. The constructors are a little messy, but in the end I have

      public class StateMachineSupport {
      // use by subclassing
      protected StateMachineSupport(...) {
      }

      // use by delegation
      public StateMachineSupport(Object delegator, ...) {
      }

      // ... methods from AbstractStateMachine
      }

      public abstract class AbstractStateMachine extends StateMachineSupport {
      protected AbstractStateMachine(...)

      { super(...); }

      }

      // use by subclassing
      class ConcreteStateMachine extends AbstractStateMachine {
      ConcreteStateMachine()

      { super(..."stopwatch.xml"); }

      public void reset()

      { ... }
      public void running() { ... }

      public void paused()

      { ... }
      public void stopped() { ... }

      }

      // use by delegation
      class DelegatingStateMachine extends SomethingElse {
      StateMachineSupport delegate;

      DelegatingStateMachine()

      { delegate = new StateMachineSupport(this, ..."stopwatch.xml"); }

      public void reset()

      { ... }
      public void running() { ... }

      public void paused()

      { ... }
      public void stopped() { ... }

      }

      StateMachineSupport.java, AbstractStateMachine2.java, StateMachineSupportTest.java, and AbstractStateMachine2Test.java attached.

      Attachments

        1. additional-tests.tar.gz
          2 kB
          Michael Heuer
        2. state-machine-support-src.tar.gz
          3 kB
          Michael Heuer

        Activity

          People

            Unassigned Unassigned
            heuermh@acm.org Michael Heuer
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: