polish
This commit is contained in:
@@ -38,10 +38,13 @@ import org.springframework.webflow.core.collection.AttributeMap;
|
|||||||
public class FlowDefinitionResourceFactory {
|
public class FlowDefinitionResourceFactory {
|
||||||
|
|
||||||
private static final String CLASSPATH_SCHEME = "classpath:";
|
private static final String CLASSPATH_SCHEME = "classpath:";
|
||||||
|
|
||||||
private static final String CLASSPATH_STAR_SCHEME = "classpath*:";
|
private static final String CLASSPATH_STAR_SCHEME = "classpath*:";
|
||||||
|
|
||||||
private static final String SLASH = "/";
|
private static final String SLASH = "/";
|
||||||
|
|
||||||
private ResourceLoader resourceLoader;
|
private ResourceLoader resourceLoader;
|
||||||
|
|
||||||
private String basePath;
|
private String basePath;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -119,7 +122,7 @@ public class FlowDefinitionResourceFactory {
|
|||||||
/**
|
/**
|
||||||
* Create an array of flow definition resources from the path pattern location provided.
|
* Create an array of flow definition resources from the path pattern location provided.
|
||||||
* @param pattern the encoded {@link Resource} path pattern.
|
* @param pattern the encoded {@link Resource} path pattern.
|
||||||
* @param attributes the flow definition meta attributes to configure
|
* @param attributes meta attributes to apply to each flow definition resource
|
||||||
* @return the flow definition resources
|
* @return the flow definition resources
|
||||||
*/
|
*/
|
||||||
public FlowDefinitionResource[] createResources(String pattern, AttributeMap attributes) throws IOException {
|
public FlowDefinitionResource[] createResources(String pattern, AttributeMap attributes) throws IOException {
|
||||||
@@ -181,12 +184,12 @@ public class FlowDefinitionResourceFactory {
|
|||||||
* @return the flow id
|
* @return the flow id
|
||||||
*/
|
*/
|
||||||
protected String getFlowId(Resource flowResource) {
|
protected String getFlowId(Resource flowResource) {
|
||||||
|
if (basePath == null) {
|
||||||
|
return getFlowIdFromFileName(flowResource);
|
||||||
|
}
|
||||||
String basePath = this.basePath;
|
String basePath = this.basePath;
|
||||||
String filePath;
|
String filePath;
|
||||||
if (basePath == null) {
|
if (flowResource instanceof ClassPathResource) {
|
||||||
// default to the filename
|
|
||||||
return getFlowIdFromFileName(flowResource);
|
|
||||||
} else if (flowResource instanceof ClassPathResource) {
|
|
||||||
filePath = ((ClassPathResource) flowResource).getPath();
|
filePath = ((ClassPathResource) flowResource).getPath();
|
||||||
// remove classpath scheme
|
// remove classpath scheme
|
||||||
if (basePath.startsWith(CLASSPATH_SCHEME)) {
|
if (basePath.startsWith(CLASSPATH_SCHEME)) {
|
||||||
@@ -194,13 +197,13 @@ public class FlowDefinitionResourceFactory {
|
|||||||
} else if (basePath.startsWith(CLASSPATH_STAR_SCHEME)) {
|
} else if (basePath.startsWith(CLASSPATH_STAR_SCHEME)) {
|
||||||
basePath = basePath.substring(CLASSPATH_STAR_SCHEME.length());
|
basePath = basePath.substring(CLASSPATH_STAR_SCHEME.length());
|
||||||
}
|
}
|
||||||
} else if (!(flowResource instanceof ContextResource)) {
|
} else if (flowResource instanceof ContextResource) {
|
||||||
|
filePath = ((ContextResource) flowResource).getPathWithinContext();
|
||||||
|
} else {
|
||||||
// default to the filename
|
// default to the filename
|
||||||
return getFlowIdFromFileName(flowResource);
|
return getFlowIdFromFileName(flowResource);
|
||||||
} else {
|
|
||||||
filePath = ((ContextResource) flowResource).getPathWithinContext();
|
|
||||||
}
|
}
|
||||||
|
// TODO can this logic be simplified?
|
||||||
int beginIndex = 0;
|
int beginIndex = 0;
|
||||||
int endIndex = filePath.length();
|
int endIndex = filePath.length();
|
||||||
if (filePath.startsWith(SLASH) || !basePath.startsWith(SLASH)) {
|
if (filePath.startsWith(SLASH) || !basePath.startsWith(SLASH)) {
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import org.springframework.web.context.support.ServletContextResourceLoader;
|
|||||||
public class FlowDefinitionResourceFactoryTests extends TestCase {
|
public class FlowDefinitionResourceFactoryTests extends TestCase {
|
||||||
|
|
||||||
private ResourceLoader resourceLoader;
|
private ResourceLoader resourceLoader;
|
||||||
|
|
||||||
private FlowDefinitionResourceFactory factory;
|
private FlowDefinitionResourceFactory factory;
|
||||||
|
|
||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
|
|||||||
Reference in New Issue
Block a user