Example #1
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)));
    }
  }