Commit Graph

160 Commits

Author SHA1 Message Date
Michael Shindle
599ffc99e2 Apply fix for issue #148 to 1.0.x branch. 2016-01-11 17:34:14 -08:00
Janne Valkealahti
5227aea34b Add synchronization
- Relates to #135
2015-12-30 10:55:56 +00:00
Janne Valkealahti
b624330681 Fix event defer issues
- Event may get not accepted in some cases
  while it should be deferred. Check defer
  again before accept would return false.
- Relates to #135
2015-12-30 08:58:02 +00:00
Janne Valkealahti
a9f106e930 DefaultStateMachineExecutor using wrong extended state
- Backport #146
- Remove passing extended state into DefaultStateMachineExecutor as
  after machine is reseted and extended state object changed, transitions
  from executor would get wrong object. Just get it from state machine
  itself for StateContext.
- Fixes #147
2015-12-17 19:52:02 +00:00
Janne Valkealahti
f2f8c1a3c4 Wrong publish method calls
- Backport #144
- notifyTransition and notifyTransitionEnd call wrong
  publish methods. fix by well calling correct methods.
- Fixes #145
2015-12-15 08:45:50 +00:00
Janne Valkealahti
41371d292b Fix machine autostart with annotation config
- Backport #141 fixes #142
- This seem to relate with machine build from an annotation
  config which is then used as a session scoped bean.
- Fix autostart usage where appropriate and also fix some
  test which were using wrong logic to determine autostart
  usage(tests were wrong).
2015-12-13 14:46:39 +00:00
Janne Valkealahti
a9d24c038c Event defer for substates and regions
- Backport #131 fixes #135
- Modify state structure so that nested states and orthogonal
  regions can work with deferred events.
- Change executor to work better with deferred events and try
  to provide better model for run-to-completion when execution
  happens in a threads.
- Add new event defer section in ref docs.
2015-12-07 08:12:50 +00:00
Janne Valkealahti
ed25006075 Add support for session scope
- Add tweaks to DisposableBean.destroy() which integrates
  into a lifecycle and properly closes a machine if only
  destroy() is called which is a case when `session` scoped
  bean is destroyed when http session is invalidated.
- Tests in SessionScopedAnnotationTests and
  SessionScopedManualTests for both builder and
  annotation config.
- Fixes #112
2015-11-28 09:13:10 +00:00
Janne Valkealahti
c0b24a3ca1 Fix typo in OnStateMachineStop
- Fixes #129
2015-11-27 07:43:34 +00:00
Janne Valkealahti
68e0cd5f72 Change way BeanFactory and TaskExecutor are set
- Guard LifecycleObjectSupport.afterPropertiesSet() so that
  it's not called twice where other call would be initiated
  by app context if machine is returned as @Bean but still
  normally build via a builder.
- Tune internal handling of BeanFactory and TaskExecutor so that
  we play nice with machine and its executor.
- Fixes #130
2015-11-27 07:41:36 +00:00
Janne Valkealahti
40be191b21 Update tests 2015-11-26 15:30:39 +00:00
Janne Valkealahti
f6037802fd Fix empty @OnTransition
- Fix so that bean method will be called with
  plain @OnTransition having no source or target
  defined.
- Fixes #128
2015-11-26 12:10:22 +00:00
Janne Valkealahti
c981c5a6ee Update docs
- Remove most of a static class modifiers from docs
  to make things easier if doing copy/paste. Not
  all can be removed because some spring inner
  config classes has to be static.
- Fixes #123
2015-11-26 09:36:47 +00:00
Janne Valkealahti
b5d3c4e3e4 Fix class loading in StateMachineConfiguration
- Change used classloader so that classes in found if
  doing normal boot cli tricks for a sm config adapter.
- Fixes #122
2015-11-26 08:17:51 +00:00
Janne Valkealahti
01dc737bf6 Update docs
- Add missing docs for @StatesOnTransition supported
  method arguments.
- Fixes #124
2015-11-20 16:22:04 +00:00
Janne Valkealahti
56abfab4f8 Update docs 2015-11-15 14:57:41 +00:00
Janne Valkealahti
2b1d06e097 Support context events with StateMachineBuilder
- Fix so that we can annotate @Configuration class with
  @EnableStateMachine assuming config class is not extended
  from StateMachineConfigurer(aka config adapter).
- Allows to create machine via a builder as @Bean still properly
  registring rest of a facilities via @EnableStateMachine.
- Polish other tests by removing registering StateMachineEventPublisherConfiguration
  as it's added via @EnableStateMachine.
- Change AbstractImportingAnnotationConfiguration so that it will not try
  to register bean if implementation returned null definition. Meaning
  StateMachineConfiguration detected that @EnableStateMachine was placed
  on a non-adapter class.
- Fixes #120
2015-11-14 16:11:52 +00:00
Janne Valkealahti
19af615698 Fix NPE with missing configurer
- Throw BeanDefinitionStoreException in favor of NPE if
  @EnableStateMachine or @EnableStateMachineFactory is used
  without a configurer meaning user is missing proper config
  adapter like EnumStateMachineConfigurerAdapter.
- Polish StateMachineConfiguration and StateMachineFactoryConfiguration
  by removing wrong typed refs to Enum.
- Fixes #119
2015-11-14 14:11:07 +00:00
Janne Valkealahti
d55a7ab802 Fix use of multiple EnableStateMachineFactory
- Fixing internal handling of multiple EnableStateMachineFactory
  adapters which were wrongly mixed up during internal
  config build.
- Techically we can have multiple adapters building same state machine and
  same factory if carefully crafted. However a check was missing in
  StateMachineFactoryConfiguration to only attempt configure builder
  for exact attached adapter, thus causing same internal builder called twice
  which then failed because build was already called. This was originally done
  for StateMachineConfiguration but missed for StateMachineFactoryConfiguration.
- Fixes #117
2015-11-05 19:31:36 +00:00
Janne Valkealahti
58e9f01aaf Association with @EnableStateMachine and @WithStateMachine
- Fix bug where multiple machines and beans with @WithStateMachine
  didn't properly separate calling methods with @OnTransition.
- Some polish
- Fixes #116
2015-11-05 13:46:50 +00:00
Janne Valkealahti
d5c71bb776 Fixing auto-start via @EnableStateMachineFactory
- Machine is now started automatically if it's requested
  from a factory and flag is set.
- Fixes #113
2015-10-16 11:08:08 +01:00
Janne Valkealahti
280e77347e Add better support for region persist
- Various changes to have a better support for persisting
  regions.
- Fixes for TasksHandler.
- Fixes #94
2015-10-09 17:36:22 +01:00
Krumlauf, Michael
2a617008c2 Add missing file 2015-09-08 05:34:52 -04:00
Krumlauf, Michael
671e37ce25 Rename EnsembleListeger to EnsembleListener 2015-09-07 16:19:08 -04:00
Janne Valkealahti
f33fa4055c Fix npe with choice
- Preventing passing nulls into factory if choice configurer
  only have last() defined.
- Polish some classes around those classes.
- Fixes #101
2015-09-02 18:35:22 +01:00
Janne Valkealahti
d882c392a9 Fix event handling with threading
- With a combination of a task executor using a thread pool,
  substates with triggerless transitions and actions may fail to
  properly pass on message headers.
- Move queue message outside of loop on a class level which
  should give next loop a change to see previous queued message
  which is then used from triggerless transitions.
- Relates to #100
2015-08-31 10:24:21 +01:00
Janne Valkealahti
7027a2c52a Add docs for TimerTrigger
- Fixes #102.
2015-08-29 18:26:35 +01:00
Janne Valkealahti
ad57bc7085 Add transition header tests for choice 2015-08-29 17:11:15 +01:00
Janne Valkealahti
a6145072b5 Pass event headers into triggerless transitions
- Change DefaultStateMachineExecutor to keep event message
  around and then loop triggerless transitions order to
  pass that message to whole chain.
- Fixes #100
2015-08-29 10:33:32 +01:00
Janne Valkealahti
b90382575c Move StateMachinePersist up to parent package 2015-08-28 09:15:08 +01:00
Janne Valkealahti
1371ceac7b Forward event headers to initial transition
- Enhancing internal model so that event and its headers can
  be passed into action if it's used in an initial sub-state
  when transition target its super state.
- Added tests and better docs.
- Fixes #99.
2015-08-28 08:14:38 +01:00
Janne Valkealahti
166c586458 Add enum manual builder test 2015-08-25 17:23:37 +01:00
Janne Valkealahti
d7f5f9f573 Better zk connection error handling
- Modifying concepts around DistributedStateMachine and
  ZookeeperStateMachineEnsemble to get better handling when
  zk connection is lost.
- New jepsen test showing that after a brain split machine
  will get back to a consistent state.
- Polish javadocs
- Hopefully fixes #91
2015-08-15 15:36:52 +01:00
Janne Valkealahti
7f7c2334ff Add state reset for regions
- This relates to #94 but doesn't provide full solution
  as it simply allows to use nested state machine contexts
  to reset region states.
2015-08-13 14:37:48 +01:00
Janne Valkealahti
9e0dfe9c24 Fix DefaultStateMachineExecutor concurrency issue
- Check task is null and then set it was wrongly
  not made as thread safe, changing it to be wrapped
  inside AtomicReference.
- This relates to #76 and hopefully fixes #96
2015-08-12 21:23:45 +01:00
Janne Valkealahti
edda97af16 Docs for extended state 2015-08-09 17:15:03 +01:00
Janne Valkealahti
e8debdc5a5 Add listener api for extended state variables
- New extendedStateChanged method in StateMachineListener and
  its wingman OnExtendedStateChanged in context events.
- DefaultExtendedState is now using ObservableMap to get notify
  when individual variables has been modified.
- Fixes #85
2015-08-09 14:56:54 +01:00
Janne Valkealahti
05f69070d8 Change TaskExecutor bean name
- Now using stateMachineTaskExecutor instead of taskExecutor
  so that it's easier to use custom executor and not to
  collide with bean created i.e. scheduling.
- Fixes #83
2015-08-09 09:53:46 +01:00
Janne Valkealahti
7fc7dd9cac Fix potential concurrency issue with join pseudostate
- Change notified flag to volatile which might explain
  some test failures.
- More testing tweaks for #76
2015-08-08 16:30:24 +01:00
Janne Valkealahti
5347ea4dd9 Fix internal transition for dist machine
- Change previous DistributedStateMachine fixes which didn't
  really work. Now explicitely getting state from machine to be set
  into ensemble for post internal transition.
- Now can send Message<E> via test plan instead of plain E.
- More testing for tweaked features.
2015-08-08 10:53:44 +01:00
Janne Valkealahti
435b306cf9 Fix DistributedStateMachine internal transition
- For some reason ZookeeperStateMachineEnsemble may return null
  for very early when postTransition() is handled. Adding check not
  to ping back ensemble if its getState() returns null. It really
  feels a bit wrong right now, so need to follow this.
2015-08-07 17:25:52 +01:00
Janne Valkealahti
bba3b231b3 Synchronize Join PseudoState state machine listener
- Synchronize JoinPseudoState's
  JoinTracker.stateChanged(State<S, E>, State<S, E>) method
  for playing nice with concurrent region execution.
  Should fix #93.
- Tuning test which relates to #76. What comes for the
  tests, there was this concurrency issue and also problem
  in tests itself.
- Polish JoinPseudoState.
2015-08-07 14:38:49 +01:00
Janne Valkealahti
e6c400e31c Fix jdk8 javadoc build 2015-08-04 09:08:22 +01:00
Janne Valkealahti
5ab1cb3fcb Add ref docs for error handling
- Base docs for error handling and some tests
  to verify added doc samples.
- Relates to #88
2015-07-31 16:58:47 +01:00
Janne Valkealahti
d5257c64e7 Add base feature for error handling
- Add related error handling methods to StateMachine.
- Enhance StateMachineListener and context events around
  error events.
- Modify StateMachineInterceptor and stuff around it order
  to handle errors.
- Fixes #6, fixes #77
2015-07-31 13:11:19 +01:00
Janne Valkealahti
6684b0deda Fixes for zk ensemble operations
- Fix some concurrent event issues which were
  born with new tests
- Enhance tests for dist machine and ensemble
- Add new features to testing system
- Polish and add more logging
2015-07-29 20:15:42 +01:00
Janne Valkealahti
706f1de232 Update ref docs
- First set of changes for doc updates for M3
- Relates #88
2015-07-26 16:52:15 +01:00
Janne Valkealahti
178ee816a4 Enhancements to tasks recipe
- Fix AbstractStateMachineFactory so that it does not try
  to create transitions with null source or target. Basically we
  just skip transition source or target which doesn't belong to
  region.
- Change DefaultExtendedState to use ConcurrentHashMap so that
  there's less change to get into trouble with concurrency.
- Add statechart for tasks recipe.
- Fix various concepts in TasksHandler and its tests.
- Prepare some examples for docs.
- Fixes #74
2015-07-25 17:09:54 +01:00
Janne Valkealahti
0fba91cbf2 Fix event overflow
- Fixes #89
- Added new method into EnsembleListeger which can
  be used to listen ensemble errors.
2015-07-25 08:31:03 +01:00
Janne Valkealahti
74f2f72ed6 Fix concepts around internal transitions
- Fixes #86
- Fix internal transition changes when extended
  state variables has been modified. Also internal
  transition is now correctly passed into other
  distributed state machines.
2015-07-24 09:07:03 +01:00