org.springframework.webflow.engine.Flow.getStateInstance()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(9.4k)|赞(0)|评价(0)|浏览(121)

本文整理了Java中org.springframework.webflow.engine.Flow.getStateInstance()方法的一些代码示例,展示了Flow.getStateInstance()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Flow.getStateInstance()方法的具体详情如下:
包路径:org.springframework.webflow.engine.Flow
类名称:Flow
方法名:getStateInstance

Flow.getStateInstance介绍

[英]Lookup the identified state instance of this flow.
[中]查找此流的已标识状态实例。

代码示例

代码示例来源:origin: org.springframework.webflow/spring-webflow

public StateDefinition getState(String stateId) {
  return getStateInstance(stateId);
}

代码示例来源:origin: org.springframework.webflow/spring-webflow

/**
 * Set the start state for this flow to the state with the provided <code>stateId</code>; a state must exist by the
 * provided <code>stateId</code>.
 * @param stateId the id of the new start state
 * @throws IllegalArgumentException when no state exists with the id you provided
 */
public void setStartState(String stateId) throws IllegalArgumentException {
  setStartState(getStateInstance(stateId));
}

代码示例来源:origin: org.springframework.webflow/spring-webflow

/**
 * Return the <code>TransitionableState</code> with given <code>stateId</code>.
 * @param stateId id of the state to look up
 * @return the transitionable state
 * @throws IllegalArgumentException if the identified state cannot be found
 * @throws ClassCastException when the identified state is not transitionable
 */
public TransitionableState getTransitionableState(String stateId) throws IllegalArgumentException,
    ClassCastException {
  State state = getStateInstance(stateId);
  if (state != null && !(state instanceof TransitionableState)) {
    throw new ClassCastException("The state '" + stateId + "' of flow '" + getId() + "' must be transitionable");
  }
  return (TransitionableState) state;
}

代码示例来源:origin: org.springframework.webflow/spring-webflow

public State resolveTargetState(Transition transition, State sourceState, RequestContext context) {
  String targetStateId = (String) targetStateIdExpression.getValue(context);
  if (targetStateId != null) {
    return ((Flow) context.getActiveFlow()).getStateInstance(targetStateId);
  } else {
    return null;
  }
}

代码示例来源:origin: org.springframework.webflow/spring-webflow

/**
 * Jump to a state of the currently active flow. If this execution has not been started, a new session will be
 * activated and its current state will be set. This is a implementation-internal method that bypasses the
 * {@link #start(MutableAttributeMap, ExternalContext)} operation and allows for jumping to an arbitrary flow state.
 * Useful for testing.
 * @param stateId the identifier of the state to jump to
 */
public void setCurrentState(String stateId) {
  FlowSessionImpl session;
  if (status == FlowExecutionStatus.NOT_STARTED) {
    session = activateSession(flow);
    status = FlowExecutionStatus.ACTIVE;
  } else {
    session = getActiveSessionInternal();
  }
  State state = session.getFlow().getStateInstance(stateId);
  session.setCurrentState(state);
}

代码示例来源:origin: org.springframework.webflow/spring-webflow

/**
 * Try to handle given exception using execution exception handlers registered at the state level. Returns null if
 * no handler handled the exception.
 * @return true if the exception was handled
 */
private boolean tryStateHandlers(FlowExecutionException exception, RequestControlContext context) {
  if (exception.getStateId() != null) {
    State state = getActiveSessionInternal().getFlow().getStateInstance(exception.getStateId());
    return state.handleException(exception, context);
  } else {
    return false;
  }
}

代码示例来源:origin: org.springframework.webflow/spring-webflow

FlowSessionImpl rootSession = execution.getRootSession();
rootSession.setFlow(flow);
rootSession.setState(flow.getStateInstance(rootSession.getStateId()));
if (execution.hasSubflowSessions()) {
  for (Iterator<FlowSessionImpl> it = execution.getSubflowSessionIterator(); it.hasNext();) {
    Flow subflowDef = (Flow) subflowDefinitionLocator.getFlowDefinition(subflowSession.getFlowId());
    subflowSession.setFlow(subflowDef);
    subflowSession.setState(subflowDef.getStateInstance(subflowSession.getStateId()));

代码示例来源:origin: org.springframework.webflow/org.springframework.webflow

/**
 * Set the start state for this flow to the state with the provided <code>stateId</code>; a state must exist by the
 * provided <code>stateId</code>.
 * @param stateId the id of the new start state
 * @throws IllegalArgumentException when no state exists with the id you provided
 */
public void setStartState(String stateId) throws IllegalArgumentException {
  setStartState(getStateInstance(stateId));
}

代码示例来源:origin: spring-projects/spring-webflow

/**
 * Set the start state for this flow to the state with the provided <code>stateId</code>; a state must exist by the
 * provided <code>stateId</code>.
 * @param stateId the id of the new start state
 * @throws IllegalArgumentException when no state exists with the id you provided
 */
public void setStartState(String stateId) throws IllegalArgumentException {
  setStartState(getStateInstance(stateId));
}

代码示例来源:origin: org.springframework.webflow/org.springframework.webflow

public State resolveTargetState(Transition transition, State sourceState, RequestContext context) {
  String targetStateId = (String) targetStateIdExpression.getValue(context);
  if (targetStateId != null) {
    return ((Flow) context.getActiveFlow()).getStateInstance(targetStateId);
  } else {
    return null;
  }
}

代码示例来源:origin: org.springframework/spring-webflow

/**
 * Try to handle given exception using execution exception handlers registered at the state level. Returns null if
 * no handler handled the exception.
 */
private ViewSelection tryStateHandlers(FlowExecutionException exception, RequestControlContext context) {
  if (isActive() && exception.getStateId() != null) {
    return getActiveFlow().getStateInstance(exception.getStateId()).handleException(exception, context);
  } else {
    return null;
  }
}

代码示例来源:origin: spring-projects/spring-webflow

public void testOnEventInvalidCurrentState() {
  MockRequestControlContext context = new MockRequestControlContext(flow);
  context.setCurrentState(flow.getStateInstance("myState2"));
  Event event = new Event(this, "submit");
  context.setCurrentEvent(event);
  try {
    context.setCurrentEvent(event);
    flow.handleEvent(context);
  } catch (IllegalStateException e) {
  }
}

代码示例来源:origin: spring-projects/spring-webflow

public void testOnEventNoTransition() {
  MockRequestControlContext context = new MockRequestControlContext(flow);
  context.setCurrentState(flow.getStateInstance("myState1"));
  Event event = new Event(this, "bogus");
  context.setCurrentEvent(event);
  try {
    context.setCurrentEvent(event);
    flow.handleEvent(context);
  } catch (NoMatchingTransitionException e) {
  }
}

代码示例来源:origin: spring-projects/spring-webflow

public void testViewStateRedirect() {
  ViewStateModel view = new ViewStateModel("view");
  view.setRedirect("true");
  model.setStates(asList(view));
  Flow flow = getFlow(model);
  assertTrue(((ViewState) flow.getStateInstance("view")).getRedirect());
}

代码示例来源:origin: spring-projects/spring-webflow

public void testViewStateExternalRedirect() {
  ViewStateModel state = new ViewStateModel("view");
  state.setView("externalRedirect:http://www.paypal.com?_callbackUrl=#{flowExecutionUri}");
  model.setStates(asList(state));
  Flow flow = getFlow(model);
  ViewFactory vf = ((ViewState) flow.getStateInstance("view")).getViewFactory();
  assertTrue(vf instanceof ActionExecutingViewFactory);
  ActionExecutingViewFactory avf = (ActionExecutingViewFactory) vf;
  assertTrue(avf.getAction() instanceof ExternalRedirectAction);
}

代码示例来源:origin: spring-projects/spring-webflow

public void testViewStateVariable() {
  ViewStateModel view = new ViewStateModel("view");
  view.setVars(asList(new VarModel("foo", "org.springframework.webflow.TestBean")));
  model.setStates(asList(view));
  Flow flow = getFlow(model);
  assertNotNull(((ViewState) flow.getStateInstance("view")).getVariable("foo"));
}

代码示例来源:origin: spring-projects/spring-webflow

public void testViewStateFlowRedirect() {
  ViewStateModel state = new ViewStateModel("view");
  state.setView("flowRedirect:myFlow?input=#{flowScope.foo}");
  model.setStates(asList(state));
  Flow flow = getFlow(model);
  ViewFactory vf = ((ViewState) flow.getStateInstance("view")).getViewFactory();
  assertTrue(vf instanceof ActionExecutingViewFactory);
  ActionExecutingViewFactory avf = (ActionExecutingViewFactory) vf;
  assertTrue(avf.getAction() instanceof FlowDefinitionRedirectAction);
}

代码示例来源:origin: spring-projects/spring-webflow

public void testOnEvent() {
  MockRequestControlContext context = new MockRequestControlContext(flow);
  context.setCurrentState(flow.getStateInstance("myState1"));
  Event event = new Event(this, "submit");
  context.setCurrentEvent(event);
  assertTrue(context.getFlowExecutionContext().isActive());
  context.setCurrentEvent(event);
  flow.handleEvent(context);
  assertTrue(!context.getFlowExecutionContext().isActive());
}

代码示例来源:origin: spring-projects/spring-webflow

public void testOnEventGlobalTransition() {
  MockRequestControlContext context = new MockRequestControlContext(flow);
  context.setCurrentState(flow.getStateInstance("myState1"));
  Event event = new Event(this, "globalEvent");
  context.setCurrentEvent(event);
  assertTrue(context.getFlowExecutionContext().isActive());
  context.setCurrentEvent(event);
  flow.handleEvent(context);
  assertTrue(!context.getFlowExecutionContext().isActive());
}

代码示例来源:origin: spring-projects/spring-webflow

public void testHandleException() {
  flow.getExceptionHandlerSet().add(
      new TransitionExecutingFlowExecutionExceptionHandler().add(TestException.class, "myState2"));
  MockRequestControlContext context = new MockRequestControlContext(flow);
  context.setCurrentState(flow.getStateInstance("myState1"));
  FlowExecutionException e = new FlowExecutionException(flow.getId(), flow.getStartState().getId(), "Oops!",
      new TestException());
  flow.handleException(e, context);
  assertFalse(context.getFlowExecutionContext().isActive());
}

相关文章