/** * 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); }
/** * Create an array of flow definition resources from the path pattern location provided. * @param pattern the encoded {@link Resource} path pattern. * @param attributes meta attributes to apply to each flow definition resource * @return the flow definition resources */ public FlowDefinitionResource[] createResources(String pattern, AttributeMap<Object> attributes) throws IOException { if (resourceLoader instanceof ResourcePatternResolver) { ResourcePatternResolver resolver = (ResourcePatternResolver) resourceLoader; Resource[] resources; if (basePath == null) { resources = resolver.getResources(pattern); } else { if (basePath.endsWith(SLASH) || pattern.startsWith(SLASH)) { resources = resolver.getResources(basePath + pattern); } else { resources = resolver.getResources(basePath + SLASH + pattern); } } FlowDefinitionResource[] flowResources = new FlowDefinitionResource[resources.length]; for (int i = 0; i < resources.length; i++) { Resource resource = resources[i]; flowResources[i] = new FlowDefinitionResource(getFlowId(resource), resource, attributes); } return flowResources; } else { throw new IllegalStateException( "Cannot create flow definition resources from patterns without a ResourceLoader configured that is a ResourcePatternResolver"); } }
/** * 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<Object> attributes, String flowId) { Resource resource; if (basePath == null) { resource = resourceLoader.getResource(path); } else { try { String basePath = this.basePath; if (!basePath.endsWith(SLASH)) { // the basePath must end with a slash to create a relative resource basePath = basePath + SLASH; } resource = resourceLoader.getResource(basePath).createRelative(path); } catch (IOException e) { throw new IllegalStateException("The base path cannot be resolved from '" + basePath + "': " + e.getMessage()); } } if (flowId == null || flowId.length() == 0) { flowId = getFlowId(resource); } return new FlowDefinitionResource(flowId, resource, attributes); }
/** * 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); }
/** * 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); }
/** * 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 an array of flow definition resources from the path pattern location provided. * @param pattern the encoded {@link Resource} path pattern. * @param attributes meta attributes to apply to each flow definition resource * @return the flow definition resources */ public FlowDefinitionResource[] createResources(String pattern, AttributeMap<Object> attributes) throws IOException { if (resourceLoader instanceof ResourcePatternResolver) { ResourcePatternResolver resolver = (ResourcePatternResolver) resourceLoader; Resource[] resources; if (basePath == null) { resources = resolver.getResources(pattern); } else { if (basePath.endsWith(SLASH) || pattern.startsWith(SLASH)) { resources = resolver.getResources(basePath + pattern); } else { resources = resolver.getResources(basePath + SLASH + pattern); } } FlowDefinitionResource[] flowResources = new FlowDefinitionResource[resources.length]; for (int i = 0; i < resources.length; i++) { Resource resource = resources[i]; flowResources[i] = new FlowDefinitionResource(getFlowId(resource), resource, attributes); } return flowResources; } else { throw new IllegalStateException( "Cannot create flow definition resources from patterns without a ResourceLoader configured that is a ResourcePatternResolver"); } }
/** * Create an array of flow definition resources from the path pattern location provided. * @param pattern the encoded {@link Resource} path pattern. * @param attributes meta attributes to apply to each flow definition resource * @return the flow definition resources */ public FlowDefinitionResource[] createResources(String pattern, AttributeMap attributes) throws IOException { if (resourceLoader instanceof ResourcePatternResolver) { ResourcePatternResolver resolver = (ResourcePatternResolver) resourceLoader; Resource[] resources; if (basePath == null) { resources = resolver.getResources(pattern); } else { if (basePath.endsWith(SLASH) || pattern.startsWith(SLASH)) { resources = resolver.getResources(basePath + pattern); } else { resources = resolver.getResources(basePath + SLASH + pattern); } } FlowDefinitionResource[] flowResources = new FlowDefinitionResource[resources.length]; for (int i = 0; i < resources.length; i++) { Resource resource = resources[i]; flowResources[i] = new FlowDefinitionResource(getFlowId(resource), resource, attributes); } return flowResources; } else { throw new IllegalStateException( "Cannot create flow definition resources from patterns without a ResourceLoader configured that is a ResourcePatternResolver"); } }
/** * 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<Object> attributes, String flowId) { Resource resource; if (basePath == null) { resource = resourceLoader.getResource(path); } else { try { String basePath = this.basePath; if (!basePath.endsWith(SLASH)) { // the basePath must end with a slash to create a relative resource basePath = basePath + SLASH; } resource = resourceLoader.getResource(basePath).createRelative(path); } catch (IOException e) { throw new IllegalStateException("The base path cannot be resolved from '" + basePath + "': " + e.getMessage()); } } if (flowId == null || flowId.length() == 0) { flowId = getFlowId(resource); } return new FlowDefinitionResource(flowId, resource, attributes); }
/** * 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; if (basePath == null) { resource = resourceLoader.getResource(path); } else { try { String basePath = this.basePath; if (!basePath.endsWith(SLASH)) { // the basePath must end with a slash to create a relative resource basePath = basePath + SLASH; } resource = resourceLoader.getResource(basePath).createRelative(path); } catch (IOException e) { throw new IllegalStateException("The base path cannot be resolved from '" + basePath + "': " + e.getMessage()); } } if (flowId == null || flowId.length() == 0) { flowId = getFlowId(resource); } return new FlowDefinitionResource(flowId, resource, attributes); }
flowResources.add(new FlowDefinitionResource(getFlowId(basePath, resource), resource, attributes));
return new FlowDefinitionResource(flowId, resource, attributes);