Пример #1
0
  /** Loads the issues browser as standalone application. */
  public void run() {
    constructStandalone();

    // we have advice for the user when we cannot connect to a host
    Exceptions.getInstance().addHandler(ExceptionHandlerFactory.unknownHostExceptionHandler(frame));
    Exceptions.getInstance().addHandler(ExceptionHandlerFactory.connectExceptionHandler(frame));
    Exceptions.getInstance()
        .addHandler(ExceptionHandlerFactory.noRouteToHostExceptionHandler(frame));
    Exceptions.getInstance()
        .addHandler(ExceptionHandlerFactory.accessControlExceptionHandler(frame));
    Exceptions.getInstance().addHandler(ExceptionHandlerFactory.ioExceptionCode500Handler(frame));

    // create the issue loader and start loading issues
    issueLoader =
        new IssueLoader(
            issuesEventList, new IndeterminateToggler(throbber, THROBBER_ACTIVE, THROBBER_STATIC));
    issueLoader.start();

    // load issues from a file if requested
    if (startupArgs.length == 1) {
      issueLoader.setFileName(startupArgs[0]);
    }
  }
  protected static ExceptionHandlingService initExceptionHandling(
      String engineURI,
      ConfigurationEngineDefaults.ExceptionHandling exceptionHandling,
      ConfigurationEngineDefaults.ConditionHandling conditionHandling)
      throws ConfigurationException {
    List<ExceptionHandler> exceptionHandlers;
    if (exceptionHandling.getHandlerFactories() == null
        || exceptionHandling.getHandlerFactories().isEmpty()) {
      exceptionHandlers = Collections.emptyList();
    } else {
      exceptionHandlers = new ArrayList<ExceptionHandler>();
      ExceptionHandlerFactoryContext context = new ExceptionHandlerFactoryContext(engineURI);
      for (String className : exceptionHandling.getHandlerFactories()) {
        try {
          ExceptionHandlerFactory factory =
              (ExceptionHandlerFactory)
                  JavaClassHelper.instantiate(ExceptionHandlerFactory.class, className);
          ExceptionHandler handler = factory.getHandler(context);
          if (handler == null) {
            log.warn(
                "Exception handler factory '"
                    + className
                    + "' returned a null handler, skipping factory");
            continue;
          }
          exceptionHandlers.add(handler);
        } catch (RuntimeException ex) {
          throw new ConfigurationException(
              "Exception initializing exception handler from exception handler factory '"
                  + className
                  + "': "
                  + ex.getMessage(),
              ex);
        }
      }
    }

    List<ConditionHandler> conditionHandlers;
    if (conditionHandling.getHandlerFactories() == null
        || conditionHandling.getHandlerFactories().isEmpty()) {
      conditionHandlers = Collections.emptyList();
    } else {
      conditionHandlers = new ArrayList<ConditionHandler>();
      ConditionHandlerFactoryContext context = new ConditionHandlerFactoryContext(engineURI);
      for (String className : conditionHandling.getHandlerFactories()) {
        try {
          ConditionHandlerFactory factory =
              (ConditionHandlerFactory)
                  JavaClassHelper.instantiate(ConditionHandlerFactory.class, className);
          ConditionHandler handler = factory.getHandler(context);
          if (handler == null) {
            log.warn(
                "Condition handler factory '"
                    + className
                    + "' returned a null handler, skipping factory");
            continue;
          }
          conditionHandlers.add(handler);
        } catch (RuntimeException ex) {
          throw new ConfigurationException(
              "Exception initializing exception handler from exception handler factory '"
                  + className
                  + "': "
                  + ex.getMessage(),
              ex);
        }
      }
    }
    return new ExceptionHandlingService(engineURI, exceptionHandlers, conditionHandlers);
  }