Commit Graph

378 Commits

Author SHA1 Message Date
xJoeWoo
61c58cdee0 Improve creation of StateMachineFactory
- Returning factory from StateMachineBuilder.Builder
- Fixes #845
2020-09-06 15:31:31 +01:00
Janne Valkealahti
4e4ed2fc38 Polish 2020-09-06 09:45:07 +01:00
Janne Valkealahti
f835ce6959 Fix javadocs with jdk11
- Forward port #863
2020-09-05 15:27:29 +01:00
Janne Valkealahti
9e0bdae46f Add Flux test for denied result
- Relates #802
2019-12-26 12:41:24 +00:00
Janne Valkealahti
dd2017c8b5 Configure BlockHound 2019-12-26 10:23:17 +00:00
Janne Valkealahti
2eebb2b0bf Polish build 2019-12-25 09:23:49 +00:00
Janne Valkealahti
00a4fae3a1 Add checks for missing transitions
- Now checking if some transitions are missing
  and throwing a proper exception instead of NPE.
- Fixes #775
2019-12-25 08:38:51 +00:00
Janne Valkealahti
20c1f56381 Relax sync in DefaultStateMachineService
- Now starting machine outside of a sycn block with
  acquire vs. release. This should allow long running
  start in a machine to allow next acquire to work faster.
- Forwardport #770
- Relates #777
2019-12-25 07:40:26 +00:00
Janne Valkealahti
96773828fc Docs changes
- Relates #742
2019-08-04 08:04:05 +01:00
Janne Valkealahti
8bd0df9e4c Docs changes
- Add some notes for threading and wipe out TaskExecutor and
  TaskScheduler from docs.
- Some notes about replacement with reactor.
- Relates #742
2019-08-03 15:27:21 +01:00
Janne Valkealahti
da9c68f4e6 Remove TaskExecutor and TaskScheduler
- As all execution and scheduling is now in reactor,
  remove all traces of these spring interfaces.
- Fixes #800
2019-08-03 14:40:37 +01:00
Janne Valkealahti
f1bf35e688 Trigger reactive changes
- Triggers evaluate method is now reactive.
- Various changes for signature change.
- Fixes #799
2019-08-03 12:59:52 +01:00
Janne Valkealahti
e566f7ee65 Polish
- Relates #791
2019-08-03 07:57:16 +01:00
Janne Valkealahti
0a6992959a Fix NPR in ReactiveStateMachineExecutor
- Re-enable test in EventDeferTests as this NPE fix
  now handles smoke test.
- Relates #791
2019-07-01 09:09:12 +01:00
Janne Valkealahti
5128ed735a Change things around guards to reactive
- For Guard and Transition change call stach to be fully
  reactive from executor. Some changed signatures similarly
  what was needed for reactive Actions.
- Disabling one smoke test to get figure out later as
  something is broken somewhere, possible reactor bug...
- Relates #791
2019-06-30 16:51:08 +01:00
Janne Valkealahti
02be7eb478 Polish 2019-06-29 15:49:48 +01:00
Janne Valkealahti
e7092a31f1 Initial reactive Guard changes
- First changes to introduce ReactiveGuard similar to work done
  for ReactiveAction. User level interface is ReactiveGuard but internally
  it is handled as its super type Function<StateContext<S, E>, Mono<Boolean>>.
- This change still keeps some calls as blocking which will get changed
  in futher commits to get a full reactive chain.
- Touching only Transition to change guard signature, other use of blocking guard
  internally need to get similar changes in next commits.
- Baby steps...
- Relates #791
2019-06-29 15:30:41 +01:00
Janne Valkealahti
fcd9945169 Updates to migration guide
- Relates #742
2019-06-29 12:12:47 +01:00
Ming Deng
9f10700da2 Refactor to junit5
- remove junit4 dependecies
- refactor the unit tests by junit5
- enhance the spring-statemachine-test and spring-statemachine-build-tests so they can work together with junit4/junit5
- relates #779
2019-06-08 07:23:59 +01:00
Ming Deng
f816a88e7e Change StateMachineFunction to Consumer
- Remove StateMachineFunction class
- Replace StateMachineFunction with Consumer
- Fixes #767
2019-05-27 08:44:33 +01:00
Janne Valkealahti
10f986ce06 Polish AbstractState
- Polish previous change to AbstractState by using a shared function
  completionStateListenerSink to track completion sink as functionality
  between entries to submachine/regions should be similar.
- Mostly relates to #743
2019-05-26 15:20:03 +01:00
Janne Valkealahti
5562bfdd12 Move anonymous transitions to reactive chain
- This commit changes a way how triggerless transitions are executed by
  going via new doOnComplete method in StateListener which returns
  Mono<Void>. This used to be a simple fire and forget subscribe via listener
  and now fully handled via reactive chain when state is complete. Rest of
  a changes are to tweak state actions to run parallel to be able to cancel
  those and then follow and track when triggerless transitions need to be
  executed.
- AbstractState still have some work to do for disposing things around
  submachines which currently seem to break thins if handleStateDoOnComplete
  is disposed when submachine state is exited. We'll leave this to get
  fixed later.
- Add tag handling for junit5 which can be set via gradle build properties
  statemachineIncludeTags and statemachineExcludeTags.
- Add BlockHound to build which can be activated via gradle build
  property statemachineBlockHound.
- Add org.awaitility:awaitility to various test deps.
- Mostly relates to #734
2019-05-25 13:53:31 +01:00
Janne Valkealahti
c213f62aef Reactive test changes for core
- Relates #750
2019-05-14 07:09:19 +01:00
Janne Valkealahti
aed1ba5aaa Fix deprecation in Spring ClassUtils
- Using cglib check from AopUtils which is not deprecated.
- Relates #765
2019-05-14 07:08:05 +01:00
Janne Valkealahti
c11a1957f3 Fix deprecation in StateMachineAnnotationPostProcessor
- As AnnotationUtils.getAnnotations from framework is deprecated
  from 5.2 move over to MergedAnnotations api.
- Relates to #765
2019-05-12 16:23:01 +01:00
Janne Valkealahti
94fa9c89d2 Remove obsolete CleanTimerTests
- Relates #397
2019-05-12 14:41:00 +01:00
Janne Valkealahti
c24bac57a3 Reactive changes for StateMachineTestPlan
- Move to use reactive methods and for now block
  as concept is really blocking. Full reactive stuff
  needs bigger overhaul.
- Fix event issues in DistributedStateMachine as these
  caused issues when StateMachineTestPlan were changed to
  send events via reactive methods.
- Relates #744
- Relates #750
2019-05-12 13:37:08 +01:00
Janne Valkealahti
175175419a Reactive test changes for core
- Relates #744
2019-05-11 13:24:10 +01:00
Janne Valkealahti
be6ee233c5 Reactive changes for docs
- Relates #742
- Relates #744
2019-05-11 10:06:49 +01:00
Janne Valkealahti
32dfb58a4b Testing polish and generic reactive changes
- Remove use of statemachine assertj assertions to prepare move
- Move statemachine assertj assertion to spring-statemachine-test
- Polish some tests and user TestUtils from core tests
- Remove most of a deprecation warning from core tests
- Relates #744
2019-05-10 14:54:14 +01:00
Janne Valkealahti
10f0ec0edf Clear event defer list
- In ReactiveStateMachineExecutor deferList is clear
  with deferred event if it triggers.
- Fixes #747
2019-05-08 18:29:43 +01:00
Janne Valkealahti
70341f54e5 Add reactive state actions
- Add stateDoFunction, stateEntryFunction and stateExitFunction methods
  taking Function with a state to register reactive actions.
- Don't yet to a full take on all similar action methods as we need
  to think about how these should be named and what old methods to
  depecate.
- Relates #743
2019-05-06 22:44:58 +01:00
Janne Valkealahti
d8f1fc0155 Initial reactive action support
- This first commit related to reactive action support basically changes internal
  logic away from original Action interface which really is just
  a Consumer<StateContext> but it originates pre jdk8 era.
  Reactive equivalent internally is now Function<StateContext<S, E>, Mono<Void>>.
- Essentially actions will now get executed with a reactor chain fully.
- Fix StateMachineExecutorTransit in AbstractStateMachine to be full reactive
  chain which were needed to get reactive actions working. This also put
  StateContextTests back to its original state.
- Add typesafe interface ReactiveAction which simply wraps
  Function<StateContext<S, E>, Mono<Void>> and add this to transitions with
  actionFunction() as a concept. This will be added to states in next
  commits if actionFunction() as a concept works.
- Polish various things and issues which were not addressed with initial reactive commit.
- Disable ActionSecurityTests for now as secured Action bean now breaks because it's
  internally wrapped into a Function and Spring Security doesn't see it anymore.
  Security like this needs a bit of a overhaul which can be done later.
- State do actions which are done via scheduling needs some work as now we just do
  a subscribe which is probably a bit wrong. There's going to be more work for
  scheduling so this also can be left later stages.
- Relates #743
2019-05-06 17:03:21 +01:00
Janne Valkealahti
52fc9c8568 Initial reactive refactor
- Change to Boot 2.2.x to pick upcoming series.
- Introduce Awaitility to tests
- Introduce new StateMachineEventResult concept in favor of boolean
  when sending events. This result interface will have richer information
  what happens when event is processed as previously we simply had boolean
  flag telling if even was accepted. With StateMachineEventResult we can
  can provide more information like if event was deferred and which region
  provided this message.
- Deprecate old event methods and add new reactive event methods which now
  return a Flux of StateMachineEventResult's. This concept then allows
  to send Flux of events to a machine.
- State exit/entry now return Mono<Void>
- Refactor component lifecycle to be reactive as old start/stop would
  not work anymore in a reactive statemachine simply because start may
  cause changes and execute flow's.
- To ease testing add internal assertj assertions for some classes. This
  work is kept in a test classes for time being to get move to public
  spring-statemachine-test when things are more mature.
- Overhaul StateMachineExecutor interface and replace DefaultStateMachineExecutor
  with ReactiveStateMachineExecutor.
- New ReactiveLifecycleManager which is kinda reactive replacement of some internals
  of a LifecycleObjectSupport. Needed as components are reactively started and
  stopped during a machine execution.
- New RegionExecutionPolicy concept which is an attempt to introduce parallel config
  idea to a regions. Previously this was just naively handled with TaskExecutor which
  never worked perfectly while working through reactor now seem to provide more
  consistent results.
- Some test has been changed to reflect changes in a StateMachineExecutor. Also execution
  using reactor made some changes to state notifications which now seem to be
  more consistent(aka. previously parallel execution might have given notifications
  in wrong order and in some cases kinda bogus changes).
- New turnstile reactive sample which is just start of a reactive sample to show
  concept with webflux.
- Don't yet really add any docs as things are in-flight.
- Fixes #740
2019-05-04 16:31:08 +01:00
Spring Operator
426fa163b2 URL Cleanup
- Merge/squash #686 and #694
2019-05-03 15:01:31 +01:00
Janne Valkealahti
98ba6949ff Fix concurrency in DefaultStateMachineExecutor
- Change deferList from LinkedList to ConcurrentLinkedQueue
  to fix ConcurrentModificationException with parallel events.
- Fixes #736
2019-05-03 14:14:14 +01:00
Janne Valkealahti
55b7ff09cf Fix exit logic with fork/join
- In a case where fork/join happens within a substate we should not exit parent state
  which causes cascading stops for forked regions thus causing inconsistent lifecycle
  states within that kind of a machine structure. This for example caused parent submachine
  to end up stopped and all regions running even if some regions ended up into terminal state.
- Fixes #737
2019-05-03 09:50:35 +01:00
Janne Valkealahti
8f6c89d65e Move post state interceptor call later
- This is fixing some issues where anonymous transitions
  are causing post state call to happen too early i.e.
  with a submachine which transits away from it.
- Fixes #734
2019-04-24 07:51:18 +01:00
burak
cdaa9a1400 Add full interceptor methods support for RegionPersistingInterceptorAdapter
- Fixes #726
2019-04-14 07:15:08 +01:00
Hamid Mortazavi
bd2518cce9 Persisting StateMachineContext for SM with nested regions and Fork/Join
- fixing issue when StateMachineContext is incorrectly persisted for
  SM with nested regions and Fork/Join configuration
- Fixes #723
2019-04-13 16:41:32 +01:00
Jonathon Seah
39ab4a0732 Add backwards compatibility between StateMachineContext serialization of spring-statemachine 2.0.x and 2.1.x
- Add tests between old serialised context(write) and new context(write)
- Fix setting childRefs to empty array instead of null if childRefs
  are not given.
2019-04-13 15:56:43 +01:00
Janne Valkealahti
40a7230a43 JoinPseudoState not tracking join states correctly
- In JoinPseudoState join states are tracked as list of lists
  where usually inner list contains one item except with region
  having multiple end states.
- Now fixing this case when resetting when previously completed
  region don't clear this list out from outer list.
- Fixes #684
2019-03-19 11:45:41 +00:00
Vincent Privat
675fdf07de Add new method isStateMachineManaged
Determines if the given machine identifier denotes a known managed state machine.
2019-03-17 08:52:23 +00:00
Janne Valkealahti
7df664d306 Add support for @EventHeader annotation
- Add @EventHeader which can be used to bound as single
  event headers instead of all headers @EventHeaders.
- Fixes #638
2019-03-17 08:08:13 +00:00
Janne Valkealahti
53d6ddefa9 Fix StateMachineInterceptor calls
- Due to a regression when new preStateChange method were
  added to pass on root machine, old method did not get
  called anymore. Now calling that as well and fixing
  some other things around it.
- Same changes for postStateChange.
- Fixes #633
2019-03-11 11:17:45 +00:00
Janne Valkealahti
62b57ebb84 Make equals work in DefaultStateMachineContext
- Adding equals and hashCode methods to DefaultStateMachineContext,
  DefaultExtendedState and ObservableMap.
- Fixes #628
2019-01-26 14:35:29 +00:00
Janne Valkealahti
4feeb196cf Document region changes
- Add new docs for regions changes related to StateMachineContext
  and StateConfigurer.
- Document new datajpamultipersist sample.
- Fixes #621
2019-01-20 13:55:24 +00:00
Janne Valkealahti
b30f0ed0b3 Fix join from orthogonal regions
- Fix a bug where multiple end states in a region failed to complete
  if transition was from a super state which in case of join used to track
  a list of end states. This is now changed to track list of lists and
  we can now track that at least one end state were reached per region.
- Fixes #619
2019-01-13 09:01:20 +00:00
Janne Valkealahti
1a485e4d69 Add end state action test
- Test that entry action for end state is executed.
- Relates to #620
2019-01-12 09:10:33 +00:00
Janne Valkealahti
84ca0aec3e Refactor region handling and persistence
- Make kryo in AbstractKryoStateMachineSerialisationService aware of same classloader
  most likely use in an app. This takes away some of those weird kryo
  errors you see with a web apps.
- Add context references concept to StateMachineContext which can be used
  to store reference id and then individual running machines with regions
  can independently store their states. Whole machine state can then get
  restored more accurately.
- Add new `region(String id)` to StateConfigurer which can be used to set region id.
  This is equivalent as setting region id with json based machine structure where
  you need to define region id's with orthogonal regions are in use.
- Add new datajpamultipersist sample showing running regions and how those are
  persisted to a database.
- Fixes #617
- Fixes #605
- Fixes #615
2019-01-12 08:37:34 +00:00