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 Action
s or Guard
s 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
ConstructorDescriptionInstantiates 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.BeanFactory
Gets the bean factory.protected org.springframework.core.io.ResourceLoader
Gets the resource loader.Gets the state machine component resolver.void
registerAction
(String id, Action<S, E> action) RegisterAction
into factory with a given id.void
registerGuard
(String id, Guard<S, E> guard) RegisterGuard
into factory with a given id.resolveAction
(String id) Resolve action.resolveGuard
(String id) Resolve guard.void
setBeanFactory
(org.springframework.beans.factory.BeanFactory beanFactory) void
setResourceLoader
(org.springframework.core.io.ResourceLoader resourceLoader) void
setStateMachineComponentResolver
(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:
setBeanFactory
in interfaceorg.springframework.beans.factory.BeanFactoryAware
- Throws:
org.springframework.beans.BeansException
-
setResourceLoader
public void setResourceLoader(org.springframework.core.io.ResourceLoader resourceLoader) - Specified by:
setResourceLoader
in interfaceorg.springframework.context.ResourceLoaderAware
-
build
Description copied from interface:StateMachineModelFactory
Builds the state machine model with a givenmachineId
. Implementation is free to choose what to do with a givenmachineId
but usually it might map to a different configurations supported by storage or repository in a factory.- Specified by:
build
in interfaceStateMachineModelFactory<S,
E> - Parameters:
machineId
- the machine id- Returns:
- the state machine model
-
build
Description copied from interface:StateMachineModelFactory
Builds the state machine model.- Specified by:
build
in 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
RegisterAction
into factory with a given id.- Parameters:
id
- the idaction
- the action
-
registerGuard
RegisterGuard
into 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:
resolveAction
in interfaceStateMachineComponentResolver<S,
E> - Parameters:
id
- the id- Returns:
- the action
-
resolveGuard
Resolve guard.- Specified by:
resolveGuard
in 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
-