Commit Graph

318 Commits

Author SHA1 Message Date
james
282d395ba0 Use the contextObj as is when saving the StateMachineContext
- Polish and fix some merge issues
- Backport #494
2018-02-21 18:06:36 +02:00
jvalkeal
3ce942fce3 StateMachineAnnotationPostProcessor should extract correct annotated method
- Fix processing so that only expected annotations are
  processed and handlers created.
- Fixes #510
2018-02-21 15:17:17 +02:00
jvalkeal
08e1138aab 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.
- Fixes #501
2018-02-15 14:24:15 +02:00
jvalkeal
c5ebca0b08 Polish tests and executor
- Remove extra logging
- Polish tests, remove thread sleeps
- Relates #466
2018-02-13 12:30:39 +02:00
Marco Primi
371b594f15 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
 - Backport #502
 - Relates #496

https://github.com/spring-projects/spring-statemachine/issues/502
2018-02-13 09:12:25 +02:00
jvalkeal
7857440559 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.
- Fixes #466
2018-02-12 13:30:37 +02:00
Janne Valkealahti
ea6b71c6a7 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-22 09:24:35 +00:00
Janne Valkealahti
66174adde3 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
2017-12-22 09:23:10 +00:00
Janne Valkealahti
2cd3b94662 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
2017-12-19 13:09:41 +00:00
Janne Valkealahti
11ef0e279b 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
2017-12-15 08:54:32 +00:00
Janne Valkealahti
fdae9f7f48 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
2017-12-10 11:39:41 +00:00
Janne Valkealahti
afcd587c08 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
2017-11-29 13:33:12 +00:00
Janne Valkealahti
d49d52b2d3 Add stop logic to DefaultStateMachineService
- Now implementing DisposableBean and clearing/stopping
  machines if service is destroyed.
- Relates to #432
2017-11-28 10:05:29 +00:00
Janne Valkealahti
594505bce3 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
2017-11-26 15:19:26 +00:00
Janne Valkealahti
aa6c927a6c 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
2017-11-26 13:54:11 +00:00
Janne Valkealahti
de6d00e6c8 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
2017-11-23 13:11:39 +00:00
Janne Valkealahti
ca71380f9f 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
2017-11-23 08:04:15 +00:00
Janne Valkealahti
8f7c9310fe Add base DefaultStateMachineService implementation
- First take on new interface StateMachineService with
  its default impl.
- Modify datajpapersist sample to use it.
- Relates to #432
2017-11-21 10:46:49 +00:00
Janne Valkealahti
33a5370d01 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
2017-11-18 16:38:49 +00:00
Janne Valkealahti
c8062e6c61 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.
- Fixes #412
2017-11-12 11:44:18 +00:00
Janne Valkealahti
42ffc19df9 Fix event processing threading
- Add one extra step to schedule event processing to
  recude risks that machine doesn't do full
  run-to-completion.
- Backport #419
- Relates #420
2017-11-05 17:14:48 +00:00
Hazim
f8b7c0dae0 Fix method description typo
Fixed typing mistake in the method description
2017-10-28 15:19:03 +01:00
Janne Valkealahti
ab31c942fe Fix state holder usage
- In AbstractStateMachineFactory change used holder map
  to list so that same states don't get lost because of
  used key.
- Fixes #416
2017-10-28 15:10:46 +01:00
Pinguet62
5630769f04 Fix logging message when transition action throws exception 2017-09-17 22:31:26 +02:00
Janne Valkealahti
609035acea Fix timer after restore
- Previously timer were only armed when state
  were entered, thus failing for timer to work if
  machine were restored. Now changing logic so that
  that state have a lifecycle which is called during
  machine reset.
- Fixes #381
2017-07-08 18:50:18 +01:00
Janne Valkealahti
a9cf3e1acc Clean machine id when restored with null context
- Resetting a machine with null context currently
  just resets to initial state and clear extended
  state variables. Enhance also to clear machine id
  which as a user level variable may cause some other
  trouble. There are no internal functionality for this
  id as it's meant for user consumption.
- Fixes #390
2017-07-08 18:00:02 +01:00
Janne Valkealahti
8c18dc86de 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
- Fixes #386
2017-07-08 17:34:31 +01:00
Janne Valkealahti
38977bef71 Add recursive context build
- Fix AbstractStateMachinePersister to handle
  recursive machines and regions.
- Fixes #391
2017-07-08 10:18:47 +01:00
Janne Valkealahti
4cc3dd705d 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.
- Fixes #387
2017-07-01 15:18:29 +01:00
Janne Valkealahti
04f77664b8 Fix terminal state for persist
- Now calling post state interceptors at end
  of state change which gives machine a change
  to stop if state is terminal.
- Fixes #379
2017-06-29 10:17:55 +01:00
Janne Valkealahti
c15bd99d7f Prevent npe on accept
- Taking local copy of current state
  to prevent npe without sync block.
- Relates to #364
2017-06-10 15:24:23 +01:00
Janne Valkealahti
bec44751d9 Backport ci test changes from master
- Relates to #343
- Relates to #376
2017-06-10 14:33:55 +01:00
Janne Valkealahti
bbca0ea504 Fix possible deadlock
- Removing some sync blocks which imho
  are not needed anymore.
- Adding some smoke tests.
- Relates to #364
2017-06-10 09:11:35 +01:00
Janne Valkealahti
78e3e479a7 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.
- Fixes #368
2017-06-09 10:06:39 +01:00
Janne Valkealahti
1dd3790e4a @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.
- Fixes #370
2017-06-08 09:52:49 +01:00
Janne Valkealahti
7fccb6db94 Fix PreStateChange interceptors being called twice for END states
- Backport #367
- Relates to #372
2017-06-08 09:40:09 +01:00
Janne Valkealahti
ca02c2cecb Add additinal sync
- Change how some internals in
  AbstractStateMachine are synchronized
  to limit changes for deadlock.
- Relates #359
2017-05-18 08:53:52 +01:00
Janne Valkealahti
4d98b80358 Handle possible deadlock
- 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.
- Fixes #360
2017-05-15 11:39:27 +01:00
Janne Valkealahti
faae270b4b NPE on sendEvent
- Adding null check for current state
- Fixes #359
2017-05-15 11:37:58 +01:00
Janne Valkealahti
cec0d24035 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.
- Fixes #108
2017-05-05 14:40:00 +01:00
Janne Valkealahti
37642b1270 Fix post interceptor call
- Now calling post state interceptor with
  correct/same state as pre.
- Fixes #353
2017-05-03 10:27:40 +01:00
Janne Valkealahti
e25c5c6814 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.
- Fixes #344
2017-04-20 09:55:44 +01:00
Janne Valkealahti
33a9c59f39 Prevent debug calls
- Polish to do checks for debug/trace logs
- Fixes #329
2017-03-22 15:52:10 +00:00
Janne Valkealahti
7a25849e9c StateMachineInterceptorList set() does nothing
- Backport #318 from master
2017-03-08 11:22:34 +00:00
Janne Valkealahti
61a790586a 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.
- Fixes #321
2017-03-08 11:02:34 +00:00
Janne Valkealahti
5f8e6c0935 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.
- Fixes #322
2017-03-07 17:02:35 +00:00
Janne Valkealahti
12841bd215 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.
- Relates to #315
2017-02-13 14:02:09 +00:00
Janne Valkealahti
1389360950 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.
- Fixes #306
2017-02-10 11:50:28 +00:00
Janne Valkealahti
48b694fa47 @WithStateMachine with factory and builder
- 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.
- Fixes #292
- Fixes #224
2017-01-10 15:59:29 +00:00
Janne Valkealahti
8bb852cc79 Make autostart smarter
- 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.
- Fixes #298
2016-12-29 09:58:04 +00:00