org.springframework.statemachine.config.builders.StateMachineTransitionConfigurer Java Examples
The following examples show how to use
org.springframework.statemachine.config.builders.StateMachineTransitionConfigurer.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ForkJoinStateMachine.java From spring-statemachine-learning with Apache License 2.0 | 6 votes |
@Override public void configure(StateMachineTransitionConfigurer<States, Events> transitions) throws Exception { transitions .withExternal() .source(States.SI) .target(States.S1) .event(Events.E1) .and() .withExternal() .source(States.S3) .target(States.S4) .event(Events.E4) .and() .withFork() .source(States.S1) .target(States.S2) .target(States.S3) .and() .withJoin() .source(States.S2) .source(States.S4) .target(States.S5); }
Example #2
Source File: AbstractFlowConfiguration.java From cloudbreak with Apache License 2.0 | 6 votes |
private void configure(StateMachineStateConfigurer<S, E> stateConfig, StateMachineTransitionConfigurer<S, E> transitionConfig, FlowEdgeConfig<S, E> flowEdgeConfig, Iterable<Transition<S, E>> transitions) throws Exception { StateConfigurer<S, E> stateConfigurer = stateConfig.withStates().initial(flowEdgeConfig.initState).end(flowEdgeConfig.finalState); ExternalTransitionConfigurer<S, E> transitionConfigurer = null; Collection<S> failHandled = new HashSet<>(); for (Transition<S, E> transition : transitions) { transitionConfigurer = transitionConfigurer == null ? transitionConfig.withExternal() : transitionConfigurer.and().withExternal(); AbstractAction<S, E, ?, ?> action = getAction(transition.source); if (action != null) { stateConfigurer.state(transition.source, action, null); } transitionConfigurer.source(transition.source).target(transition.target).event(transition.event); if (action != null && transition.getFailureEvent() != null && !Objects.equals(transition.target, flowEdgeConfig.defaultFailureState)) { action.setFailureEvent(transition.getFailureEvent()); S failureState = Optional.ofNullable(transition.getFailureState()).orElse(flowEdgeConfig.defaultFailureState); stateConfigurer.state(failureState, getAction(failureState), null); transitionConfigurer.and().withExternal().source(transition.source).target(failureState).event(transition.getFailureEvent()); if (!failHandled.contains(failureState)) { failHandled.add(failureState); transitionConfigurer.and().withExternal().source(failureState).target(flowEdgeConfig.finalState).event(flowEdgeConfig.failureHandled); } } } stateConfigurer.state(flowEdgeConfig.finalState, getAction(FlowFinalizeAction.class), null); }
Example #3
Source File: ForkJoinStateMachineConfiguration.java From tutorials with MIT License | 6 votes |
@Override public void configure(StateMachineTransitionConfigurer<String, String> transitions) throws Exception { transitions.withExternal() .source("SI").target("SFork").event("E1") .and().withExternal() .source("Sub1-1").target("Sub1-2").event("sub1") .and().withExternal() .source("Sub2-1").target("Sub2-2").event("sub2") .and() .withFork() .source("SFork") .target("Sub1-1") .target("Sub2-1") .and() .withJoin() .source("Sub1-2") .source("Sub2-2") .target("SJoin"); }
Example #4
Source File: StateMachineConfig.java From spring-boot-tutorial with Creative Commons Attribution Share Alike 4.0 International | 5 votes |
@Override public void configure(StateMachineTransitionConfigurer<States, Events> transitions) throws Exception { // @formatter:off transitions .withExternal() .source(States.SI).target(States.S1).event(Events.E1) .and() .withExternal() .source(States.S1).target(States.S2).event(Events.E2); // @formatter:on }
Example #5
Source File: ChoiceStateMachine.java From spring-statemachine-learning with Apache License 2.0 | 5 votes |
@Override public void configure(StateMachineTransitionConfigurer<States, Events> transitions) throws Exception { transitions .withChoice() .source(States.S1) .first(States.S2, s2Guard()) .then(States.S3, s3Guard()) .last(States.S4) .and() .withExternal() .source(States.SI) .target(States.S1) .event(Events.E1); }
Example #6
Source File: JunctionStateMachine.java From spring-statemachine-learning with Apache License 2.0 | 5 votes |
@Override public void configure(StateMachineTransitionConfigurer<States, Events> transitions) throws Exception { transitions .withHistory() .source(States.S2H) .target(States.S22) .and() .withExternal() .source(States.S1) .target(States.S2) .event(Events.E2) .and() .withExternal() .source(States.S2) .target(States.S1) .event(Events.E1) .and() .withExternal() .source(States.S2) .target(States.S21) .event(Events.E21) .and() .withExternal() .source(States.S21) .target(States.S22) .event(Events.E22) .and() .withExternal() .source(States.S2) .target(States.S2H) .event(Events.E2H) .and() .withExternal() .source(States.S22) .target(States.S221) .event(Events.E221); }
Example #7
Source File: HistoryStateMachine.java From spring-statemachine-learning with Apache License 2.0 | 5 votes |
@Override public void configure(StateMachineTransitionConfigurer<States, Events> transitions) throws Exception { transitions .withHistory() .source(States.S2H) .target(States.S22) .and() .withExternal() .source(States.S1) .target(States.S2) .event(Events.E2) .and() .withExternal() .source(States.S2) .target(States.S1) .event(Events.E1) .and() .withExternal() .source(States.S2) .target(States.S21) .event(Events.E21) .and() .withExternal() .source(States.S21) .target(States.S22) .event(Events.E22) .and() .withExternal() .source(States.S2) .target(States.S2H) .event(Events.E2H) .and() .withExternal() .source(States.S22) .target(States.S221) .event(Events.E221); }
Example #8
Source File: StateMachineConfig.java From spring-statemachine-learning with Apache License 2.0 | 5 votes |
@Override public void configure(StateMachineTransitionConfigurer<StateEnum, EventEnum> transitions) throws Exception { transitions .withExternal() .source(StateEnum.S1) .target(StateEnum.S2) .event(EventEnum.E1) .and() .withExternal() .source(StateEnum.S2) .target(StateEnum.S1) .event(EventEnum.E2); }
Example #9
Source File: StatemachineConfigurer.java From tools-journey with Apache License 2.0 | 5 votes |
@Override public void configure(StateMachineTransitionConfigurer<TurnstileStates, TurnstileEvents> transitions) throws Exception { transitions .withExternal() .source(TurnstileStates.Unlocked).target(TurnstileStates.Locked) .event(TurnstileEvents.PUSH).action(customerPassAndLock()) .and() .withExternal() .source(TurnstileStates.Locked).target(TurnstileStates.Unlocked) .event(TurnstileEvents.COIN).action(turnstileUnlock()) ; }
Example #10
Source File: HierarchicalStateMachineConfiguration.java From tutorials with MIT License | 5 votes |
@Override public void configure(StateMachineTransitionConfigurer<String, String> transitions) throws Exception { transitions.withExternal() .source("SI").target("SF").event("end") .and().withExternal() .source("SUB1").target("SUB2").event("se1") .and().withExternal() .source("SUB2").target("SUBEND").event("s-end"); }
Example #11
Source File: SimpleStateMachineConfiguration.java From tutorials with MIT License | 5 votes |
@Override public void configure(StateMachineTransitionConfigurer<String, String> transitions) throws Exception { transitions .withExternal() .source("SI") .target("S1") .event("E1") .action(initAction()) .and() .withExternal() .source("S1") .target("S2") .event("E2") .and() .withExternal() .source("SI") .target("S3") .event("E3") .and() .withExternal() .source("S3") .target("S4") .event("E4") .and() .withExternal() .source("S4") .target("S5") .event("E5") .and() .withExternal() .source("S5") .target("SF") .event("end") .guard(simpleGuard()); }
Example #12
Source File: JunctionStateMachineConfiguration.java From tutorials with MIT License | 5 votes |
@Override public void configure(StateMachineTransitionConfigurer<String, String> transitions) throws Exception { transitions.withExternal() .source("SI").target("SJ").event("E1") .and() .withJunction() .source("SJ") .first("high", highGuard()) .then("medium", mediumGuard()) .last("low") .and().withExternal() .source("low").target("SF").event("end"); }
Example #13
Source File: SimpleEnumStateMachineConfiguration.java From tutorials with MIT License | 5 votes |
@Override public void configure(StateMachineTransitionConfigurer<ApplicationReviewStates, ApplicationReviewEvents> transitions) throws Exception { transitions.withExternal() .source(ApplicationReviewStates.PEER_REVIEW).target(ApplicationReviewStates.PRINCIPAL_REVIEW).event(ApplicationReviewEvents.APPROVE) .and().withExternal() .source(ApplicationReviewStates.PRINCIPAL_REVIEW).target(ApplicationReviewStates.APPROVED).event(ApplicationReviewEvents.APPROVE) .and().withExternal() .source(ApplicationReviewStates.PEER_REVIEW).target(ApplicationReviewStates.REJECTED).event(ApplicationReviewEvents.REJECT) .and().withExternal() .source(ApplicationReviewStates.PRINCIPAL_REVIEW).target(ApplicationReviewStates.REJECTED).event(ApplicationReviewEvents.REJECT); }