Class AbstractStateMachineFactory<S,E>
java.lang.Object
org.springframework.statemachine.support.LifecycleObjectSupport
org.springframework.statemachine.config.AbstractStateMachineFactory<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.beans.factory.BeanNameAware,org.springframework.beans.factory.DisposableBean,org.springframework.beans.factory.InitializingBean,org.springframework.context.Lifecycle,org.springframework.context.Phased,org.springframework.context.SmartLifecycle,StateMachineFactory<S,,E> StateMachineReactiveLifecycle
- Direct Known Subclasses:
ObjectStateMachineFactory
public abstract class AbstractStateMachineFactory<S,E>
extends LifecycleObjectSupport
implements StateMachineFactory<S,E>, org.springframework.beans.factory.BeanNameAware
Base
StateMachineFactory implementation building StateMachines.- Author:
- Janne Valkealahti
-
Field Summary
Fields inherited from interface org.springframework.context.SmartLifecycle
DEFAULT_PHASE -
Constructor Summary
ConstructorsConstructorDescriptionAbstractStateMachineFactory(StateMachineModel<S, E> defaultStateMachineModel, StateMachineModelFactory<S, E> stateMachineModelFactory) Instantiates a new abstract state machine factory. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract RegionState<S,E> buildRegionStateInternal(S id, Collection<Region<S, E>> regions, Collection<E> deferred, Collection<Function<StateContext<S, E>, reactor.core.publisher.Mono<Void>>> entryActions, Collection<Function<StateContext<S, E>, reactor.core.publisher.Mono<Void>>> exitActions, PseudoState<S, E> pseudoState, StateMachineModel<S, E> stateMachineModel) buildStateInternal(S id, Collection<E> deferred, Collection<Function<StateContext<S, E>, reactor.core.publisher.Mono<Void>>> entryActions, Collection<Function<StateContext<S, E>, reactor.core.publisher.Mono<Void>>> exitActions, Collection<Function<StateContext<S, E>, reactor.core.publisher.Mono<Void>>> stateActions, PseudoState<S, E> pseudoState, StateMachineModel<S, E> stateMachineModel) protected abstract StateMachine<S,E> buildStateMachineInternal(Collection<State<S, E>> states, Collection<Transition<S, E>> transitions, State<S, E> initialState, Transition<S, E> initialTransition, org.springframework.messaging.Message<E> initialEvent, ExtendedState extendedState, PseudoState<S, E> historyState, Boolean contextEventsEnabled, org.springframework.beans.factory.BeanFactory beanFactory, String beanName, String machineId, UUID uuid, StateMachineModel<S, E> stateMachineModel) Build a newStateMachineinstance.getStateMachine(String machineId) Build a newStateMachineinstance with a given machine id.getStateMachine(UUID uuid) Build a newStateMachineinstance with a given machine uuid.getStateMachine(UUID uuid, String machineId) Main constructor that create aStateMachine.protected org.springframework.beans.factory.BeanFactoryresolveBeanFactory(StateMachineModel<S, E> stateMachineModel) protected StateMachineModel<S,E> resolveStateMachineModel(String machineId) voidsetBeanName(String name) voidsetContextEventsEnabled(Boolean contextEvents) Instructs this factory to enable application context events.voidsetHandleAutostartup(boolean handleAutostartup) Instructs this factory to handle auto-start flag manually by calling lifecycle start method.voidsetStateMachineMonitor(StateMachineMonitor<S, E> stateMachineMonitor) Set state machine monitor.Methods inherited from class org.springframework.statemachine.support.LifecycleObjectSupport
afterPropertiesSet, destroy, doDestroy, doPostStartReactively, doPostStopReactively, doPreStartReactively, doPreStopReactively, getBeanFactory, getPhase, isAutoStartup, isRunning, onInit, setAutoStartup, setBeanFactory, setPhase, start, startReactively, stop, stopReactivelyMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.context.SmartLifecycle
stop
-
Constructor Details
-
AbstractStateMachineFactory
public AbstractStateMachineFactory(StateMachineModel<S, E> defaultStateMachineModel, StateMachineModelFactory<S, E> stateMachineModelFactory) Instantiates a new abstract state machine factory.- Parameters:
defaultStateMachineModel- the default state machine modelstateMachineModelFactory- the state machine model factory
-
-
Method Details
-
setBeanName
- Specified by:
setBeanNamein interfaceorg.springframework.beans.factory.BeanNameAware
-
getStateMachine
Description copied from interface:StateMachineFactoryBuild a newStateMachineinstance.- Specified by:
getStateMachinein interfaceStateMachineFactory<S,E> - Returns:
- a new state machine instance.
-
getStateMachine
Description copied from interface:StateMachineFactoryBuild a newStateMachineinstance with a given machine id.- Specified by:
getStateMachinein interfaceStateMachineFactory<S,E> - Parameters:
machineId- the machine id- Returns:
- a new state machine instance.
-
getStateMachine
Description copied from interface:StateMachineFactoryBuild a newStateMachineinstance with a given machine uuid.- Specified by:
getStateMachinein interfaceStateMachineFactory<S,E> - Parameters:
uuid- to be used internally- Returns:
- a new state machine instance.
-
getStateMachine
Main constructor that create aStateMachine.- Parameters:
uuid- for internal usage. Can be null, in that case a random one will be generated.machineId- represent a user Id, up to you to set what you want.- Returns:
- a
StateMachine
-
setHandleAutostartup
public void setHandleAutostartup(boolean handleAutostartup) Instructs this factory to handle auto-start flag manually by calling lifecycle start method.- Parameters:
handleAutostartup- the new handle autostartup
-
setContextEventsEnabled
Instructs this factory to enable application context events.- Parameters:
contextEvents- the new context events enabled
-
setStateMachineMonitor
Set state machine monitor.- Parameters:
stateMachineMonitor- the state machine monitor
-
resolveBeanFactory
protected org.springframework.beans.factory.BeanFactory resolveBeanFactory(StateMachineModel<S, E> stateMachineModel) -
resolveStateMachineModel
-
buildStateMachineInternal
protected abstract StateMachine<S,E> buildStateMachineInternal(Collection<State<S, E>> states, Collection<Transition<S, E>> transitions, State<S, E> initialState, Transition<S, E> initialTransition, org.springframework.messaging.Message<E> initialEvent, ExtendedState extendedState, PseudoState<S, E> historyState, Boolean contextEventsEnabled, org.springframework.beans.factory.BeanFactory beanFactory, String beanName, String machineId, UUID uuid, StateMachineModel<S, E> stateMachineModel) -
buildStateInternal
protected abstract State<S,E> buildStateInternal(S id, Collection<E> deferred, Collection<Function<StateContext<S, E>, reactor.core.publisher.Mono<Void>>> entryActions, Collection<Function<StateContext<S, E>, reactor.core.publisher.Mono<Void>>> exitActions, Collection<Function<StateContext<S, E>, reactor.core.publisher.Mono<Void>>> stateActions, PseudoState<S, E> pseudoState, StateMachineModel<S, E> stateMachineModel) -
buildRegionStateInternal
protected abstract RegionState<S,E> buildRegionStateInternal(S id, Collection<Region<S, E>> regions, Collection<E> deferred, Collection<Function<StateContext<S, E>, reactor.core.publisher.Mono<Void>>> entryActions, Collection<Function<StateContext<S, E>, reactor.core.publisher.Mono<Void>>> exitActions, PseudoState<S, E> pseudoState, StateMachineModel<S, E> stateMachineModel)
-