org.springframework.statemachine.guard.Guard Java Examples

The following examples show how to use org.springframework.statemachine.guard.Guard. 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: MachineFactory.java    From agile-service-old with Apache License 2.0 5 votes vote down vote up
/**
 * 条件验证是否转换
 *
 * @param serviceCode
 * @return
 */
private Guard<String, String> guard(Long organizationId, String serviceCode) {
    return context -> {
        Long transformId = Long.parseLong(context.getEvent());
        InputDTO inputDTO = (InputDTO) context.getExtendedState().getVariables().get(INPUT_DTO);
        logger.info("stateMachine instance execute transform guard,instanceId:{},transformId:{}", inputDTO.getInstanceId(), transformId);
        return instanceService.validatorGuard(organizationId, serviceCode, transformId, inputDTO, context);
    };
}
 
Example #2
Source File: ChoiceStateMachine.java    From spring-statemachine-learning with Apache License 2.0 5 votes vote down vote up
@Bean
public Guard<States, Events> s2Guard() {
    return new Guard<States, Events>() {
        @Override
        public boolean evaluate(StateContext<States, Events> context) {
            return false;
        }
    };
}
 
Example #3
Source File: ChoiceStateMachine.java    From spring-statemachine-learning with Apache License 2.0 5 votes vote down vote up
@Bean
public Guard<States, Events> s3Guard() {
    return new Guard<States, Events>() {
        @Override
        public boolean evaluate(StateContext<States, Events> context) {
            return true;
        }
    };
}
 
Example #4
Source File: TaskLauncherStateMachine.java    From spring-cloud-deployer-yarn with Apache License 2.0 5 votes vote down vote up
@Override
protected Map<String, Guard<String, String>> getRegisteredGuards() {
	HashMap<String, Guard<String, String>> guards = new HashMap<>();
	guards.put("pushAppGuard", new PushAppGuard());
	guards.put("errorGuard", new ErrorGuard());
	return guards;
}
 
Example #5
Source File: AppDeployerStateMachine.java    From spring-cloud-deployer-yarn with Apache License 2.0 5 votes vote down vote up
@Override
protected Map<String, Guard<String, String>> getRegisteredGuards() {
	HashMap<String, Guard<String, String>> guards = new HashMap<>();
	guards.put("pushAppGuard", new PushAppGuard());
	guards.put("startInstanceGuard", new StartInstanceGuard());
	guards.put("errorGuard", new ErrorGuard());
	guards.put("instanceGuard", new InstanceGuard());
	return guards;
}
 
Example #6
Source File: SimpleStateMachineConfiguration.java    From tutorials with MIT License 5 votes vote down vote up
@Bean
public Guard<String, String> simpleGuard() {
    return ctx -> {
        int approvalCount = (int) ctx
          .getExtendedState()
          .getVariables()
          .getOrDefault("approvalCount", 0);
        return approvalCount > 0;
    };
}
 
Example #7
Source File: StateMachineConfiguration.java    From spring-cloud-skipper with Apache License 2.0 4 votes vote down vote up
@Bean
public Guard<SkipperStates, SkipperEvents> errorGuard() {
	return context -> context.getExtendedState().getVariables().containsKey(SkipperVariables.ERROR);
}
 
Example #8
Source File: StateMachineConfiguration.java    From spring-cloud-skipper with Apache License 2.0 4 votes vote down vote up
@Bean
public Guard<SkipperStates, SkipperEvents> rollbackInstallGuard() {
	return context -> {
		return context.getExtendedState().getVariables().containsKey(SkipperEventHeaders.INSTALL_REQUEST);
	};
}
 
Example #9
Source File: StateMachineConfiguration.java    From spring-cloud-skipper with Apache License 2.0 4 votes vote down vote up
@Bean
public Guard<SkipperStates, SkipperEvents> rollbackUpgradeGuard() {
	return context -> {
		return context.getExtendedState().getVariables().containsKey(SkipperEventHeaders.UPGRADE_REQUEST);
	};
}
 
Example #10
Source File: ForkJoinStateMachineConfiguration.java    From tutorials with MIT License 4 votes vote down vote up
@Bean
public Guard<String, String> mediumGuard() {
    return ctx -> false;
}
 
Example #11
Source File: ForkJoinStateMachineConfiguration.java    From tutorials with MIT License 4 votes vote down vote up
@Bean
public Guard<String, String> highGuard() {
    return ctx -> false;
}
 
Example #12
Source File: JunctionStateMachineConfiguration.java    From tutorials with MIT License 4 votes vote down vote up
@Bean
public Guard<String, String> mediumGuard() {
    return ctx -> false;
}
 
Example #13
Source File: JunctionStateMachineConfiguration.java    From tutorials with MIT License 4 votes vote down vote up
@Bean
public Guard<String, String> highGuard() {
    return ctx -> false;
}
 
Example #14
Source File: AbstractDeployerStateMachine.java    From spring-cloud-deployer-yarn with Apache License 2.0 2 votes vote down vote up
/**
 * Gets the registered guards.
 *
 * @return the registered guards
 */
protected abstract Map<String, Guard<String, String>> getRegisteredGuards();