コード例 #1
0
  // //@Override
  public ServiceDescriptor lookupServiceDescriptor(String type, String name, Properties overrides)
      throws ServiceException {
    try {
      // Get all services which match the interface.
      ServiceReference[] services;
      if (context != null) {
        services = context.getServiceReferences(TransportServiceDescriptor.class.getName(), null);
      } else {
        throw new InitialisationException(
            Message.createStaticMessage("BundleContext has not been set for Manager."), this);
      }

      // Match the service by name.
      String servicePid;
      for (int i = 0; i < services.length; ++i) {
        servicePid = (String) services[i].getProperty(Constants.SERVICE_PID);
        if (servicePid != null && servicePid.endsWith(name)) {
          return (ServiceDescriptor) context.getService(services[i]);
        }
      }
      return null;
    } catch (Exception e) {
      throw new ServiceException(
          Message.createStaticMessage("Exception while looking up the service descriptor."), e);
    }
  }
コード例 #2
0
 private static Message generateMessage(Message message, Connector connector) {
   Message m = CoreMessages.connectorCausedError(connector);
   if (message != null) {
     message.setNextMessage(m);
   }
   return message;
 }
コード例 #3
0
 public int hashCode() {
   int result;
   result = errorCode;
   result = 29 * result + (message != null ? message.hashCode() : 0);
   result = 29 * result + (i18nMessage != null ? i18nMessage.hashCode() : 0);
   return result;
 }
コード例 #4
0
  /** application entry point */
  public static void main(String[] args) {
    Server server = new Server();
    List opts = Arrays.asList(args);
    String config = null;

    if (opts.size() > 0) {
      config = getOption("-config", opts);
      if (config != null) {
        server.setConfigurationResources(config);
      }
    } else {
      URL configUrl = ClassHelper.getResource("mule-jbi.xml", org.mule.MuleServer.class);
      if (configUrl != null) {
        config = configUrl.toExternalForm();
        server.setConfigurationResources(config);
      }
    }

    if (config == null) {
      Message message = new Message(Messages.CONFIG_NOT_FOUND_USAGE);
      logger.fatal(message.toString());
      System.exit(0);
    }

    String builder = getOption("-builder", opts);
    if (builder != null) {
      try {
        configBuilder =
            (JbiContainerBuilder) ClassHelper.loadClass(builder, Server.class).newInstance();
      } catch (Exception e) {
        logger.fatal(new Message(Messages.FAILED_LOAD_X, "Builder: " + builder), e);
      }
    } else {
      // use this by default
      // try {
      configBuilder = new MuleXmlJbiContainerBuilder();
      //            } catch (ConfigurationException e) {
      //                logger.fatal(e.getMessage(), e);
      //                System.exit(0);
      //            }
    }

    server.start(false);
  }
コード例 #5
0
  /**
   * Will shut down the server displaying the cause and time of the shutdown
   *
   * @param e the exception that caused the shutdown
   */
  void shutdown(Throwable e) {
    Message msg = new Message(Messages.FATAL_ERROR_WHILE_RUNNING);
    UMOException muleException = ExceptionHelper.getRootMuleException(e);
    if (muleException != null) {
      logger.fatal(muleException.getDetailedMessage());
    } else {
      logger.fatal(msg.toString() + " " + e.getMessage(), e);
    }
    List msgs = new ArrayList();
    msgs.add(msg.getMessage());
    Throwable root = ExceptionHelper.getRootException(e);
    msgs.add(root.getMessage() + " (" + root.getClass().getName() + ")");
    msgs.add(" ");
    msgs.add(new Message(Messages.FATAL_ERROR_SHUTDOWN));
    msgs.add(
        new Message(
            Messages.SERVER_STARTED_AT_X, new Date(MuleManager.getInstance().getStartDate())));
    msgs.add(new Message(Messages.SERVER_SHUTDOWN_AT_X, new Date().toString()));

    shutdownMessage = StringMessageHelper.getBoilerPlate(msgs, '*', 80);
    logger.fatal(shutdownMessage);
    System.exit(0);
  }
コード例 #6
0
  public Object onCall(UMOEventContext context) throws Exception {
    String contents = context.getTransformedMessageAsString();
    String msg =
        StringMessageUtils.getBoilerPlate(
            "Message Received in component: "
                + context.getComponentDescriptor().getName()
                + ". Content is: "
                + StringMessageUtils.truncate(contents, 100, true),
            '*',
            80);

    logger.info(msg);

    if (eventCallback != null) {
      eventCallback.eventReceived(context, this);
    }

    Object replyMessage;
    if (returnMessage != null) {
      replyMessage = returnMessage;
    } else {
      replyMessage =
          contents
              + " Received"
              + (appendComponentName ? " " + context.getComponentDescriptor().getName() : "");
    }

    MuleManager.getInstance()
        .fireNotification(
            new FunctionalTestNotification(
                context, replyMessage, FunctionalTestNotification.EVENT_RECEIVED));

    if (throwException) {
      throw new MuleException(Message.createStaticMessage("Functional Test Component Exception"));
    }

    return replyMessage;
  }
コード例 #7
0
  public boolean equals(Object o) {
    if (this == o) {
      return true;
    }
    if (!(o instanceof MuleException)) {
      return false;
    }

    final MuleException umoException = (MuleException) o;

    if (errorCode != umoException.errorCode) {
      return false;
    }
    if (i18nMessage != null
        ? !i18nMessage.equals(umoException.i18nMessage)
        : umoException.i18nMessage != null) {
      return false;
    }
    if (message != null ? !message.equals(umoException.message) : umoException.message != null) {
      return false;
    }

    return true;
  }
コード例 #8
0
 public MuleException(String message, Throwable cause) {
   this(Message.createStaticMessage(message), cause);
 }
コード例 #9
0
 public MuleException(String message) {
   this(Message.createStaticMessage(message));
 }
コード例 #10
0
 /**
  * @param message
  * @param cause
  */
 public FatalException(String message, Throwable cause) {
   super(Message.createStaticMessage(message), cause);
 }
コード例 #11
0
 public int getMessageCode() {
   return (i18nMessage == null ? 0 : i18nMessage.getCode());
 }
コード例 #12
0
 protected void setMessage(Message message) {
   initialise();
   this.message = message.getMessage();
   i18nMessage = message;
 }