This commit is contained in:
@@ -39,6 +39,8 @@ class FlowRegistryBeanDefinitionParser extends AbstractSingleBeanDefinitionParse
|
||||
|
||||
private static final String FLOW_BUILDER_SERVICES_ATTRIBUTE = "flow-builder-services";
|
||||
|
||||
private static final String PARENT_ATTRIBUTE = "parent";
|
||||
|
||||
private static final String FLOW_LOCATION_ELEMENT = "flow-location";
|
||||
|
||||
private static final String FLOW_BUILDER_ELEMENT = "flow-builder";
|
||||
@@ -65,6 +67,8 @@ class FlowRegistryBeanDefinitionParser extends AbstractSingleBeanDefinitionParse
|
||||
|
||||
private static final String FLOW_BUILDER_SERVICES_PROPERTY = "flowBuilderServices";
|
||||
|
||||
private static final String PARENT_PROPERTY = "parent";
|
||||
|
||||
protected Class getBeanClass(Element element) {
|
||||
return FlowRegistryFactoryBean.class;
|
||||
}
|
||||
@@ -78,6 +82,10 @@ class FlowRegistryBeanDefinitionParser extends AbstractSingleBeanDefinitionParse
|
||||
FlowBuilderServicesBeanDefinitionParser.registerDefaultFlowBuilderServicesBeanDefinition(
|
||||
parserContext).getBeanName());
|
||||
}
|
||||
String parent = getParentAttribute(element);
|
||||
if (StringUtils.hasText(parent)) {
|
||||
definitionBuilder.addPropertyReference(PARENT_PROPERTY, parent);
|
||||
}
|
||||
definitionBuilder.addPropertyValue(FLOW_LOCATIONS_PROPERTY, parseLocations(element));
|
||||
definitionBuilder.addPropertyValue(FLOW_BUILDERS_PROPERTY, parseFlowBuilders(element));
|
||||
}
|
||||
@@ -133,4 +141,9 @@ class FlowRegistryBeanDefinitionParser extends AbstractSingleBeanDefinitionParse
|
||||
private String getFlowBuilderServicesAttribute(Element element) {
|
||||
return element.getAttribute(FLOW_BUILDER_SERVICES_ATTRIBUTE);
|
||||
}
|
||||
|
||||
private String getParentAttribute(Element element) {
|
||||
return element.getAttribute(PARENT_ATTRIBUTE);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -39,53 +39,63 @@ import org.springframework.webflow.engine.model.registry.FlowModelRegistryImpl;
|
||||
*/
|
||||
class FlowRegistryFactoryBean implements FactoryBean, InitializingBean {
|
||||
|
||||
private FlowLocation[] flowLocations;
|
||||
|
||||
private FlowBuilderInfo[] flowBuilders;
|
||||
|
||||
private FlowBuilderServices flowBuilderServices;
|
||||
|
||||
private FlowDefinitionRegistry parent;
|
||||
|
||||
/**
|
||||
* The definition registry produced by this factory bean.
|
||||
*/
|
||||
private FlowDefinitionRegistryImpl flowRegistry;
|
||||
|
||||
/**
|
||||
* The model registry produced by this factory bean.
|
||||
* The model registry used to build flow models that can be assembled into registerable Flows.
|
||||
*/
|
||||
private FlowModelRegistryImpl flowModelRegistry;
|
||||
|
||||
/**
|
||||
* Flow definitions defined in external files that should be registered in the registry produced by this factory
|
||||
* bean.
|
||||
*/
|
||||
private FlowLocation[] flowLocations;
|
||||
|
||||
/**
|
||||
* Java {@link FlowBuilder flow builder} classes that should be registered in the registry produced by this factory
|
||||
* bean.
|
||||
*/
|
||||
private FlowBuilderInfo[] flowBuilders;
|
||||
|
||||
/**
|
||||
* The holder for services needed to build flow definitions registered in this registry.
|
||||
*/
|
||||
private FlowBuilderServices flowBuilderServices;
|
||||
|
||||
/**
|
||||
* A helper for creating abstract representation of externalized flow definition resources.
|
||||
*/
|
||||
private FlowDefinitionResourceFactory flowResourceFactory;
|
||||
|
||||
/**
|
||||
* Flow definitions defined in external files that should be registered in the registry produced by this factory
|
||||
* bean.
|
||||
*/
|
||||
public void setFlowLocations(FlowLocation[] flowLocations) {
|
||||
this.flowLocations = flowLocations;
|
||||
}
|
||||
|
||||
/**
|
||||
* Java {@link FlowBuilder flow builder} classes that should be registered in the registry produced by this factory
|
||||
* bean.
|
||||
*/
|
||||
public void setFlowBuilders(FlowBuilderInfo[] flowBuilders) {
|
||||
this.flowBuilders = flowBuilders;
|
||||
}
|
||||
|
||||
/**
|
||||
* The holder for services needed to build flow definitions registered in this registry.
|
||||
*/
|
||||
public void setFlowBuilderServices(FlowBuilderServices flowBuilderServices) {
|
||||
this.flowBuilderServices = flowBuilderServices;
|
||||
}
|
||||
|
||||
/**
|
||||
* The parent of the registry created by this factory bean.
|
||||
*/
|
||||
public void setParent(FlowDefinitionRegistry parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
flowResourceFactory = new FlowDefinitionResourceFactory(flowBuilderServices.getApplicationContext());
|
||||
flowRegistry = new FlowDefinitionRegistryImpl();
|
||||
flowRegistry.setParent(parent);
|
||||
flowModelRegistry = new FlowModelRegistryImpl();
|
||||
registerFlowLocations();
|
||||
registerFlowBuilders();
|
||||
|
||||
@@ -71,6 +71,16 @@ Registers a custom FlowBuilder implementation in this registry.
|
||||
<![CDATA[
|
||||
A reference to a FlowBuilderServices implementation defining custom services needed to build the flows registered in this registry.
|
||||
Optional. For use when one or more custom builder services are required.
|
||||
]]>
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="parent" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
<![CDATA[
|
||||
A reference to this registry's parent. Registries can be organized in a hierarchy. If a child registry does not contain a flow,
|
||||
its parent registry will be queried.
|
||||
]]>
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
|
||||
@@ -34,6 +34,12 @@ public interface FlowDefinitionRegistry extends FlowDefinitionLocator {
|
||||
*/
|
||||
public int getFlowDefinitionCount();
|
||||
|
||||
/**
|
||||
* Returns this registry'es parent registry.
|
||||
* @return the parent flow definition registry, or null if no parent is set
|
||||
*/
|
||||
public FlowDefinitionRegistry getParent();
|
||||
|
||||
/**
|
||||
* Sets this registry's parent registry. When asked by a client to locate a flow definition this registry will query
|
||||
* it's parent if it cannot fulfill the lookup request itself.
|
||||
|
||||
@@ -78,6 +78,10 @@ public class FlowDefinitionRegistryImpl implements FlowDefinitionRegistry {
|
||||
return flowDefinitions.size();
|
||||
}
|
||||
|
||||
public FlowDefinitionRegistry getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
public void setParent(FlowDefinitionRegistry parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
@@ -56,4 +56,9 @@ public class FlowRegistryBeanDefinitionParserTests extends TestCase {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void testParent() {
|
||||
assertNotNull(registry.getParent());
|
||||
assertEquals("parentFlow", registry.getParent().getFlowDefinition("parentFlow").getId());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
http://www.springframework.org/schema/webflow-config
|
||||
http://www.springframework.org/schema/webflow-config/spring-webflow-config-2.0.xsd">
|
||||
|
||||
<webflow:flow-registry id="flowRegistry">
|
||||
<webflow:flow-registry id="flowRegistry" parent="parentRegistry">
|
||||
<webflow:flow-location id="flow" path="org/springframework/webflow/config/flow.xml">
|
||||
<webflow:flow-definition-attributes>
|
||||
<webflow:attribute name="foo" value="bar" />
|
||||
@@ -26,4 +26,8 @@
|
||||
</webflow:flow-builder>
|
||||
</webflow:flow-registry>
|
||||
|
||||
<webflow:flow-registry id="parentRegistry">
|
||||
<webflow:flow-location id="parentFlow" path="org/springframework/webflow/config/flow.xml" />
|
||||
</webflow:flow-registry>
|
||||
|
||||
</beans>
|
||||
Reference in New Issue
Block a user