copyright / docs
This commit is contained in:
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* Copyright 2004-2008 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.config;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* Copyright 2004-2008 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.config;
|
||||
|
||||
import org.springframework.beans.factory.config.BeanDefinitionHolder;
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* Copyright 2004-2008 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.config;
|
||||
|
||||
import org.springframework.core.io.Resource;
|
||||
@@ -20,7 +35,13 @@ public class FlowDefinitionResource {
|
||||
|
||||
private AttributeMap attributes;
|
||||
|
||||
FlowDefinitionResource(String flowId, Resource path, AttributeMap attributes) {
|
||||
/**
|
||||
* Creates a new flow definition resource
|
||||
* @param flowId the flow id
|
||||
* @param path the location of the resource
|
||||
* @param attributes meta-attributes describing the flow resource
|
||||
*/
|
||||
public FlowDefinitionResource(String flowId, Resource path, AttributeMap attributes) {
|
||||
this.id = flowId;
|
||||
this.path = path;
|
||||
this.attributes = attributes;
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* Copyright 2004-2008 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.config;
|
||||
|
||||
import java.io.File;
|
||||
@@ -12,26 +27,59 @@ import org.springframework.core.io.support.ResourcePatternResolver;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.webflow.core.collection.AttributeMap;
|
||||
|
||||
/**
|
||||
* A factory for creating flow definition resources that serve as pointers to external Flow definition files.
|
||||
*
|
||||
* @author Keith Donald
|
||||
*/
|
||||
public class FlowDefinitionResourceFactory {
|
||||
|
||||
private ResourceLoader resourceLoader;
|
||||
|
||||
/**
|
||||
* Creates a new flow definition resource factory using a default resource loader.
|
||||
*/
|
||||
public FlowDefinitionResourceFactory() {
|
||||
this.resourceLoader = new DefaultResourceLoader();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new flow definition resource factory using the specified resource loader.
|
||||
* @param resourceLoader the resource loader
|
||||
*/
|
||||
public FlowDefinitionResourceFactory(ResourceLoader resourceLoader) {
|
||||
Assert.notNull(resourceLoader, "The resource loader cannot be null");
|
||||
this.resourceLoader = resourceLoader;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a flow definition resource from the path location provided.
|
||||
* @param path the encoded {@link Resource} path.
|
||||
* @return the flow definition resource
|
||||
*/
|
||||
public FlowDefinitionResource createResource(String path) {
|
||||
return createResource(path, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a flow definition resource from the path location provided. The returned resource will be configured with
|
||||
* the provided attributes.
|
||||
* @param path the encoded {@link Resource} path.
|
||||
* @param attributes the flow definition meta attributes to configure
|
||||
* @return the flow definition resource
|
||||
*/
|
||||
public FlowDefinitionResource createResource(String path, AttributeMap attributes) {
|
||||
return createResource(path, attributes, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a flow definition resource from the path location provided. The returned resource will be configured with
|
||||
* the provided attributes and flow id.
|
||||
* @param path the encoded {@link Resource} path.
|
||||
* @param attributes the flow definition meta attributes to configure
|
||||
* @param flowId the flow definition id to configure
|
||||
* @return the flow definition resource
|
||||
*/
|
||||
public FlowDefinitionResource createResource(String path, AttributeMap attributes, String flowId) {
|
||||
Resource resource = resourceLoader.getResource(path);
|
||||
if (flowId == null || flowId.length() == 0) {
|
||||
@@ -40,6 +88,11 @@ public class FlowDefinitionResourceFactory {
|
||||
return new FlowDefinitionResource(flowId, resource, attributes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an array of flow definition resources from the path pattern location provided.
|
||||
* @param pattern the encoded {@link Resource} path pattern.
|
||||
* @return the flow definition resources
|
||||
*/
|
||||
public FlowDefinitionResource[] createResources(String pattern) throws IOException {
|
||||
if (resourceLoader instanceof ResourcePatternResolver) {
|
||||
ResourcePatternResolver resolver = (ResourcePatternResolver) resourceLoader;
|
||||
@@ -56,17 +109,36 @@ public class FlowDefinitionResourceFactory {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a file-based based resource from the file path provided.
|
||||
* @param path the {@link FileSystemResource} path
|
||||
* @return the file-based flow definition resource
|
||||
*/
|
||||
public FlowDefinitionResource createFileResource(String path) {
|
||||
Resource resource = new FileSystemResource(new File(path));
|
||||
return new FlowDefinitionResource(getFlowId(resource), resource, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a classpath-based resource from the path provided.
|
||||
* @param path the {@link ClassPathResource} path
|
||||
* @param clazz to specify if the path should be relative to another class
|
||||
* @return the classpath-based flow definition resource
|
||||
*/
|
||||
public FlowDefinitionResource createClassPathResource(String path, Class clazz) {
|
||||
Resource resource = new ClassPathResource(path, clazz);
|
||||
return new FlowDefinitionResource(getFlowId(resource), resource, null);
|
||||
}
|
||||
|
||||
private String getFlowId(Resource flowResource) {
|
||||
// subclassing hooks
|
||||
|
||||
/**
|
||||
* Obtains the flow id from the flow resource. By default, the flow id becomes the filename of the resource minus
|
||||
* the extension. Subclasses may override.
|
||||
* @param flowResource the flow resource
|
||||
* @return the flow id
|
||||
*/
|
||||
protected String getFlowId(Resource flowResource) {
|
||||
String fileName = flowResource.getFilename();
|
||||
int extensionIndex = fileName.lastIndexOf('.');
|
||||
if (extensionIndex != -1) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2004-2007 the original author or authors.
|
||||
* Copyright 2004-2008 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.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2004-2007 the original author or authors.
|
||||
* Copyright 2004-2008 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.
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* Copyright 2004-2008 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.config;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2004-2007 the original author or authors.
|
||||
* Copyright 2004-2008 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.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2004-2007 the original author or authors.
|
||||
* Copyright 2004-2008 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.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2004-2007 the original author or authors.
|
||||
* Copyright 2004-2008 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.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2004-2007 the original author or authors.
|
||||
* Copyright 2004-2008 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.
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* Copyright 2004-2008 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.config;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2004-2007 the original author or authors.
|
||||
* Copyright 2004-2008 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.
|
||||
@@ -31,7 +31,7 @@ import org.springframework.util.xml.DomUtils;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
/**
|
||||
* {@link BeanDefinitionParser} for the flow <code><registry></code> tag.
|
||||
* {@link BeanDefinitionParser} for the flow <code><flow-registry></code> tag.
|
||||
*
|
||||
* @author Keith Donald
|
||||
*/
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* Copyright 2004-2008 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.config;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2004-2007 the original author or authors.
|
||||
* Copyright 2004-2008 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.
|
||||
|
||||
Reference in New Issue
Block a user