flow model resources
This commit is contained in:
@@ -15,8 +15,6 @@
|
||||
*/
|
||||
package org.springframework.webflow.engine.model.registry;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.webflow.engine.model.FlowModel;
|
||||
import org.springframework.webflow.engine.model.builder.FlowModelBuilder;
|
||||
@@ -37,8 +35,6 @@ import org.springframework.webflow.engine.model.builder.FlowModelBuilderExceptio
|
||||
*/
|
||||
public class DefaultFlowModelHolder implements FlowModelHolder {
|
||||
|
||||
private static final Log logger = LogFactory.getLog(DefaultFlowModelHolder.class);
|
||||
|
||||
/**
|
||||
* The flow model assembled by this assembler.
|
||||
*/
|
||||
@@ -54,12 +50,6 @@ public class DefaultFlowModelHolder implements FlowModelHolder {
|
||||
*/
|
||||
private FlowModelBuilder flowModelBuilder;
|
||||
|
||||
/**
|
||||
* A last modified date for the backing flow definition resource, used to support automatic reassembly on resource
|
||||
* change.
|
||||
*/
|
||||
private long lastModified;
|
||||
|
||||
/**
|
||||
* Creates a new refreshable flow model holder that uses the configured assembler (GOF director) to drive flow
|
||||
* assembly, on initial use and on any resource change or refresh.
|
||||
|
||||
@@ -63,7 +63,6 @@ public abstract class AbstractExternalizedFlowExecutionTests extends AbstractFlo
|
||||
/**
|
||||
* Constructs an externalized flow execution test with given name.
|
||||
* @param name the name of the test
|
||||
* @since 1.0.2
|
||||
*/
|
||||
public AbstractExternalizedFlowExecutionTests(String name) {
|
||||
super(name);
|
||||
@@ -121,6 +120,14 @@ public abstract class AbstractExternalizedFlowExecutionTests extends AbstractFlo
|
||||
new StaticFlowExecutionListenerLoader(executionListeners));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the factory used to create pointers to externalized flow definition resources.
|
||||
* @return the resource factory
|
||||
*/
|
||||
protected FlowDefinitionResourceFactory getResourceFactory() {
|
||||
return resourceFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the flow definition being tested.
|
||||
*/
|
||||
@@ -142,7 +149,7 @@ public abstract class AbstractExternalizedFlowExecutionTests extends AbstractFlo
|
||||
* @return the built flow definition, ready for execution
|
||||
*/
|
||||
protected final Flow buildFlow() {
|
||||
FlowDefinitionResource resource = getResource(resourceFactory);
|
||||
FlowDefinitionResource resource = getResource(getResourceFactory());
|
||||
MockFlowBuilderContext builderContext = new MockFlowBuilderContext(resource.getId(), resource.getAttributes());
|
||||
configureFlowBuilderContext(builderContext);
|
||||
FlowBuilder builder = createFlowBuilder(resource);
|
||||
|
||||
@@ -17,6 +17,7 @@ package org.springframework.webflow.test.execution;
|
||||
|
||||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||
import org.springframework.webflow.config.FlowDefinitionResource;
|
||||
import org.springframework.webflow.config.FlowDefinitionResourceFactory;
|
||||
import org.springframework.webflow.engine.builder.FlowBuilder;
|
||||
import org.springframework.webflow.engine.builder.model.FlowModelFlowBuilder;
|
||||
import org.springframework.webflow.engine.model.builder.FlowModelBuilder;
|
||||
@@ -57,7 +58,7 @@ import org.springframework.webflow.engine.model.registry.FlowModelRegistryImpl;
|
||||
*/
|
||||
public abstract class AbstractXmlFlowExecutionTests extends AbstractExternalizedFlowExecutionTests {
|
||||
|
||||
private FlowModelRegistry flowModelRegistry;
|
||||
private FlowModelRegistry flowModelRegistry = new FlowModelRegistryImpl();
|
||||
|
||||
/**
|
||||
* Constructs a default XML flow execution test.
|
||||
@@ -65,7 +66,6 @@ public abstract class AbstractXmlFlowExecutionTests extends AbstractExternalized
|
||||
*/
|
||||
public AbstractXmlFlowExecutionTests() {
|
||||
super();
|
||||
flowModelRegistry = new FlowModelRegistryImpl();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -74,10 +74,10 @@ public abstract class AbstractXmlFlowExecutionTests extends AbstractExternalized
|
||||
*/
|
||||
public AbstractXmlFlowExecutionTests(String name) {
|
||||
super(name);
|
||||
flowModelRegistry = new FlowModelRegistryImpl();
|
||||
}
|
||||
|
||||
protected FlowBuilder createFlowBuilder(FlowDefinitionResource resource) {
|
||||
protected final FlowBuilder createFlowBuilder(FlowDefinitionResource resource) {
|
||||
registerDependentFlowModels();
|
||||
FlowModelBuilder modelBuilder = new XmlFlowModelBuilder(resource.getPath(), flowModelRegistry);
|
||||
FlowModelHolder modelHolder = new DefaultFlowModelHolder(modelBuilder, resource.getId());
|
||||
flowModelRegistry.registerFlowModel(modelHolder);
|
||||
@@ -88,6 +88,17 @@ public abstract class AbstractXmlFlowExecutionTests extends AbstractExternalized
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Template method subclasses may override to return pointers to "flow model resources" needed to build the
|
||||
* definition of the flow being tested. Typically overridden when the flow being tested extends from another flow.
|
||||
* Default returns null, assuming no inheritance.
|
||||
* @param resourceFactory the resource factory
|
||||
* @return the flow definition model resources
|
||||
*/
|
||||
protected FlowDefinitionResource[] getModelResources(FlowDefinitionResourceFactory resourceFactory) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Template method subclasses may override to register mock implementations of services used locally by the flow
|
||||
* being tested. By default, this method does nothing.
|
||||
@@ -96,4 +107,18 @@ public abstract class AbstractXmlFlowExecutionTests extends AbstractExternalized
|
||||
*/
|
||||
protected void registerMockFlowBeans(ConfigurableBeanFactory flowBeanFactory) {
|
||||
}
|
||||
|
||||
// internal helpers
|
||||
|
||||
private void registerDependentFlowModels() {
|
||||
FlowDefinitionResource[] modelResources = getModelResources(getResourceFactory());
|
||||
if (modelResources != null) {
|
||||
for (int i = 0; i < modelResources.length; i++) {
|
||||
FlowDefinitionResource modelResource = modelResources[i];
|
||||
FlowModelBuilder modelBuilder = new XmlFlowModelBuilder(modelResource.getPath(), flowModelRegistry);
|
||||
flowModelRegistry.registerFlowModel(new DefaultFlowModelHolder(modelBuilder, modelResource.getId()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user