FlowDefinitionResource now has a public static helper method named conventionalFlowId that implements conventions based flow id calculation logic.

This commit is contained in:
Erwin Vervaet
2006-12-27 16:11:17 +00:00
parent 0528fd24f6
commit bf951c7e35
2 changed files with 18 additions and 3 deletions

View File

@@ -35,6 +35,8 @@ Package org.springframework.webflow.conversation
Package org.springframework.webflow.definition
* Added debug logging to FlowDefinitionRegistryImpl.
* FlowDefinitionResource now has a public static helper method named conventionalFlowId that implements
conventions based flow id calculation logic.
Package org.springframework.webflow.engine
* The methods getMatchingCriteria, getExecutionCriteria, getTargetStateResolver, and canExecute

View File

@@ -52,12 +52,21 @@ public class FlowDefinitionResource implements Serializable {
/**
* Creates a new externalized flow definition resource. The flow id assigned will be
* the same name as the externalized resource's filename, excluding the extension.
* @param location the flow resource location.
* @param location the flow resource location
*/
public FlowDefinitionResource(Resource location) {
Assert.notNull(location, "The location of the externalized flow definition is required");
init(conventionalFlowId(location), location, null);
}
/**
* Creates a new externalized flow definition resource. The flow id assigned will be
* the same name as the externalized resource's filename, excluding the extension.
* @param location the flow resource location
* @param attributes flow definition attributes to be assigned
*/
public FlowDefinitionResource(Resource location, AttributeMap attributes) {
init(conventionalFlowId(location), location, attributes);
}
/**
* Creates a new externalized flow definition.
@@ -128,12 +137,16 @@ public class FlowDefinitionResource implements Serializable {
this.attributes = CollectionUtils.EMPTY_ATTRIBUTE_MAP;
}
}
// public utilities
/**
* Returns the flow id assigned to the flow definition contained in given resource.
* By convention this will be the filename of the resource, excluding extension.
* @see FlowDefinitionResource#FlowDefinitionResource(Resource)
* @see FlowDefinitionResource#FlowDefinitionResource(Resource, AttributeMap)
*/
private String conventionalFlowId(Resource location) {
public static String conventionalFlowId(Resource location) {
String fileName = location.getFilename();
int extensionIndex = fileName.lastIndexOf('.');
if (extensionIndex != -1) {