Class FlowDefinitionResourceFactory


public class FlowDefinitionResourceFactory extends Object
Derivation of SWF-supplied resource factory for flow definitions.

This implementation overrides the behavior of the built-in factory with regard to handling absolute paths while still supporting relative paths.

  • Field Details

  • Constructor Details

    • FlowDefinitionResourceFactory

      public FlowDefinitionResourceFactory(@Nonnull ResourceLoader loader)
      Creates a new flow definition resource factory using the specified resource loader.
      loader - the resource loader
  • Method Details

    • createResource

      public FlowDefinitionResource createResource(@Nullable String basePath, @Nonnull @NotEmpty String path, @Nonnull AttributeMap<Object> attributes, @Nonnull @NotEmpty String flowId)
      Create a flow definition resource from the path location provided. The returned resource will be configured with the provided attributes and flow id.
      basePath - base location to use for a relative path
      path - the encoded Resource path.
      attributes - the flow definition meta attributes to configure
      flowId - the flow definition id to configure
      the flow definition resource
    • createResources

      @Nonnull public Collection<FlowDefinitionResource> createResources(@Nonnull @NotEmpty String basePath, @Nonnull @NotEmpty String pattern, @Nonnull AttributeMap<Object> attributes) throws IOException
      Create an array of flow definition resources from the path pattern location provided.

      Unlike in the explicit case, we must have a base location provided here to properly compute the flow IDs.

      basePath - base location for a relative path and in truncating to obtain the flow IDs
      pattern - the encoded Resource path pattern
      attributes - the flow definition meta attributes to configure
      the flow definition resources
      IOException - if resolving the resources fails
    • getFlowId

      protected String getFlowId(@Nonnull @NotEmpty String basePath, @Nonnull Resource flowResource) throws IOException
      Obtains the flow id from the flow resource. By default, the flow id becomes the portion of the path between the basePath and the filename.

      This is the key override from the SWF version, because it only operates on pattern-based flows, and it assumes a base path to strip. Explicit flow mappings are all assumed to have a flow ID explicitly assigned.

      basePath - the base path applied to the computation
      flowResource - the flow resource
      the flow id
      IOException - if unable to obtain information about the underlying resource
    • truncateFilePath

      @Nonnull @NotEmpty private String truncateFilePath(@Nonnull @NotEmpty String filePath, @Nonnull @NotEmpty String basePath)
      If the file path contains the base path, then the part after the base path is returned, otherwise the entire file path is returned.
      filePath - file path to examine
      basePath - base path to strip
      result as above
    • isAbsolute

      private boolean isAbsolute(@Nonnull @NotEmpty String path)
      Check if a path starts with a known scheme.
      path - path to check
      true iff the path starts with a known scheme
    • removeScheme

      private String removeScheme(@Nonnull @NotEmpty String path)
      Remove the scheme from a path.
      path - path to strip
      the input with the scheme removed.