Class AbstractStateMachineModelFactory<S,E>

java.lang.Object
org.springframework.statemachine.config.model.AbstractStateMachineModelFactory<S,E>
Type Parameters:
S - the type of state
E - the type of event
All Implemented Interfaces:
org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanFactoryAware, org.springframework.context.ResourceLoaderAware, StateMachineComponentResolver<S,E>, StateMachineModelFactory<S,E>
Direct Known Subclasses:
RepositoryStateMachineModelFactory, UmlStateMachineModelFactory

public abstract class AbstractStateMachineModelFactory<S,E> extends Object implements StateMachineComponentResolver<S,E>, StateMachineModelFactory<S,E>, org.springframework.beans.factory.BeanFactoryAware, org.springframework.context.ResourceLoaderAware
Base implementation of a StateMachineModelFactory providing some common grounds for various implementations. This factory is able to resolve Actions or Guards either from a BeanFactory if knows, or from manually registered instances. Manually registered actions or guards are needed if those are not created as beans or if whole state machine is working outside of an application context.
Author:
Janne Valkealahti
  • Constructor Details

    • AbstractStateMachineModelFactory

      public AbstractStateMachineModelFactory()
      Instantiates a new abstract state machine model factory.
    • AbstractStateMachineModelFactory

      public AbstractStateMachineModelFactory(org.springframework.core.io.ResourceLoader resourceLoader, StateMachineComponentResolver<S,E> stateMachineComponentResolver)
      Instantiates a new abstract state machine model factory.
      Parameters:
      resourceLoader - the resource loader
      stateMachineComponentResolver - the state machine component resolver
  • Method Details

    • setBeanFactory

      public void setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory) throws org.springframework.beans.BeansException
      Specified by:
      setBeanFactory in interface org.springframework.beans.factory.BeanFactoryAware
      Throws:
      org.springframework.beans.BeansException
    • setResourceLoader

      public void setResourceLoader(org.springframework.core.io.ResourceLoader resourceLoader)
      Specified by:
      setResourceLoader in interface org.springframework.context.ResourceLoaderAware
    • build

      public StateMachineModel<S,E> build(String machineId)
      Description copied from interface: StateMachineModelFactory
      Builds the state machine model with a given machineId. Implementation is free to choose what to do with a given machineId but usually it might map to a different configurations supported by storage or repository in a factory.
      Specified by:
      build in interface StateMachineModelFactory<S,E>
      Parameters:
      machineId - the machine id
      Returns:
      the state machine model
    • build

      public abstract StateMachineModel<S,E> build()
      Description copied from interface: StateMachineModelFactory
      Builds the state machine model.
      Specified by:
      build in interface StateMachineModelFactory<S,E>
      Returns:
      the state machine model
    • setStateMachineComponentResolver

      public void setStateMachineComponentResolver(StateMachineComponentResolver<S,E> stateMachineComponentResolver)
      Sets the state machine component resolver.
      Parameters:
      stateMachineComponentResolver - the state machine component resolver
    • registerAction

      public void registerAction(String id, Action<S,E> action)
      Register Action into factory with a given id.
      Parameters:
      id - the id
      action - the action
    • registerGuard

      public void registerGuard(String id, Guard<S,E> guard)
      Register Guard into factory with a given id.
      Parameters:
      id - the id
      guard - the guard
    • getStateMachineComponentResolver

      public StateMachineComponentResolver<S,E> getStateMachineComponentResolver()
      Gets the state machine component resolver.
      Returns:
      the state machine component resolver
    • resolveAction

      public Action<S,E> resolveAction(String id)
      Resolve action.
      Specified by:
      resolveAction in interface StateMachineComponentResolver<S,E>
      Parameters:
      id - the id
      Returns:
      the action
    • resolveGuard

      public Guard<S,E> resolveGuard(String id)
      Resolve guard.
      Specified by:
      resolveGuard in interface StateMachineComponentResolver<S,E>
      Parameters:
      id - the id
      Returns:
      the guard
    • getBeanFactory

      protected final org.springframework.beans.factory.BeanFactory getBeanFactory()
      Gets the bean factory.
      Returns:
      the bean factory
    • getResourceLoader

      protected org.springframework.core.io.ResourceLoader getResourceLoader()
      Gets the resource loader.
      Returns:
      the resource loader