/** * Adds an exception-to-target state mapping to this handler. * @param exceptionClass the type of exception to map * @param targetStateId the id of the state to transition to if the specified type of exception is handled * @return this handler, to allow for adding multiple mappings in a single statement */ public TransitionExecutingFlowExecutionExceptionHandler add(Class<? extends Throwable> exceptionClass, String targetStateId) { return add(exceptionClass, new DefaultTargetStateResolver(targetStateId)); }
public Object convertSourceToTargetClass(Object source, Class<?> targetClass) throws Exception { String targetStateId = (String) source; if (!StringUtils.hasText(targetStateId)) { return null; } ExpressionParser parser = flowBuilderContext.getExpressionParser(); Expression expression = parser.parseExpression(targetStateId, new FluentParserContext().template().evaluate(RequestContext.class).expectResult(String.class)); return new DefaultTargetStateResolver(expression); } }
/** * Create transition without a criteria. * * @param targetState the target state * @return the transition */ protected Transition createTransition(final String targetState) { final DefaultTargetStateResolver resolver = new DefaultTargetStateResolver(targetState); return new Transition(resolver); }
/** * Adds an exception->state mapping to this handler. * @param exceptionClass the type of exception to map * @param targetStateId the id of the state to transition to if the specified type of exception is handled * @return this handler, to allow for adding multiple mappings in a single statement */ public TransitionExecutingStateExceptionHandler add(Class exceptionClass, String targetStateId) { return add(exceptionClass, new DefaultTargetStateResolver(targetStateId)); }
/** * Create transition without a criteria. * * @param targetState the target state * @return the transition */ protected static Transition createTransition(final String targetState) { final DefaultTargetStateResolver resolver = new DefaultTargetStateResolver(targetState); return new Transition(resolver); }
/** * Adds an exception-to-target state mapping to this handler. * @param exceptionClass the type of exception to map * @param targetStateId the id of the state to transition to if the specified type of exception is handled * @return this handler, to allow for adding multiple mappings in a single statement */ public TransitionExecutingFlowExecutionExceptionHandler add(Class<? extends Throwable> exceptionClass, String targetStateId) { return add(exceptionClass, new DefaultTargetStateResolver(targetStateId)); }
protected TargetStateResolver to(String stateId) { return new DefaultTargetStateResolver(stateId); } }
protected TargetStateResolver to(String stateId) { return new DefaultTargetStateResolver(stateId); } }
/** * Adds an exception-to-target state mapping to this handler. * @param exceptionClass the type of exception to map * @param targetStateId the id of the state to transition to if the specified type of exception is handled * @return this handler, to allow for adding multiple mappings in a single statement */ public TransitionExecutingFlowExecutionExceptionHandler add(Class exceptionClass, String targetStateId) { return add(exceptionClass, new DefaultTargetStateResolver(targetStateId)); }
protected TargetStateResolver to(String stateId) { return new DefaultTargetStateResolver(stateId); } }
@Override public Transition createTransition(final String targetState) { val resolver = new DefaultTargetStateResolver(targetState); return new Transition(resolver); }
@Override public Transition createTransition(final Expression criteriaOutcomeExpression, final String targetState) { val criteria = getTransitionCriteriaForExpression(criteriaOutcomeExpression); val resolver = new DefaultTargetStateResolver(targetState); return new Transition(criteria, resolver); }
public Object convertSourceToTargetClass(Object source, Class targetClass) throws Exception { String targetStateId = (String) source; if (!StringUtils.hasText(targetStateId)) { return null; } ExpressionParser parser = flowBuilderContext.getExpressionParser(); Expression expression = parser.parseExpression(targetStateId, new FluentParserContext().template().evaluate( RequestContext.class).expectResult(String.class)); return new DefaultTargetStateResolver(expression); } }
public Object convertSourceToTargetClass(Object source, Class<?> targetClass) throws Exception { String targetStateId = (String) source; if (!StringUtils.hasText(targetStateId)) { return null; } ExpressionParser parser = flowBuilderContext.getExpressionParser(); Expression expression = parser.parseExpression(targetStateId, new FluentParserContext().template().evaluate(RequestContext.class).expectResult(String.class)); return new DefaultTargetStateResolver(expression); } }
public void testTransitionExecutingNoSecurity() { SecurityFlowExecutionListener listener = new SecurityFlowExecutionListener(); RequestContext context = new MockRequestContext(); Transition transition = new Transition(new DefaultTargetStateResolver("target")); listener.transitionExecuting(context, transition); }
public void testResolveStateNull() { DefaultTargetStateResolver resolver = new DefaultTargetStateResolver((String) null); MockRequestContext context = new MockRequestContext(); Transition transition = new Transition(); assertEquals(null, resolver.resolveTargetState(transition, null, context)); }
public void testResolveState() { DefaultTargetStateResolver resolver = new DefaultTargetStateResolver("mockState"); MockRequestContext context = new MockRequestContext(); Transition transition = new Transition(); assertEquals("mockState", resolver.resolveTargetState(transition, null, context).getId()); }
public void testGetFlowExecutorBasicConfig() throws Exception { factoryBean.setFlowDefinitionLocator(id -> { Flow flow = new Flow(id); ViewState view = new ViewState(flow, "view", new StubViewFactory()); view.getTransitionSet().add(new Transition(new DefaultTargetStateResolver("end"))); new EndState(flow, "end"); return flow; }); factoryBean.afterPropertiesSet(); factoryBean.getObject(); }
public void testResolveStateExpression() { DefaultTargetStateResolver resolver = new DefaultTargetStateResolver(new StaticExpression("mockState")); MockRequestContext context = new MockRequestContext(); Transition transition = new Transition(); assertEquals("mockState", resolver.resolveTargetState(transition, null, context).getId()); }
protected void setUp() throws Exception { flow = new Flow("myFlow"); ViewState s1 = new ViewState(flow, "state", new StubViewFactory()); s1.getTransitionSet().add(new Transition(new DefaultTargetStateResolver("state2"))); new ViewState(flow, "state2", new StubViewFactory()); conversationManager = new StubConversationManager(); FlowDefinitionLocator locator = flowId -> flow; SerializedFlowExecutionSnapshotFactory snapshotFactory = new SerializedFlowExecutionSnapshotFactory( executionFactory, locator); repository = new DefaultFlowExecutionRepository(conversationManager, snapshotFactory); executionFactory.setExecutionKeyFactory(repository); }