Пример #1
0
  protected Object sendAction(AdminNotification action, UMOEventContext context)
      throws UMOException {
    UMOMessage result = null;
    try {
      UMOEndpoint endpoint = new MuleEndpoint(action.getResourceIdentifier(), false);

      if (AdminNotification.ACTION_DISPATCH == action.getAction()) {
        context.dispatchEvent(action.getMessage(), endpoint);
        return null;
      } else {
        endpoint.setRemoteSync(true);
        result = context.sendEvent(action.getMessage(), endpoint);
        if (result == null) {
          return null;
        } else {
          ByteArrayOutputStream out = new ByteArrayOutputStream();
          wireFormat.write(out, result);
          return out.toByteArray();
        }
      }
    } catch (Exception e) {
      return handleException(result, e);
    }
  }
Пример #2
0
  protected Object invokeAction(AdminNotification action, UMOEventContext context)
      throws UMOException {
    String destComponent = null;
    UMOMessage result = null;
    String endpoint = action.getResourceIdentifier();
    if (action.getResourceIdentifier().startsWith("mule:")) {
      destComponent = endpoint.substring(endpoint.lastIndexOf("/") + 1);
    } else {
      destComponent = endpoint;
    }

    if (destComponent != null) {
      UMOSession session = MuleManager.getInstance().getModel().getComponentSession(destComponent);
      // Need to do this otherise when the event is invoked the
      // transformer associated with the Mule Admin queue will be invoked, but
      // the
      // message will not be of expected type
      UMOEndpoint ep = new MuleEndpoint(RequestContext.getEvent().getEndpoint());
      ep.setTransformer(null);
      UMOEvent event =
          new MuleEvent(action.getMessage(), ep, context.getSession(), context.isSynchronous());
      RequestContext.setEvent(event);

      if (context.isSynchronous()) {
        result = session.getComponent().sendEvent(event);
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        wireFormat.write(out, result);
        return out.toByteArray();
      } else {
        session.getComponent().dispatchEvent(event);
        return null;
      }
    } else {
      return handleException(
          result,
          new MuleException(
              new Message(
                  Messages.COULD_NOT_DETERMINE_DESTINATION_COMPONENT_FROM_ENDPOINT_X, endpoint)));
    }
  }