Results 1 to 5 of 5

Thread: Reloading Flows at Runtime

  1. #1
    Join Date
    Aug 2011
    Posts
    8

    Default 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. #2
    Join Date
    Aug 2011
    Posts
    8

    Default

    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

  3. #3
    Join Date
    Aug 2011
    Posts
    8

    Default

    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 at 08:55 AM.

  4. #4
    Join Date
    Aug 2011
    Posts
    8

    Default

    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

  5. #5
    Join Date
    Aug 2011
    Posts
    8

    Default 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 at 04:52 AM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •