org.springframework.webflow.execution.Event.<init>()方法的使用及代码示例

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

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

Event.<init>介绍

[英]Create a new event with the specified id and no payload.
[中]使用指定的id创建一个新事件,并且没有有效负载。

代码示例

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

/**
 * Returns a event with the specified identifier.
 * @param source the source of the event
 * @param eventId the result event identifier
 * @return the event
 */
public Event event(Object source, String eventId) {
  return new Event(source, eventId, null);
}

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

/**
 * Returns a event with the specified identifier and the specified set of attributes.
 * @param source the source of the event
 * @param eventId the result event identifier
 * @param attributes the event payload attributes
 * @return the event
 */
public Event event(Object source, String eventId, AttributeMap<Object> attributes) {
  return new Event(source, eventId, attributes);
}

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

public Event execute(RequestContext context) {
  return new Event(this, resultEventId, resultAttributes);
}

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

public Event getFlowEvent() {
  if (!hasFlowEvent()) {
    return null;
  }
  return new Event(this, eventId);
}

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

/**
   * Returns a result event with the specified identifier and a single attribute.
   * @param source the source of the event
   * @param eventId the result id
   * @param attributeName the attribute name
   * @param attributeValue the attribute value
   * @return the event
   */
  public Event event(Object source, String eventId, String attributeName, Object attributeValue) {
    return new Event(source, eventId, CollectionUtils.singleEntryMap(attributeName, attributeValue));
  }
}

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

protected Event doExecute(RequestContext context) throws Exception {
    if (viewFactory != null) {
      viewFactory.getView(context).render();
    }
    return new Event(this, "success");
  }
}

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

public Event getFlowEvent() {
  return new Event(this, context.getRequestParameters().get("_eventId"));
}

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

public Event getFlowEvent() {
  if (!hasFlowEvent()) {
    return null;
  }
  return new Event(this, getEventId(), requestContext.getRequestParameters().asAttributeMap());
}

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

/**
 * Get the event id to be used as grounds for a transition in the containing state, based on given result returned
 * from action execution.
 * <p>
 * If the wrapped action is named, the name will be used as a qualifier for the event (e.g. "myAction.success").
 * @param resultEvent the action result event
 */
protected Event postProcessResult(Event resultEvent) {
  if (resultEvent == null) {
    return null;
  }
  if (isNamed()) {
    // qualify result event id with action name for a named action
    String qualifiedId = getName() + "." + resultEvent.getId();
    if (logger.isDebugEnabled()) {
      logger.debug("Qualifying action result '" + resultEvent.getId() + "'; qualified result = '"
          + qualifiedId + "'");
    }
    resultEvent = new Event(resultEvent.getSource(), qualifiedId, resultEvent.getAttributes());
  }
  return resultEvent;
}

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

public Event doExecute(RequestContext context) throws Exception {
  Action[] actions = getActions();
  String eventId = getEventFactorySupport().getSuccessEventId();
  MutableAttributeMap<Object> eventAttributes = new LocalAttributeMap<>();
  List<Event> actionResults = new ArrayList<>(actions.length);
  for (Action action : actions) {
    Event result = action.execute(context);
    actionResults.add(result);
    if (result != null) {
      eventId = result.getId();
      if (isStopOnError() && result.getId().equals(getEventFactorySupport().getErrorEventId())) {
        break;
      }
    }
  }
  eventAttributes.put(ACTION_RESULTS_ATTRIBUTE_NAME, actionResults);
  return new Event(this, eventId, eventAttributes);
}

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

void endActiveFlowSession(String outcome, MutableAttributeMap<Object> output, RequestControlContext context) {
  FlowSessionImpl session = getActiveSessionInternal();
  listeners.fireSessionEnding(context, session, outcome, output);
  session.getFlow().end(context, outcome, output);
  flowSessions.removeLast();
  boolean executionEnded = flowSessions.isEmpty();
  if (executionEnded) {
    // set the root flow execution outcome for external clients to use
    this.outcome = new FlowExecutionOutcome(outcome, output);
    status = FlowExecutionStatus.ENDED;
  }
  listeners.fireSessionEnded(context, session, outcome, output);
  if (!executionEnded) {
    // restore any variables that may have transient references
    getActiveSessionInternal().getFlow().restoreVariables(context);
    // treat the outcome as an event against the current state of the new active flow
    context.handleEvent(new Event(session.getState(), outcome, output));
  }
}

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

/**
 * Returns a event with the specified identifier.
 * @param source the source of the event
 * @param eventId the result event identifier
 * @return the event
 */
public Event event(Object source, String eventId) {
  return new Event(source, eventId, null);
}

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

public void endActiveFlowSession(String outcome, MutableAttributeMap<Object> output) throws IllegalStateException {
  MockFlowSession endingSession = getMockFlowExecutionContext().getMockActiveSession();
  endingSession.getDefinitionInternal().end(this, outcome, output);
  getMockFlowExecutionContext().setActiveSession(endingSession.getParent());
  if (!getMockFlowExecutionContext().hasEnded()) {
    handleEvent(new Event(endingSession.getState(), outcome, output));
  }
}

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

public Event execute(RequestContext context) {
    executeCalled = true;
    return new Event(this, "success");
  }
}

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

public void testEventNullSource() {
  try {
    new Event(null, "id");
    fail("null source");
  } catch (IllegalArgumentException e) {
  }
}

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

public void testOnEventNullCurrentState() {
  MockRequestControlContext context = new MockRequestControlContext(flow);
  Event event = new Event(this, "foo");
  try {
    context.setCurrentEvent(event);
    flow.handleEvent(context);
  } catch (IllegalStateException e) {
  }
}

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

private MockRequestContext getRequestContext() {
    Flow flow = new Flow("id");
    MockRequestContext ctx = new MockRequestContext(flow);
    RequestContextHolder.setRequestContext(ctx);
    ctx.getFlowScope().put("foo", "bar");
    ctx.setCurrentEvent(new Event(this, "sample"));
    return ctx;
  }
}

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

public void testNewEventWithAttributes() {
  LocalAttributeMap<Object> attrs = new LocalAttributeMap<>();
  attrs.put("name", "value");
  Event event = new Event(this, "id", attrs);
  assertTrue(!event.getAttributes().isEmpty());
  assertEquals(1, event.getAttributes().size());
}

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

public void testResolveEventAttributes() {
  MockRequestContext context = new MockRequestContext();
  LocalAttributeMap<Object> attributes = new LocalAttributeMap<>();
  attributes.put("foo", "bar");
  context.setCurrentEvent(new Event(this, "event", attributes));
  Expression exp = parser.parseExpression("currentEvent.attributes.foo",
      new FluentParserContext().evaluate(RequestContext.class));
  assertEquals("bar", exp.getValue(context));
}

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

public void testElseDecision() {
  Flow flow = new Flow("flow");
  DecisionState state = new DecisionState(flow, "decisionState");
  state.getTransitionSet().add(new Transition(new MockTransitionCriteria("foo"), to("invalid")));
  state.getTransitionSet().add(new Transition(to("target")));
  new EndState(flow, "target");
  MockRequestControlContext context = new MockRequestControlContext(flow);
  context.setCurrentEvent(new Event(this, "bogus"));
  state.enter(context);
  assertFalse(context.getFlowExecutionContext().isActive());
}

相关文章

微信公众号

最新文章

更多