Announcement Announcement Module
No announcement yet.
Change flow definition in run-time Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Change flow definition in run-time

    I was wondering if it's possible to modified the definition of a flow in runtime programatically.

    for example i will like to add an EndState to the active flow. Something like this:

    requestContext.getActiveFlow().addEndState(new EndState("endStateID"));

    id this possible? how?

    thanks in advance

  • #2
    I think SWF 2.1.x has more robust support for programmatic flow construction. I don't know if that extends to runtime construction, but I would doubt it.

    What's your use case which requires programmatically adding an end-state?


    • #3
      I'm using SWF 2.0.5. I also know that it's possible to create flow programatically (AbstractFlowBuilder) but I can't find anything regarding to flow modification in runtime.

      Something like this is my use case


      <subflow "flowB">
      <transition on=a to a>
      <transition on=b to b>

      retrives from a map in the scope the result of this flow (could be A,B,C or anything else). So I can't create a endState per each result defined in my map because could be any value

      I know that I could use another solutions but I prefer using this (if possible)

      Hope you understand my use case

      Last edited by polololoco; Jun 17th, 2010, 04:27 PM.


      • #4
        I guess I'm still having trouble understanding.

        Your end-state IDs will drive the transition from your subflow to the next state. Don't you know what possible states you might jump to from your end-state? If you don't, as it seems the case here, then I'm not sure if web flow is the tool you need.

        Then again, you might be able to get away with evaluating the next state to jump to based upon a returned value from your subflow. So, rather than letting the end-state drive the transition, you let the transition dynamically use whatever output you supply from the subflow's endstate.

        There are a few threads here on dynamic transitions...those might help you out.


        • #5
          I have all the application built in SWF, I cannot change it now . I read the thread that you mention and here is the thing...

          <transition on="guestCreated" to="${somevalue}">

          For this i will like to have...

          <end-state id="${somevalue}"> (the fact is that the end-states are dynamic, for example making available a new option to the user without changing the application code and deploying. This flow pretends to be generic, for building the menus, so in the entire application I could have like 100 options. Creating 100 endStates is not a clean and good solution I think)

          I know that I can just save the stateResult in the scope, but I prefer the other way around (adding the EndState that I need programatically)

          thanks for your responses
          Last edited by polololoco; Jun 18th, 2010, 09:02 AM.


          • #6
            I think a member of the SWF implementation team is probably in a better position to answer your question.

            Still, from what I understand, SWF is geared to construct the flow BEFORE flow execution...If you WERE to find a way to add in states, you would need to pay close attention to synchronization, as the Flow object may be supporting multiple concurrent executions.

            Also, from what I can tell, creating dynamic end-states would require dynamic transitions in your subflow-state as well? Where are these transitions going to? States which already exist, or more dynamic states you'll need to create?

            Without knowing more about what your application is supposed to do, I'm still not convinced SWF is the right technology for this kind of use case.


            • #7
              It's bit more complex. I'm trying to make it simple without explaining all the business logic, anyway SWF is the right choice, is an IVR application, so flows are the main documents.

              Don't worry, I think I will have to save the stateResult and evaluate it later

              Thanks! really appreciate your concern