@Override
  protected void doRun(Event event) throws Exception {

    // check the global COORDINATION_MESSAGE (must be ABORT)
    if (event instanceof CloseFromOtherNeedEvent) {
      WonMessage wonMessage = ((CloseFromOtherNeedEvent) event).getWonMessage();
      NodeIterator ni =
          RdfUtils.visitFlattenedToNodeIterator(
              wonMessage.getMessageContent(),
              new RdfUtils.ModelVisitor<NodeIterator>() {
                @Override
                public NodeIterator visit(final Model model) {
                  return model.listObjectsOfProperty(
                      model.createProperty(WON_TX.COORDINATION_MESSAGE.getURI()));
                }
              });
      if (ni.hasNext()) {
        String coordinationMessageUri = ni.toList().get(0).asResource().getURI().toString();
        if (coordinationMessageUri.equals(WON_TX.COORDINATION_MESSAGE_ABORT.getURI().toString()))
          logger.debug("Sent COORDINATION_MESSAGE: {}", coordinationMessageUri);
        else
          logger.error(
              "Content of the COORDINATION_MESSAGE must be: {}. Currently it is: {}",
              WON_TX.COORDINATION_MESSAGE_ABORT.getURI(),
              coordinationMessageUri);
      }
    }
    List<URI> toDeactivate = getEventListenerContext().getBotContext().listNeedUris();
    for (URI uri : toDeactivate) {
      getEventListenerContext().getOwnerService().deactivate(uri, createWonMessage(uri));
      getEventListenerContext().getEventBus().publish(new NeedDeactivatedEvent(uri));
    }
  }
コード例 #2
0
 @Override
 public void process(final Exchange exchange) throws Exception {
   WonMessage message = (WonMessage) exchange.getIn().getHeader(WonCamelConstants.MESSAGE_HEADER);
   sendMessageToOwner(
       message,
       message.getReceiverNeedURI(),
       (String) exchange.getIn().getHeader(WonCamelConstants.OWNER_APPLICATION_ID));
 }
 @Override
 public boolean matches(final Exchange exchange) {
   WonMessage wonMessage =
       (WonMessage) exchange.getIn().getHeader(WonCamelConstants.MESSAGE_HEADER);
   WonMessageType messageType = wonMessage.getMessageType();
   switch (messageType) {
     case DEACTIVATE:
       return false;
     case ACTIVATE:
       return false;
     case CREATE_NEED:
       return false;
     case SUCCESS_RESPONSE:
       return false;
     case FAILURE_RESPONSE:
       return false;
   }
   return true;
 }