Commit Graph

315 Commits

Author SHA1 Message Date
jvalkeal
dbb028b38e Support executing state action with timeout
- Add new concepts around executing state do actions
  allowing to use timeouts via StateDoActionPolicy.
- Global config per machine or via event headers.
- Backport #501
- Relates #504
2018-02-15 15:52:51 +02:00
jvalkeal
cbe2615c14 Merge spring-statemachine-core from 1.2.x
- Merge spring-statemachine-core/src which for some
  reason is not up to date in master/1.2.x anymore.
- Relates #504
2018-02-14 09:20:25 +02:00
jvalkeal
a4d43131ea Add support for completion transitions
- Currently into as internal new feature, add state
  completed concecept and use it in various places.
- Main focus for this commit is to add support using
  anonymous transitions with state do actions which
  requires proper completion schematics.
- Internal functionality here will probably expose to
  user level in future releases using various other
  concepts.
- Backport #466
- Relates #504
2018-02-13 12:37:04 +02:00
Marco Primi
6743d42792 Add getter for state actions
State has getters for entry and exit actions but no getter for state actions.

 - Add State::getStateActions() in State
 - Implement in AbstractState
 - Update tests

https://github.com/spring-projects/spring-statemachine/issues/502
2018-02-12 16:07:46 -08:00
Janne Valkealahti
c90baa2624 Fix typo in transition conflict
- Changing unfortunate typo conflight vs. conflict.
- Also add some docs for transition conflict.
- Relates to #456
- Relates to #476
2018-01-23 09:57:34 +00:00
Janne Valkealahti
12a48ee443 Add configuration tests for StateMachineModelFactory
- While original issue is already fixed in 1.2.x, adding
  specific tests for checking if config is coming from model
  or adapter.
- Fixes #459
2018-01-23 09:56:27 +00:00
Janne Valkealahti
7c8b93bd45 Conflicting transitions cause undefined order behaviour
- Add new TransitionConflightPolicy and allow to configure
  it via an adapter interfaces.
- For now, use it in TransitionComparator which sorts transitions
  based on source states. This gives PARENT and CHILD sorting
  and allows to choose conflicting transitions either from parent
  or child.
- Add new sync thread used in submachines so that one thread is used
  in a whole call stach per machine(regions still get their own as well
  as a root machine).
- Fixes #456
2018-01-23 09:56:27 +00:00
Janne Valkealahti
f4f904bb6e Find correct super type generics for configurer adapter
- Naively with StateMachineConfigurerAdapter or EnumStateMachineConfigurerAdapter
  only immediate super type were checked to find user level generics to
  instruct IOC for proper resolvable types. This worked with almost all cases
  except if user created new base type out from StateMachineConfigurerAdapter and
  bean id didn't match what what was trying to get autowired if multiple adapters
  were in use.
- Correctly find resolvable type as StateMachineConfigurerAdapter in ResolvableType
  which finds an exact correct type to get generics.
- Fixes #454
2018-01-23 09:56:27 +00:00
Janne Valkealahti
6147a81ea9 Allow to define extended state variables during persist
- Now in AbstractPersistingStateMachineInterceptor it is possible
  to use a Function to define which variables are persisted. This
  is for cases where it is not desirable to persist some variables
  for variours reasons.
- Relates to #423
2018-01-23 09:56:27 +00:00
Janne Valkealahti
cdba5af330 Fix extended state handling during reset
- Instead of changing extended state object, use existing one
  by clearing it and setting new values from context.
- Fixes #447
2018-01-23 09:56:27 +00:00
Janne Valkealahti
916ab2bd09 Add stop logic to DefaultStateMachineService
- Now implementing DisposableBean and clearing/stopping
  machines if service is destroyed.
- Relates to #432
2018-01-23 09:56:27 +00:00
Janne Valkealahti
ade57d6638 Add start/stop feature to DefaultStateMachineService
- Add new interface methods to StateMachineService to ease
  starting and stopping when acquiring or releasing machines.
- Relates to #432
2018-01-23 09:56:27 +00:00
Janne Valkealahti
2a53b4eee5 Fix threading issues
- In AbstractStateMachine and DefaultStateMachineExecutor
  do a little more synchronisation so that submachine is allowed
  to do its run-to-completion before parent machine can do its
  own transitions. This should fix use cases, when submachine
  starts, does its transitions and actions, parent wont try to
  do its own triggerless transtions.
- Adding some new tests and fixing one other sync issue with end state.
- Relates to #442
2018-01-23 09:56:27 +00:00
Janne Valkealahti
6ba231af2e Make use of kryo more configurable
- Move away from thread local in favour of using
  kryo pooling.
- New interface StateMachineSerialisationService
  with KryoStateMachineSerialisationService.
- Try to work via constructors for instead of full blown
  configuration as it looks like this may give enough
  for users to customise.
- Relates to #437
2018-01-23 09:55:26 +00:00
Janne Valkealahti
51412b5d03 Change persistence model structure
- Fix wrong acquire logic in DefaultStatemachineService.
- Overhaul StateMachineRuntimePersister
- Change StateMachineRuntimePersister to extend
  StateMachinePersist which should work better on
  a bean level. Also add generic type T to it and
  config where needed.
- Relates to #432
- Relates to #427
2018-01-23 09:55:26 +00:00
Janne Valkealahti
3d538f7600 Add base DefaultStateMachineService implementation
- First take on new interface StateMachineService with
  its default impl.
- Modify datajpapersist sample to use it.
- Relates to #432
2018-01-23 09:55:26 +00:00
Janne Valkealahti
c0e5a9d305 Preliminary support for Spring Data persist
- Add new repository model for storing StateMachineContext
  via a new StateMachineRepository.
- New StateMachineRuntimePersister interface to abstract needed
  functionality to do a runtime machine persistence.
- As runtime persistence, as of now, is done via interceptors, define
  JpaRepositoryStateMachinePersist and JpaPersistingStateMachineInterceptor
  to define StateMachineRuntimePersister logic.
- Add new datajpapersist sample demonstrating new concepts.
- Keep tests related to jpa as there's not redis/mongo integration
  implemented in this first iteration.
- As this is going to be WIP until features around this issues
  are completed, docs, etc are not yet added. Also, interfaces and impls
  are subject to change during a process.
- Relates to #423
- Relates to #426
- Relates to #427
2018-01-23 09:55:26 +00:00
Janne Valkealahti
c2db915306 Handle null BeanFactory in StateMachineHandlerCallHelper
- Makes things less chatty if BeanFactory is null in
  StateMachineHandlerCallHelper as this is usually a case
  with manual builders outside of app context.
- Backport #412
- Relates #307
2017-11-12 16:29:52 +00:00
Janne Valkealahti
10ed7feeae Fix state holder usage
- In AbstractStateMachineFactory change used holder map
  to list so that same states don't get lost because of
  used key.
- Backport #416
- Relates #307
2017-11-12 16:28:32 +00:00
Pinguet62
fb8d534e8e Fix logging message when transition action throws exception
- Backport #413
- Relates #307
2017-11-12 16:26:12 +00:00
Janne Valkealahti
17c9223103 Fix event processing threading
- Add one extra step to schedule event processing to
  recude risks that machine doesn't do full
  run-to-completion.
- Fixes #419
2017-11-05 17:09:44 +00:00
Hazim
43121435f9 Fix method description typo
Fixed typing mistake in the method description
2017-10-10 20:53:18 +05:00
Janne Valkealahti
6fc08b5f01 Clear machine id with null context restore
- As passing in null context don't have any
  meaning other than doing reset with pre-defined
  behaviour which currently just resets back to
  initial state and clears extended state variables.
  Now Also clearing machine id back to null which is
  anyway a default value.
- Backport #381
- Relates #307
2017-07-09 08:43:56 +01:00
Janne Valkealahti
0753f712f0 Change machine lifecycle with restore
- Fixing machine lifecycle logic when machine
  is restored which effectively should not touch
  any lifecycle methods as start/stop is
  user level action.
- Remove start/stop from restore and attempt to
  do same when root machine is started. This also
  needed some further changes as some functionality
  for restore was essentially broken
- Backport #386
- Relates #307
2017-07-09 08:43:10 +01:00
Janne Valkealahti
6b636bef2d Add recursive context build
- Fix AbstractStateMachinePersister to handle
  recursive machines and regions.
- Backport #391
- Relates #307
2017-07-09 08:42:44 +01:00
Janne Valkealahti
f268999400 Fix OnExtendedStateChanged with key
- Fix case where method was annotated with
  @OnExtendedStateChanged(key = "V1"), V1 was
  changed which didn't result call to that method.
- Backport #387
- Relates #307
2017-07-09 08:42:11 +01:00
Janne Valkealahti
1e60b7abfa Add support for multiple end states with javaconfig
- Add missing support for defining more than one
  end states and as it's just missing from javaconfig.
- Backport #368
- Relates #307
2017-07-09 08:41:30 +01:00
Janne Valkealahti
526c05e0f9 @WithStateMachine may register too many processors
- Change processor registration so that if @WithStateMachine is
  used with 'id', 'name' is skipped because it defaults to 'stateMachine'
  and would cause extra registration.
- Relates #307
- Backport #370
2017-07-09 08:40:08 +01:00
Fabien Chebel
2fb817f803 Fix PreStateChange interceptors being called twice for END states (#367) 2017-05-29 14:06:44 +02:00
Janne Valkealahti
8d7fe80bdb NPE on sendEvent
- Adding null check for current state
- Remove synchronization from scheduleEventQueueProcessing
  method in executor. Looks like this sync is not really needed
  and indeed may cause jvm level deadlocks if threads are used
  for execution.
- Change how some internals in
  AbstractStateMachine are synchronized
  to limit changes for deadlock.
- Relates to #307
- Backport of #359 #360
2017-05-19 07:52:31 +01:00
Janne Valkealahti
b1d708e241 Fix EventDeferTests
- Change testDeferWithSubsThreadExecutor to use
  more threads if that is a culprint for this
  failure.
- Relates to #343
2017-05-07 09:05:29 +01:00
Janne Valkealahti
3884d48fef Support actions with transition via choice/junction pseudostate
- Adding support for javaconfig/uml to define
  actions for transitions leading out from a
  choice or junction states.
- Support for action for incoming transition is
  already implemented as it is defined as normal
  transition.
- Backport #108
- Relates #307
2017-05-05 14:57:15 +01:00
Janne Valkealahti
d16e29ea45 Fix post interceptor call
- Now calling post state interceptor with
  correct/same state as pre.
- Backport #353
- Relates #307
2017-05-05 14:56:44 +01:00
Janne Valkealahti
d3b6491bbc Fix action error in anonymous transition
- Executor is following anonymous transitions in a loop
  and if there is an exception in actions with this transition,
  effectively executor ended into infinite loop.
- No bailing out from this loop if we cannot continue.
- Backport #344
- Relates #307
2017-05-05 14:55:56 +01:00
Janne Valkealahti
331dc05957 Prevent debug calls
- Polish to do checks for debug/trace logs
- Backport #329
- Relates #307
2017-05-05 14:55:00 +01:00
Janne Valkealahti
168f6476f9 Adapt to logging changes
- Moving over to log4j2 for test logging.
- Need to follow what happens to commons-logging
  per SPR-14512.
- Relates to #394
2017-04-19 15:12:22 +01:00
Janne Valkealahti
ea9dee4aad Fix mockito deprecation warnings
- Relates to #342
2017-04-11 20:36:55 +01:00
Janne Valkealahti
7cd5f3c069 Fix Assert deprecation warnings
- Fixes #346
2017-04-11 19:59:44 +01:00
Janne Valkealahti
cf7b9d7e24 Fix StateMachineMonitorTests
- Attempt to make these tests more reliable
- Relates to #343
2017-04-10 14:58:48 +01:00
Janne Valkealahti
6ced0371d8 Disarm timers
- Trying to handle scenario where TimerTrigger keeps firing
  even if machine is stopped or has moved away from its
  hosting state.
- Explicitely handle trigger starts/stops in
  DefaultStateMachineExecutor when executor itself
  is started/stopped.
- Backport #321
- Relates to #307
2017-03-09 10:51:20 +00:00
Janne Valkealahti
688b61d5d2 Notify transition before calling its actions
- Add new api to Transition to expose calling
  its actions.
- Modify rest of a framework to first notify before
  calling transtion action.
- Backport #322
- Relates to #307
2017-03-09 10:51:20 +00:00
Janne Valkealahti
7371f67eb6 Timer trigger deadlock in DefaultStateMachineExecutor
- Add new tests for DefaultStateMachineExecutor to find
  possible causes for a deadlock.
- Handle lifecycle scenario little differently
  if timer is fired during a executor starting phase
  order to not getting into a deadlock.
- Backport #315
- Relates to #307
2017-03-09 10:51:20 +00:00
Gary Rosales
70a8657463 StateMachineInterceptorList set() does nothing
- Fixes #318
2017-02-16 09:31:52 +00:00
Janne Valkealahti
90637d68d6 Better generics handling with adapters
- Modify StateMachineConfiguration and StateMachineFactoryConfiguration
  so that if you have different states and events classes with multiple
  machines or factories, you can autowire by types without
  adding qualifiers.
- Manually try to discover generic types from enclosing adapther class
  and if succesfull pass that information into bean definition
  as ResolvableType.
- Backporting #306
- Relates to #307
2017-02-10 11:57:04 +00:00
Janne Valkealahti
c35286e83f Fix typo
- Fixes #310
2017-02-09 17:55:32 +00:00
Janne Valkealahti
29e8cdd276 @WithStateMachine with factory and builder
- Backport #292
- Backport #224
- Add support so that @WithStateMachine can be used with
  machines build via @EnableStateMachineFactory or via
  manual builders.
- Adding new annotation @EnableWithStateMachine to help
  handling needed context configuration.
- Add tests and docs.
- Relates to #307
2017-01-18 09:49:10 +00:00
Janne Valkealahti
17d977ddc1 Make autostart smarter
- Backport #298
- Factory now listens machine event if autostart
  is requested which should give fully started machine
  i.e. if asynch executor is used. Bails out after 30
  seconds. Further tweaks like allowing user to define
  this time or conditionally not wait could be added later.
- Fix typos.
- Relates to #307
2017-01-18 09:48:14 +00:00
Janne Valkealahti
b26b03e6bb Update docs
- Add intro builder which goes to gh pages
- Relates to #284
2016-12-11 11:31:26 +00:00
Janne Valkealahti
3d9059a075 Update docs
- Add section about machineId
- Relates to #284
2016-12-10 12:27:58 +00:00
Janne Valkealahti
457c924e67 Remove some EventNotAccepted events
- Now only trying to notify those from
  a root machine as same events from childs are
  kinda pointless and just create noise.
- Fixes #287
2016-12-08 12:15:52 +00:00