Announcement Announcement Module
Collapse
No announcement yet.
Reloading Flows at Runtime Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Reloading Flows at Runtime

    Hello there!

    I am using webflow 2.3.

    I would like to reload my flow defintions (from xml) at runtime.
    Since XmlFlowRegistryFactoryBean is no more and DefaultFlowRegistry is protected, I tried to implement an own Registry.

    Before posting the Code, I'd like to know if there is another way to go. I already read some questions like this one, but found no answer. If there already is an answer somewhere, please let me know.

    Nils

  • #2
    Ok, I got it by having a FlowService bean, knowing the default flowRegistry. It got this method:

    Code:
    public void register(String id, String path) {
    		
    		FileSystemResource resource=new FileSystemResource(servletContext.getRealPath(path));
    		
    		System.out.println("PATH:::::::::::::::::::::::::::::::::::::::::"+
    				servletContext.getRealPath("/WEB-INF/flows/purchase-flow.xml")+" exists?: "+ resource.exists());
    		
    		FlowDefinitionResource flowDefinitionResource = new FlowDefinitionResource(id, resource, null);
    		XmlFlowModelBuilder flowModelBuilder = new XmlFlowModelBuilder(flowDefinitionResource.getPath(), null);
    		DefaultFlowModelHolder flowModelHolder = new DefaultFlowModelHolder(flowModelBuilder);
    		FlowModelFlowBuilder flowBuilder=new FlowModelFlowBuilder(flowModelHolder);
    		//attributes=null .... ??
    		FlowBuilderContextImpl flowBuilderContext= new FlowBuilderContextImpl(path, CollectionUtils.EMPTY_ATTRIBUTE_MAP, flowRegistry, flowBuilderServices);
    		DefaultFlowHolder definitionHolder = new DefaultFlowHolder(new FlowAssembler(flowBuilder, flowBuilderContext));
    		flowRegistry.registerFlowDefinition(definitionHolder);
    	}
    The init-method of FlowService is this one:

    Code:
    public void init() {
    		register("flow", "/WEB-INF/flows/purchase-flow.xml");
    		register("flow", "/WEB-INF/flows/addToBasket-flow.xml");
    		register("flow", "/WEB-INF/flows/trader-flow.xml");
    		System.out.println("FLOWIDS###############################################");
    		for(String s: flowRegistry.getFlowDefinitionIds()) {
    			System.out.println("FLOWID:::::::::::::::::::::::::"+s);
    		}
    	}
    The sysout delivers:
    [INFO] FLOWIDS########################################### ####
    [INFO] FLOWID:::::::::::::::::::::::::/WEB-INF/flows/addToBasket-flow.xml
    [INFO] FLOWID:::::::::::::::::::::::::/WEB-INF/flows/purchase-flow.xml
    [INFO] FLOWID:::::::::::::::::::::::::/WEB-INF/flows/trader-flow.xml


    How can I change the IDs of the flows (Since by now, my "String id" is pretty useless) ?

    EDIT: Erased something useless.

    Nils

    Comment


    • #3
      To change the ID I had to change

      Code:
      FlowBuilderContextImpl flowBuilderContext= new FlowBuilderContextImpl(path, CollectionUtils.EMPTY_ATTRIBUTE_MAP, flowRegistry, flowBuilderServices);
      to

      Code:
      FlowBuilderContextImpl flowBuilderContext= new FlowBuilderContextImpl(id, CollectionUtils.EMPTY_ATTRIBUTE_MAP, flowRegistry, flowBuilderServices);


      But how can I get access to the Holder, once it is registered instead of the Definition itself(To refresh it)?

      edit: I just tried to re-register it for change - this does not work.
      Last edited by tohu; Aug 15th, 2011, 08:55 AM.

      Comment


      • #4
        I can now refresh all Flows by doing flowRegistry.destroy and rebuilding it using a String[] of all previously registered IDs.
        Of course it would be nice to refresh one flow at a time, but the most important problem to solve now would be:

        How to wait with the update until no one is executing a flow any more?

        Has someone got a starting point for me? Within wich class(es) are running executions administrated?

        Thanks,
        Nils

        Comment


        • #5
          Stopping all Flow Executions

          I'd like to stop all flow executions running.

          I found the DefaultFlowExecutionRepository.java
          Does it and its ConversationManager.java know all the flows beeing executed on the server?

          Is it a bad idea to mess with the flows and flow models at runtime in general? If yes, please, someone stop me.

          Thanks,
          Nils
          Last edited by tohu; Aug 18th, 2011, 04:52 AM.

          Comment

          Working...
          X