Class AbstractFlowParser

java.lang.Object
org.springframework.beans.factory.xml.AbstractBeanDefinitionParser
org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser
org.springframework.batch.core.configuration.xml.AbstractFlowParser
All Implemented Interfaces:
org.springframework.beans.factory.xml.BeanDefinitionParser
Direct Known Subclasses:
InlineFlowParser, TopLevelFlowParser

public abstract class AbstractFlowParser extends org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser
Author:
Dave Syer, Michael Minella, Chris Schaefer, Mahmoud Ben Hassine
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected static final String
    Establishes a Decision element.
    protected static final String
    Establishes an End element.
    protected static int
    Used as a suffix to generate unique state names for end transitions.
    protected static final String
    Establishes a Exit Code element.
    protected static final String
    Establishes a Fail element.
    protected static final String
    Establishes a Flow element.
    protected static final String
    Establishes the ID attribute.
    protected static final String
    Establishes a Next attribute.
    protected static final String
    Establishes a Next element.
    protected static final String
    Establishes an On element.
    protected static final String
    Establishes a Restart attribute.
    protected static final String
    Establishes a Split element.
    protected static final String
    Establishes a Step element.
    protected static final String
    Establishes a Stop element.
    protected static final String
    Establishes a To attribute.

    Fields inherited from class org.springframework.beans.factory.xml.AbstractBeanDefinitionParser

    ID_ATTRIBUTE, NAME_ATTRIBUTE
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected static Collection<org.springframework.beans.factory.config.BeanDefinition>
    createTransition(FlowExecutionStatus status, String on, String next, String exitCode, org.springframework.beans.factory.config.BeanDefinition stateDef, org.springframework.beans.factory.xml.ParserContext parserContext, boolean abandon)
     
    protected void
    doParse(Element element, org.springframework.beans.factory.xml.ParserContext parserContext, org.springframework.beans.factory.support.BeanDefinitionBuilder builder)
    Performs the parsing for a flow definition.
    protected void
    findAllReachableElements(String startElement, Map<String,Set<String>> reachableElementMap, Set<String> accumulator)
    Find all of the elements that are reachable from the startElement.
    protected static FlowExecutionStatus
    Gets the batch status from the end transition name by the element.
    protected Class<?>
     
    static Collection<org.springframework.beans.factory.config.BeanDefinition>
    getNextElements(org.springframework.beans.factory.xml.ParserContext parserContext, String stepId, org.springframework.beans.factory.config.BeanDefinition stateDef, Element element)
    Retrieve a list of StateTransition instances from a ParserContext.
    static Collection<org.springframework.beans.factory.config.BeanDefinition>
    getNextElements(org.springframework.beans.factory.xml.ParserContext parserContext, org.springframework.beans.factory.config.BeanDefinition stateDef, Element element)
     
    static org.springframework.beans.factory.config.BeanDefinition
    getStateTransitionReference(org.springframework.beans.factory.xml.ParserContext parserContext, org.springframework.beans.factory.config.BeanDefinition stateDefinition, String on, String next)
    Gets a reference to the state transition.
    protected void
    setJobFactoryRef(String jobFactoryRef)
    Convenience method for subclasses to set the job factory reference if it is available (null is fine, but the quality of error reports is better if it is available).
    protected static void
    verifyUniquePattern(Element transitionElement, List<String> patterns, Element element, org.springframework.beans.factory.xml.ParserContext parserContext)
    Verifies that transitionElement is not in the list of state transition patterns.

    Methods inherited from class org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser

    doParse, getBeanClassName, getParentName, parseInternal

    Methods inherited from class org.springframework.beans.factory.xml.AbstractBeanDefinitionParser

    parse, postProcessComponentDefinition, registerBeanDefinition, resolveId, shouldFireEvents, shouldGenerateId, shouldGenerateIdAsFallback, shouldParseNameAsAliases

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • AbstractFlowParser

      public AbstractFlowParser()
  • Method Details

    • setJobFactoryRef

      protected void setJobFactoryRef(String jobFactoryRef)
      Convenience method for subclasses to set the job factory reference if it is available (null is fine, but the quality of error reports is better if it is available).
      Parameters:
      jobFactoryRef - name of the ref
    • getBeanClass

      protected Class<?> getBeanClass(Element element)
      Overrides:
      getBeanClass in class org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser
    • doParse

      protected void doParse(Element element, org.springframework.beans.factory.xml.ParserContext parserContext, org.springframework.beans.factory.support.BeanDefinitionBuilder builder)
      Performs the parsing for a flow definition.
      Overrides:
      doParse in class org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser
      Parameters:
      element - the top level element containing a flow definition
      parserContext - the ParserContext
    • findAllReachableElements

      protected void findAllReachableElements(String startElement, Map<String,Set<String>> reachableElementMap, Set<String> accumulator)
      Find all of the elements that are reachable from the startElement.
      Parameters:
      startElement - Name of the element to start from
      reachableElementMap - Map of elements that can be reached from the startElement
      accumulator - A collection of reachable element names
    • getNextElements

      public static Collection<org.springframework.beans.factory.config.BeanDefinition> getNextElements(org.springframework.beans.factory.xml.ParserContext parserContext, org.springframework.beans.factory.config.BeanDefinition stateDef, Element element)
      Parameters:
      parserContext - The parser context for the bean factory
      stateDef - The bean definition for the current state
      element - The <step/gt; element to parse
      Returns:
      a collection of StateTransition references
    • getNextElements

      public static Collection<org.springframework.beans.factory.config.BeanDefinition> getNextElements(org.springframework.beans.factory.xml.ParserContext parserContext, String stepId, org.springframework.beans.factory.config.BeanDefinition stateDef, Element element)
      Retrieve a list of StateTransition instances from a ParserContext.
      Parameters:
      parserContext - The parser context for the bean factory
      stepId - The ID of the current state if it is a step state, null otherwise
      stateDef - The bean definition for the current state
      element - The <step/gt; element to parse
      Returns:
      a collection of StateTransition references
    • verifyUniquePattern

      protected static void verifyUniquePattern(Element transitionElement, List<String> patterns, Element element, org.springframework.beans.factory.xml.ParserContext parserContext)
      Verifies that transitionElement is not in the list of state transition patterns.
      Parameters:
      transitionElement - The element to parse
      patterns - A list of patterns on state transitions for this element
      element - The Element representing the source.
      parserContext - The parser context for the bean factory
    • createTransition

      protected static Collection<org.springframework.beans.factory.config.BeanDefinition> createTransition(FlowExecutionStatus status, String on, String next, String exitCode, org.springframework.beans.factory.config.BeanDefinition stateDef, org.springframework.beans.factory.xml.ParserContext parserContext, boolean abandon)
      Parameters:
      status - The batch status that this transition will set. Use BatchStatus.UNKNOWN if not applicable.
      on - The pattern that this transition should match. Use null for "no restriction" (same as "*").
      next - The state to which this transition should go. Use null if not applicable.
      exitCode - The exit code that this transition will set. Use null to default to batchStatus.
      stateDef - The bean definition for the current state
      parserContext - The parser context for the bean factory
      abandon - The abandon flag to be used by the transition.
      Returns:
      a collection of StateTransition references
    • getBatchStatusFromEndTransitionName

      protected static FlowExecutionStatus getBatchStatusFromEndTransitionName(String elementName)
      Gets the batch status from the end transition name by the element.
      Parameters:
      elementName - An end transition element name
      Returns:
      the BatchStatus corresponding to the transition name.
    • getStateTransitionReference

      public static org.springframework.beans.factory.config.BeanDefinition getStateTransitionReference(org.springframework.beans.factory.xml.ParserContext parserContext, org.springframework.beans.factory.config.BeanDefinition stateDefinition, String on, String next)
      Gets a reference to the state transition.
      Parameters:
      parserContext - The parser context
      stateDefinition - A reference to the state implementation
      on - The pattern value
      next - The next step id
      Returns:
      a bean definition for a StateTransition