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
This commit is contained in:
Janne Valkealahti
2019-06-29 15:29:50 +01:00
parent fcd9945169
commit e7092a31f1
17 changed files with 151 additions and 58 deletions

View File

@@ -45,6 +45,7 @@ import org.springframework.statemachine.config.model.StatesData;
import org.springframework.statemachine.config.model.TransitionData;
import org.springframework.statemachine.config.model.TransitionsData;
import org.springframework.statemachine.guard.Guard;
import org.springframework.statemachine.guard.Guards;
import org.springframework.statemachine.guard.SpelExpressionGuard;
import org.springframework.statemachine.state.PseudoStateKind;
import org.springframework.statemachine.transition.TransitionKind;
@@ -225,7 +226,8 @@ public class RepositoryStateMachineModelFactory extends AbstractStateMachineMode
TransitionKind kind = t.getKind();
Guard<String, String> guard = resolveGuard(t);
transitionData.add(new TransitionData<>(t.getSource().getState(), t.getTarget().getState(), t.getEvent(), actions, guard, kind != null ? kind : TransitionKind.EXTERNAL));
transitionData.add(new TransitionData<>(t.getSource().getState(), t.getTarget().getState(), t.getEvent(),
actions, Guards.from(guard), kind != null ? kind : TransitionKind.EXTERNAL));
if (t.getSource().getKind() == PseudoStateKind.ENTRY) {
entrys.add(new EntryData<String, String>(t.getSource().getState(), t.getTarget().getState()));