S
- the type of stateE
- the type of eventpublic abstract class AbstractStateMachineModelFactory<S,E> extends java.lang.Object implements StateMachineComponentResolver<S,E>, StateMachineModelFactory<S,E>, org.springframework.beans.factory.BeanFactoryAware, org.springframework.context.ResourceLoaderAware
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 and Description |
---|
AbstractStateMachineModelFactory()
Instantiates 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.
|
Modifier and Type | Method and Description |
---|---|
abstract StateMachineModel<S,E> |
build()
Builds the state machine model.
|
StateMachineModel<S,E> |
build(java.lang.String machineId)
Builds the state machine model with a given
machineId . |
protected org.springframework.beans.factory.BeanFactory |
getBeanFactory()
Gets the bean factory.
|
protected org.springframework.core.io.ResourceLoader |
getResourceLoader()
Gets the resource loader.
|
StateMachineComponentResolver<S,E> |
getStateMachineComponentResolver()
Gets the state machine component resolver.
|
void |
registerAction(java.lang.String id,
Action<S,E> action)
Register
Action into factory with a given id. |
void |
registerGuard(java.lang.String id,
Guard<S,E> guard)
Register
Guard into factory with a given id. |
Action<S,E> |
resolveAction(java.lang.String id)
Resolve action.
|
Guard<S,E> |
resolveGuard(java.lang.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.
|
public AbstractStateMachineModelFactory()
public AbstractStateMachineModelFactory(org.springframework.core.io.ResourceLoader resourceLoader, StateMachineComponentResolver<S,E> stateMachineComponentResolver)
resourceLoader
- the resource loaderstateMachineComponentResolver
- the state machine component resolverpublic void setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory) throws org.springframework.beans.BeansException
setBeanFactory
in interface org.springframework.beans.factory.BeanFactoryAware
org.springframework.beans.BeansException
public void setResourceLoader(org.springframework.core.io.ResourceLoader resourceLoader)
setResourceLoader
in interface org.springframework.context.ResourceLoaderAware
public StateMachineModel<S,E> build(java.lang.String machineId)
StateMachineModelFactory
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.build
in interface StateMachineModelFactory<S,E>
machineId
- the machine idpublic abstract StateMachineModel<S,E> build()
StateMachineModelFactory
build
in interface StateMachineModelFactory<S,E>
public void setStateMachineComponentResolver(StateMachineComponentResolver<S,E> stateMachineComponentResolver)
stateMachineComponentResolver
- the state machine component resolverpublic void registerAction(java.lang.String id, Action<S,E> action)
Action
into factory with a given id.id
- the idaction
- the actionpublic void registerGuard(java.lang.String id, Guard<S,E> guard)
Guard
into factory with a given id.id
- the idguard
- the guardpublic StateMachineComponentResolver<S,E> getStateMachineComponentResolver()
public Action<S,E> resolveAction(java.lang.String id)
resolveAction
in interface StateMachineComponentResolver<S,E>
id
- the idpublic Guard<S,E> resolveGuard(java.lang.String id)
resolveGuard
in interface StateMachineComponentResolver<S,E>
id
- the idprotected final org.springframework.beans.factory.BeanFactory getBeanFactory()
protected org.springframework.core.io.ResourceLoader getResourceLoader()