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

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

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

Flow.start介绍

[英]Start a new session for this flow in its start state. This boils down to the following:

  1. Create (setup) all registered flow variables ( #addVariable(FlowVariable)) in flow scope.
  2. Map provided input data into the flow execution control context. Typically data will be mapped into flow scope using the registered input mapper ( #setInputMapper(AttributeMapper)).
  3. Execute all registered start actions ( #getStartActionList()).
  4. Enter the configured start state ( #setStartState(State))
    [中]在启动状态下为此流启动新会话。这归结为以下几点:
    1.在流作用域中创建(设置)所有已注册的流变量(#addVariable(FlowVariable))。
    1.将提供的输入数据映射到流执行控制上下文中。通常,数据将使用注册的输入映射器(#setInputMapper(AttributeMapper))映射到流范围。
    1.执行所有注册的启动操作(#getStartActionList())。
    1.输入配置的启动状态(#设置启动状态(状态))

代码示例

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

public void start(Flow flow, MutableAttributeMap<?> input) throws IllegalStateException {
  MockFlowSession session = new MockFlowSession(flow, input);
  if (getFlowExecutionContext().isActive()) {
    session.setParent(getFlowExecutionContext().getActiveSession());
  }
  getMockFlowExecutionContext().setActiveSession(session);
  flow.start(this, input);
}

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

void start(Flow flow, MutableAttributeMap<?> input, RequestControlContext context) {
  listeners.fireSessionCreating(context, flow);
  FlowSessionImpl session = activateSession(flow);
  if (session.isRoot()) {
    status = FlowExecutionStatus.ACTIVE;
  }
  if (input == null) {
    input = new LocalAttributeMap<>();
  }
  if (hasEmbeddedModeAttribute(input)) {
    session.setEmbeddedMode();
  }
  StateManageableMessageContext messageContext = (StateManageableMessageContext) context.getMessageContext();
  messageContext.setMessageSource(flow.getApplicationContext());
  listeners.fireSessionStarting(context, session, input);
  flow.start(context, input);
  listeners.fireSessionStarted(context, session);
}

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

public ViewSelection start(Flow flow, MutableAttributeMap input) throws IllegalStateException {
  getMockFlowExecutionContext().setActiveSession(new MockFlowSession(flow, input));
  getMockFlowExecutionContext().getMockActiveSession().setStatus(FlowSessionStatus.STARTING);
  ViewSelection selectedView = flow.start(this, input);
  return selectedView;
}

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

public void testStartWithoutStartState() {
  MockRequestControlContext context = new MockRequestControlContext(flow);
  try {
    Flow empty = new Flow("empty");
    empty.start(context, null);
    fail("should have failed");
  } catch (IllegalStateException e) {
  }
}

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

public ViewSelection start(Flow flow, MutableAttributeMap input) throws FlowExecutionException {
  if (input == null) {
    // create a mutable map so entries can be added by listeners!
    input = new LocalAttributeMap();
  }
  if (logger.isDebugEnabled()) {
    logger.debug("Activating new session for flow '" + flow.getId() + "' in state '"
        + flow.getStartState().getId() + "' with input " + input);
  }
  getExecutionListeners().fireSessionStarting(this, flow, input);
  FlowSession session = flowExecution.activateSession(flow);
  getExecutionListeners().fireSessionCreated(this, session);
  ViewSelection selectedView = flow.start(this, input);
  getExecutionListeners().fireSessionStarted(this, session);
  return selectedView;
}

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

public void start(Flow flow, MutableAttributeMap<?> input) throws IllegalStateException {
  MockFlowSession session = new MockFlowSession(flow, input);
  if (getFlowExecutionContext().isActive()) {
    session.setParent(getFlowExecutionContext().getActiveSession());
  }
  getMockFlowExecutionContext().setActiveSession(session);
  flow.start(this, input);
}

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

public void start(Flow flow, MutableAttributeMap input) throws IllegalStateException {
  MockFlowSession session = new MockFlowSession(flow, input);
  if (getFlowExecutionContext().isActive()) {
    session.setParent(getFlowExecutionContext().getActiveSession());
  }
  getMockFlowExecutionContext().setActiveSession(session);
  flow.start(this, input);
}

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

void start(Flow flow, MutableAttributeMap input, RequestControlContext context) {
  listeners.fireSessionCreating(context, flow);
  FlowSession session = activateSession(flow);
  if (input == null) {
    input = new LocalAttributeMap();
  }
  StateManageableMessageContext messageContext = (StateManageableMessageContext) context.getMessageContext();
  messageContext.setMessageSource(flow.getApplicationContext());
  listeners.fireSessionStarting(context, session, input);
  flow.start(context, input);
  listeners.fireSessionStarted(context, session);
}

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

public void testStart() {
  MockRequestControlContext context = new MockRequestControlContext(flow);
  flow.start(context, new LocalAttributeMap<>());
  assertEquals("Wrong start state", "myState1", context.getCurrentState().getId());
}

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

public void testStartWithVariables() {
  MockRequestControlContext context = new MockRequestControlContext(flow);
  flow.addVariable(new FlowVariable("var1", new VariableValueFactory() {
    public Object createInitialValue(RequestContext context) {
      return new ArrayList<>();
    }
    public void restoreReferences(Object value, RequestContext context) {
    }
  }));
  flow.start(context, new LocalAttributeMap<>());
  context.getFlowScope().getRequired("var1", ArrayList.class);
}

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

void start(Flow flow, MutableAttributeMap<?> input, RequestControlContext context) {
  listeners.fireSessionCreating(context, flow);
  FlowSessionImpl session = activateSession(flow);
  if (session.isRoot()) {
    status = FlowExecutionStatus.ACTIVE;
  }
  if (input == null) {
    input = new LocalAttributeMap<>();
  }
  if (hasEmbeddedModeAttribute(input)) {
    session.setEmbeddedMode();
  }
  StateManageableMessageContext messageContext = (StateManageableMessageContext) context.getMessageContext();
  messageContext.setMessageSource(flow.getApplicationContext());
  listeners.fireSessionStarting(context, session, input);
  flow.start(context, input);
  listeners.fireSessionStarted(context, session);
}

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

public void testStartWithAction() {
  MockRequestControlContext context = new MockRequestControlContext(flow);
  TestAction action = new TestAction();
  flow.getStartActionList().add(action);
  flow.start(context, new LocalAttributeMap<>());
  assertEquals("Wrong start state", "myState1", context.getCurrentState().getId());
  assertEquals(1, action.getExecutionCount());
}

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

public void testStartWithMapper() {
  DefaultMapper attributeMapper = new DefaultMapper();
  ExpressionParser parser = new WebFlowSpringELExpressionParser(new SpelExpressionParser());
  Expression x = parser.parseExpression("attr", new FluentParserContext().evaluate(AttributeMap.class));
  Expression y = parser.parseExpression("flowScope.attr",
      new FluentParserContext().evaluate(RequestContext.class));
  attributeMapper.addMapping(new DefaultMapping(x, y));
  flow.setInputMapper(attributeMapper);
  MockRequestControlContext context = new MockRequestControlContext(flow);
  LocalAttributeMap<Object> sessionInput = new LocalAttributeMap<>();
  sessionInput.put("attr", "foo");
  flow.start(context, sessionInput);
  assertEquals("foo", context.getFlowScope().get("attr"));
}

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

public void testStartWithMapperButNoInput() {
  DefaultMapper attributeMapper = new DefaultMapper();
  ExpressionParser parser = new WebFlowSpringELExpressionParser(new SpelExpressionParser());
  Expression x = parser.parseExpression("attr", new FluentParserContext().evaluate(AttributeMap.class));
  Expression y = parser.parseExpression("flowScope.attr",
      new FluentParserContext().evaluate(RequestContext.class));
  attributeMapper.addMapping(new DefaultMapping(x, y));
  flow.setInputMapper(attributeMapper);
  MockRequestControlContext context = new MockRequestControlContext(flow);
  LocalAttributeMap<Object> sessionInput = new LocalAttributeMap<>();
  flow.start(context, sessionInput);
  assertTrue(context.getFlowScope().contains("attr"));
  assertNull(context.getFlowScope().get("attr"));
}

相关文章