3 Replies Latest reply on Dec 5, 2005 2:02 AM by icyjamie

    signal and default transition

    icyjamie

      When you do a token.signal(), it always fetches some default transition (and this the first one in the list of transitions). It could be handy to implement a handler which could give back the default transition. That way, you could have some sort of decision handler for every node type.
      Internally, it could do this.node.getTransitionHandler
      With AOP, you could even define which business methods should be signalling, and you could prepare the context beforehand. Business logic will become concern, process flow will become another concern in this case.

        • 1. Re: signal and default transition
          kukeltje

          Can you explain a little more? I completely miss the point you are trying to make....e.g. 'a decision handler for evey node type'???

          • 2. Re: signal and default transition
            icyjamie

            "some sort of" decision handler.

            I mean that, when you do a signal without a transition name, it will do a getDefaultLeavingTransition on the node (check the sourcecode for this). It would be nice if this function also calls a handler, similar to a DecisionHandler, which returns the name of the transition that should be consequently used in the signal.

            In token:
             public void signal() {
             if ( (node == null) || (node.getDefaultLeavingTransition() == null)) {
             throw new IllegalStateException("couldn't signal token '" + this + "' : couldn't leave node '" + node + "' over its default transition");
             }
             signal(node.getDefaultLeavingTransition());
             }
            
            In node:
            
             public Transition getDefaultLeavingTransition() {
             Transition defaultTransition = null;
             if ( (leavingTransitions!=null)
             && (leavingTransitions.size()>0) ) {
            // here you could check for the existence of a handler, and use this
            // if it returns null, you could still use the rest of the code, giving back the first one
             defaultTransition = (Transition) leavingTransitions.get(0);
             } else if ( superState!=null ){
             defaultTransition = superState.getDefaultLeavingTransition();
             }
             return defaultTransition;
             }
            
            ....
            
            
            
            




            • 3. Re: signal and default transition
              icyjamie

              I was following the other thread concerning transitions, guards and the like (http://www.jboss.com/index.html?module=bb&op=viewtopic&t=73286)
              Of course, you could also use guards on transitions, filter the ones that are available, and choose the first one (hopefully, in this case, there will be only one available, otherwise, you have to choose the first one again, or fire an exception).
              In other words, guarded or conditional transitions seems like a hot topic.