Class AbstractStateMachineModelFactory<S,E>
java.lang.Object
org.springframework.statemachine.config.model.AbstractStateMachineModelFactory<S,E>
- Type Parameters:
S- the type of stateE- 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.-
Constructor Summary
ConstructorsConstructorDescriptionInstantiates a new abstract state machine model factory.AbstractStateMachineModelFactory(org.springframework.core.io.ResourceLoader resourceLoader, StateMachineComponentResolver<S, E> stateMachineComponentResolver) Instantiates a new abstract state machine model factory. -
Method Summary
Modifier and TypeMethodDescriptionabstract StateMachineModel<S,E> build()Builds the state machine model.Builds the state machine model with a givenmachineId.protected final org.springframework.beans.factory.BeanFactoryGets the bean factory.protected org.springframework.core.io.ResourceLoaderGets the resource loader.Gets the state machine component resolver.voidregisterAction(String id, Action<S, E> action) RegisterActioninto factory with a given id.voidregisterGuard(String id, Guard<S, E> guard) RegisterGuardinto factory with a given id.resolveAction(String id) Resolve action.resolveGuard(String id) Resolve guard.voidsetBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory) voidsetResourceLoader(org.springframework.core.io.ResourceLoader resourceLoader) voidsetStateMachineComponentResolver(StateMachineComponentResolver<S, E> stateMachineComponentResolver) Sets the state machine component resolver.
-
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 loaderstateMachineComponentResolver- the state machine component resolver
-
-
Method Details
-
setBeanFactory
public void setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory) throws org.springframework.beans.BeansException - Specified by:
setBeanFactoryin interfaceorg.springframework.beans.factory.BeanFactoryAware- Throws:
org.springframework.beans.BeansException
-
setResourceLoader
public void setResourceLoader(org.springframework.core.io.ResourceLoader resourceLoader) - Specified by:
setResourceLoaderin interfaceorg.springframework.context.ResourceLoaderAware
-
build
Description copied from interface:StateMachineModelFactoryBuilds the state machine model with a givenmachineId. Implementation is free to choose what to do with a givenmachineIdbut usually it might map to a different configurations supported by storage or repository in a factory.- Specified by:
buildin interfaceStateMachineModelFactory<S,E> - Parameters:
machineId- the machine id- Returns:
- the state machine model
-
build
Description copied from interface:StateMachineModelFactoryBuilds the state machine model.- Specified by:
buildin interfaceStateMachineModelFactory<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
RegisterActioninto factory with a given id.- Parameters:
id- the idaction- the action
-
registerGuard
RegisterGuardinto factory with a given id.- Parameters:
id- the idguard- the guard
-
getStateMachineComponentResolver
Gets the state machine component resolver.- Returns:
- the state machine component resolver
-
resolveAction
Resolve action.- Specified by:
resolveActionin interfaceStateMachineComponentResolver<S,E> - Parameters:
id- the id- Returns:
- the action
-
resolveGuard
Resolve guard.- Specified by:
resolveGuardin interfaceStateMachineComponentResolver<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
-