コード例 #1
0
  private static void initialise() {
    try {
      if (initialised) {
        return;
      }

      registerExceptionReader(new MuleExceptionReader());
      registerExceptionReader(new NamingExceptionReader());
      J2SE_VERSION = System.getProperty("java.specification.version");

      String name =
          SpiUtils.SERVICE_ROOT
              + ServiceType.EXCEPTION.getPath()
              + "/mule-exception-codes.properties";
      InputStream in = ExceptionHelper.class.getClassLoader().getResourceAsStream(name);
      if (in == null) {
        throw new IllegalArgumentException("Failed to load resource: " + name);
      }
      errorCodes.load(in);
      in.close();

      reverseErrorCodes = MapUtils.invertMap(errorCodes);

      name =
          SpiUtils.SERVICE_ROOT
              + ServiceType.EXCEPTION.getPath()
              + "/mule-exception-config.properties";
      in = ExceptionHelper.class.getClassLoader().getResourceAsStream(name);
      if (in == null) {
        throw new IllegalArgumentException("Failed to load resource: " + name);
      }
      errorDocs.load(in);
      in.close();

      initialised = true;
    } catch (Exception e) {
      throw new MuleRuntimeException(CoreMessages.failedToLoad("Exception resources"), e);
    }
  }
コード例 #2
0
  private static Properties getErrorMappings(String protocol) {
    Object m = errorMappings.get(protocol);
    if (m != null) {
      if (m instanceof Properties) {
        return (Properties) m;
      } else {
        return null;
      }
    } else {
      String name =
          SpiUtils.SERVICE_ROOT
              + ServiceType.EXCEPTION.getPath()
              + "/"
              + protocol
              + "-exception-mappings.properties";
      InputStream in = ExceptionHelper.class.getClassLoader().getResourceAsStream(name);
      if (in == null) {
        errorMappings.put(protocol, "not found");
        if (logger.isDebugEnabled()) {
          logger.debug(
              "Failed to load error mappings from: "
                  + name
                  + " This may be because there are no error code mappings for protocol: "
                  + protocol);
        }
        return null;
      }

      Properties p = new Properties();
      try {
        p.load(in);
        in.close();
      } catch (IOException iox) {
        throw new IllegalArgumentException("Failed to load resource: " + name);
      }

      errorMappings.put(protocol, p);
      return p;
    }
  }