org.springframework.statemachine.config.builders.StateMachineStateConfigurer Java Examples
The following examples show how to use
org.springframework.statemachine.config.builders.StateMachineStateConfigurer.
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: JunctionStateMachine.java From spring-statemachine-learning with Apache License 2.0 | 6 votes |
@Override public void configure(StateMachineStateConfigurer<States, Events> states) throws Exception { states .withStates() .initial(States.S1) .state(States.S2) .and() .withStates() .parent(States.S2) .initial(States.S2I) .state(States.S21) .state(States.S22) .history(States.S2H, StateConfigurer.History.SHALLOW). and() .withStates() .parent(States.S22) .initial(States.S22I) .state(States.S221) .state(States.S222); }
Example #2
Source File: HistoryStateMachine.java From spring-statemachine-learning with Apache License 2.0 | 6 votes |
@Override public void configure(StateMachineStateConfigurer<States, Events> states) throws Exception { states .withStates() .initial(States.S1) .state(States.S2) .and() .withStates() .parent(States.S2) .initial(States.S2I) .state(States.S21) .state(States.S22) .history(States.S2H, StateConfigurer.History.SHALLOW). and() .withStates() .parent(States.S22) .initial(States.S22I) .state(States.S221) .state(States.S222); }
Example #3
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 #4
Source File: ForkJoinStateMachineConfiguration.java From tutorials with MIT License | 6 votes |
@Override public void configure(StateMachineStateConfigurer<String, String> states) throws Exception { states .withStates() .initial("SI") .fork("SFork") .join("SJoin") .end("SF") .and() .withStates() .parent("SFork") .initial("Sub1-1") .end("Sub1-2") .and() .withStates() .parent("SFork") .initial("Sub2-1") .end("Sub2-2"); }
Example #5
Source File: StateMachineConfig.java From spring-boot-tutorial with Creative Commons Attribution Share Alike 4.0 International | 5 votes |
@Override public void configure(StateMachineStateConfigurer<States, Events> states) throws Exception { // @formatter:off states .withStates() .initial(States.SI) .states(EnumSet.allOf(States.class)); // @formatter:on }
Example #6
Source File: ChoiceStateMachine.java From spring-statemachine-learning with Apache License 2.0 | 5 votes |
@Override public void configure(StateMachineStateConfigurer<States, Events> states) throws Exception { states .withStates() .initial(States.SI) .choice(States.S1) .end(States.SF) .states(EnumSet.allOf(States.class)); }
Example #7
Source File: ForkJoinStateMachine.java From spring-statemachine-learning with Apache License 2.0 | 5 votes |
@Override public void configure(StateMachineStateConfigurer<States, Events> states) throws Exception { states .withStates() .initial(States.SI) .fork(States.S1) .join(States.S5) .state(States.S2) .state(States.S3) .state(States.S4); }
Example #8
Source File: StateMachineConfig.java From spring-statemachine-learning with Apache License 2.0 | 5 votes |
@Override public void configure(StateMachineStateConfigurer<StateEnum, EventEnum> states) throws Exception { states .withStates() .initial(StateEnum.S1) .states(EnumSet.allOf(StateEnum.class)); }
Example #9
Source File: StatemachineConfigurer.java From tools-journey with Apache License 2.0 | 5 votes |
@Override public void configure(StateMachineStateConfigurer<TurnstileStates, TurnstileEvents> states) throws Exception { states .withStates() // 初识状态:Locked .initial(TurnstileStates.Locked) .states(EnumSet.allOf(TurnstileStates.class)); }
Example #10
Source File: HierarchicalStateMachineConfiguration.java From tutorials with MIT License | 5 votes |
@Override public void configure(StateMachineStateConfigurer<String, String> states) throws Exception { states .withStates() .initial("SI") .state("SI") .end("SF") .and() .withStates() .parent("SI") .initial("SUB1") .state("SUB2") .end("SUBEND"); }
Example #11
Source File: SimpleStateMachineConfiguration.java From tutorials with MIT License | 5 votes |
@Override public void configure(StateMachineStateConfigurer<String, String> states) throws Exception { states .withStates() .initial("SI") .end("SF") .states(new HashSet<>(Arrays.asList("S1", "S2"))) .stateEntry("S3", entryAction()) .stateExit("S3", exitAction()) .state("S4", executeAction(), errorAction()) .stateDo("S5", executeAction()); }
Example #12
Source File: JunctionStateMachineConfiguration.java From tutorials with MIT License | 5 votes |
@Override public void configure(StateMachineStateConfigurer<String, String> states) throws Exception { states .withStates() .initial("SI") .junction("SJ") .state("high") .state("medium") .state("low") .end("SF"); }
Example #13
Source File: SimpleEnumStateMachineConfiguration.java From tutorials with MIT License | 5 votes |
@Override public void configure(StateMachineStateConfigurer<ApplicationReviewStates, ApplicationReviewEvents> states) throws Exception { states .withStates() .initial(ApplicationReviewStates.PEER_REVIEW) .state(ApplicationReviewStates.PRINCIPAL_REVIEW) .end(ApplicationReviewStates.APPROVED) .end(ApplicationReviewStates.REJECTED); }
Example #14
Source File: StateMachineConfiguration.java From spring-cloud-skipper with Apache License 2.0 | 4 votes |
@Override public void configure(StateMachineStateConfigurer<SkipperStates, SkipperEvents> states) throws Exception { states // there's no need to explicitly define supported states // as every state id used in below config, adds it as supported state .withStates() // define main states .initial(SkipperStates.INITIAL) .stateEntry(SkipperStates.ERROR, errorAction()) // clear memory for stored variables .stateExit(SkipperStates.INITIAL, resetVariablesAction()) .state(SkipperStates.INSTALL) .state(SkipperStates.DELETE) .state(SkipperStates.SCALE) .state(SkipperStates.UPGRADE) .state(SkipperStates.ROLLBACK) .junction(SkipperStates.ERROR_JUNCTION) .and() .withStates() // substates for install .parent(SkipperStates.INSTALL) .initial(SkipperStates.INSTALL_INSTALL) .stateEntry(SkipperStates.INSTALL_INSTALL, installInstallAction()) .exit(SkipperStates.INSTALL_EXIT) .and() .withStates() // substates for upgrade .parent(SkipperStates.UPGRADE) .initial(SkipperStates.UPGRADE_START) .stateEntry(SkipperStates.UPGRADE_START, upgradeStartAction()) .stateEntry(SkipperStates.UPGRADE_DEPLOY_TARGET_APPS, upgradeDeployTargetAppsAction()) .state(SkipperStates.UPGRADE_WAIT_TARGET_APPS) .state(SkipperStates.UPGRADE_CHECK_TARGET_APPS, SkipperEvents.UPGRADE_CANCEL) .stateEntry(SkipperStates.UPGRADE_CHECK_TARGET_APPS, upgradeCheckTargetAppsAction()) .stateEntry(SkipperStates.UPGRADE_DEPLOY_TARGET_APPS_SUCCEED, upgradeDeployTargetAppsSucceedAction()) .stateEntry(SkipperStates.UPGRADE_DEPLOY_TARGET_APPS_FAILED, upgradeDeployTargetAppsFailedAction()) .stateEntry(SkipperStates.UPGRADE_CANCEL, upgradeCancelAction()) .stateEntry(SkipperStates.UPGRADE_DELETE_SOURCE_APPS, upgradeDeleteSourceAppsAction()) .choice(SkipperStates.UPGRADE_CHECK_CHOICE) .exit(SkipperStates.UPGRADE_EXIT) .and() .withStates() // substates for scale .parent(SkipperStates.SCALE) .initial(SkipperStates.SCALE_SCALE) .stateEntry(SkipperStates.SCALE_SCALE, scaleScaleAction()) .exit(SkipperStates.SCALE_EXIT) .and() .withStates() // substates for delete .parent(SkipperStates.DELETE) .initial(SkipperStates.DELETE_DELETE) .stateEntry(SkipperStates.DELETE_DELETE, deleteDeleteAction()) .exit(SkipperStates.DELETE_EXIT) .and() .withStates() // substates for rollback .parent(SkipperStates.ROLLBACK) .initial(SkipperStates.ROLLBACK_START) .stateEntry(SkipperStates.ROLLBACK_START, rollbackStartAction()) .choice(SkipperStates.ROLLBACK_CHOICE) .exit(SkipperStates.ROLLBACK_EXIT_UPGRADE) .exit(SkipperStates.ROLLBACK_EXIT_INSTALL) .exit(SkipperStates.ROLLBACK_EXIT); }