Added AbstractFlowBuilderFlowRegistryFactoryBean for easy setup of a flow registry containing flows built using AbstractFlowBuilders.

This commit is contained in:
Erwin Vervaet
2007-03-27 19:15:22 +00:00
parent a5070b92f0
commit 67d69ecc6b
11 changed files with 99 additions and 121 deletions

View File

@@ -20,7 +20,6 @@ import org.springframework.binding.mapping.Mapping;
import org.springframework.webflow.engine.Transition;
import org.springframework.webflow.engine.builder.AbstractFlowBuilder;
import org.springframework.webflow.engine.builder.FlowBuilderException;
import org.springframework.webflow.engine.builder.FlowServiceLocator;
import org.springframework.webflow.engine.support.ConfigurableFlowAttributeMapper;
/**
@@ -34,10 +33,6 @@ import org.springframework.webflow.engine.support.ConfigurableFlowAttributeMappe
*/
class PersonDetailFlowBuilder extends AbstractFlowBuilder {
public PersonDetailFlowBuilder(FlowServiceLocator flowServiceLocator) {
super(flowServiceLocator);
}
public void buildInputMapper() throws FlowBuilderException {
Mapping idMapping = mapping().source("id").target("flowScope.id").value();
getFlow().setInputMapper(new DefaultAttributeMapper().addMapping(idMapping));

View File

@@ -1,47 +0,0 @@
/*
* Copyright 2004-2007 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.webflow.samples.phonebook.webflow;
import org.springframework.webflow.definition.registry.FlowDefinitionHolder;
import org.springframework.webflow.definition.registry.FlowDefinitionRegistrar;
import org.springframework.webflow.definition.registry.FlowDefinitionRegistry;
import org.springframework.webflow.definition.registry.StaticFlowDefinitionHolder;
import org.springframework.webflow.engine.builder.FlowAssembler;
import org.springframework.webflow.engine.builder.FlowBuilder;
import org.springframework.webflow.engine.builder.FlowServiceLocator;
/**
* Demonstrates how to register flows programatically.
*
* @author Keith Donald
*/
class PhonebookFlowRegistrar implements FlowDefinitionRegistrar {
private FlowServiceLocator serviceLocator;
public PhonebookFlowRegistrar(FlowServiceLocator serviceLocator) {
this.serviceLocator = serviceLocator;
}
public void registerFlowDefinitions(FlowDefinitionRegistry registry) {
registry.registerFlowDefinition(assemble("detail-flow", new PersonDetailFlowBuilder(serviceLocator)));
registry.registerFlowDefinition(assemble("search-flow", new SearchPersonFlowBuilder(serviceLocator)));
}
private FlowDefinitionHolder assemble(String flowId, FlowBuilder flowBuilder) {
return new StaticFlowDefinitionHolder(new FlowAssembler(flowId, flowBuilder).assembleFlow());
}
}

View File

@@ -16,16 +16,17 @@
package org.springframework.webflow.samples.phonebook.webflow;
import org.springframework.webflow.definition.registry.FlowDefinitionRegistry;
import org.springframework.webflow.engine.builder.AbstractFlowBuildingFlowRegistryFactoryBean;
import org.springframework.webflow.engine.builder.AbstractFlowBuilderFlowRegistryFactoryBean;
/**
* Demonstrates how to populate a flow registry programatically.
*
* @author Keith Donald
*/
public class PhonebookFlowRegistryFactoryBean extends AbstractFlowBuildingFlowRegistryFactoryBean {
public class PhonebookFlowRegistryFactoryBean extends AbstractFlowBuilderFlowRegistryFactoryBean {
protected void doPopulate(FlowDefinitionRegistry registry) {
new PhonebookFlowRegistrar(getFlowServiceLocator()).registerFlowDefinitions(registry);
registerFlowDefinition(registry, "detail-flow", new PersonDetailFlowBuilder());
registerFlowDefinition(registry, "search-flow", new SearchPersonFlowBuilder());
}
}

View File

@@ -20,7 +20,6 @@ import org.springframework.webflow.action.MultiAction;
import org.springframework.webflow.engine.Transition;
import org.springframework.webflow.engine.builder.AbstractFlowBuilder;
import org.springframework.webflow.engine.builder.FlowBuilderException;
import org.springframework.webflow.engine.builder.FlowServiceLocator;
import org.springframework.webflow.engine.support.ConfigurableFlowAttributeMapper;
import org.springframework.webflow.execution.ScopeType;
import org.springframework.webflow.samples.phonebook.SearchCriteria;
@@ -39,10 +38,6 @@ import org.springframework.webflow.samples.phonebook.SearchCriteriaValidator;
*/
class SearchPersonFlowBuilder extends AbstractFlowBuilder {
public SearchPersonFlowBuilder(FlowServiceLocator flowServiceLocator) {
super(flowServiceLocator);
}
public void buildStates() throws FlowBuilderException {
// view search criteria
MultiAction searchFormAction = createSearchFormAction();

View File

@@ -20,7 +20,6 @@ import org.springframework.binding.mapping.Mapping;
import org.springframework.webflow.engine.Transition;
import org.springframework.webflow.engine.builder.AbstractFlowBuilder;
import org.springframework.webflow.engine.builder.FlowBuilderException;
import org.springframework.webflow.engine.builder.FlowServiceLocator;
import org.springframework.webflow.engine.support.ConfigurableFlowAttributeMapper;
/**
@@ -34,10 +33,6 @@ import org.springframework.webflow.engine.support.ConfigurableFlowAttributeMappe
*/
class PersonDetailFlowBuilder extends AbstractFlowBuilder {
public PersonDetailFlowBuilder(FlowServiceLocator flowServiceLocator) {
super(flowServiceLocator);
}
public void buildInputMapper() throws FlowBuilderException {
Mapping idMapping = mapping().source("id").target("flowScope.id").value();
getFlow().setInputMapper(new DefaultAttributeMapper().addMapping(idMapping));

View File

@@ -1,47 +0,0 @@
/*
* Copyright 2004-2007 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.webflow.samples.phonebook.webflow;
import org.springframework.webflow.definition.registry.FlowDefinitionHolder;
import org.springframework.webflow.definition.registry.FlowDefinitionRegistrar;
import org.springframework.webflow.definition.registry.FlowDefinitionRegistry;
import org.springframework.webflow.definition.registry.StaticFlowDefinitionHolder;
import org.springframework.webflow.engine.builder.FlowAssembler;
import org.springframework.webflow.engine.builder.FlowBuilder;
import org.springframework.webflow.engine.builder.FlowServiceLocator;
/**
* Demonstrates how to register flows programatically.
*
* @author Keith Donald
*/
class PhonebookFlowRegistrar implements FlowDefinitionRegistrar {
private FlowServiceLocator serviceLocator;
public PhonebookFlowRegistrar(FlowServiceLocator serviceLocator) {
this.serviceLocator = serviceLocator;
}
public void registerFlowDefinitions(FlowDefinitionRegistry registry) {
registry.registerFlowDefinition(assemble("detail-flow", new PersonDetailFlowBuilder(serviceLocator)));
registry.registerFlowDefinition(assemble("search-flow", new SearchPersonFlowBuilder(serviceLocator)));
}
private FlowDefinitionHolder assemble(String flowId, FlowBuilder flowBuilder) {
return new StaticFlowDefinitionHolder(new FlowAssembler(flowId, flowBuilder).assembleFlow());
}
}

View File

@@ -16,16 +16,17 @@
package org.springframework.webflow.samples.phonebook.webflow;
import org.springframework.webflow.definition.registry.FlowDefinitionRegistry;
import org.springframework.webflow.engine.builder.AbstractFlowBuildingFlowRegistryFactoryBean;
import org.springframework.webflow.engine.builder.AbstractFlowBuilderFlowRegistryFactoryBean;
/**
* Demonstrates how to populate a flow registry programatically.
*
* @author Keith Donald
*/
public class PhonebookFlowRegistryFactoryBean extends AbstractFlowBuildingFlowRegistryFactoryBean {
public class PhonebookFlowRegistryFactoryBean extends AbstractFlowBuilderFlowRegistryFactoryBean {
protected void doPopulate(FlowDefinitionRegistry registry) {
new PhonebookFlowRegistrar(getFlowServiceLocator()).registerFlowDefinitions(registry);
registerFlowDefinition(registry, "detail-flow", new PersonDetailFlowBuilder());
registerFlowDefinition(registry, "search-flow", new SearchPersonFlowBuilder());
}
}

View File

@@ -20,7 +20,6 @@ import org.springframework.webflow.action.MultiAction;
import org.springframework.webflow.engine.Transition;
import org.springframework.webflow.engine.builder.AbstractFlowBuilder;
import org.springframework.webflow.engine.builder.FlowBuilderException;
import org.springframework.webflow.engine.builder.FlowServiceLocator;
import org.springframework.webflow.engine.support.ConfigurableFlowAttributeMapper;
import org.springframework.webflow.execution.ScopeType;
import org.springframework.webflow.samples.phonebook.SearchCriteria;
@@ -39,10 +38,6 @@ import org.springframework.webflow.samples.phonebook.SearchCriteriaValidator;
*/
class SearchPersonFlowBuilder extends AbstractFlowBuilder {
public SearchPersonFlowBuilder(FlowServiceLocator flowServiceLocator) {
super(flowServiceLocator);
}
public void buildStates() throws FlowBuilderException {
// view search criteria
MultiAction searchFormAction = createSearchFormAction();