Package com.bleujin.framework.util

Examples of com.bleujin.framework.util.InvalidSetupException


  }

  private void initLoggers(Configuration config) throws InvalidSetupException {
    try {
      if (!config.getTagName().equals("logs"))
        throw new InvalidSetupException("unknown configuration.");

      PrintStream out = System.out;

      out.println("initializing loggers.");
      // make handlers
      try {
        Configuration[] handlerConfigs = config.getChildren("handler");

        for (int i = 0; i < handlerConfigs.length; ++i) {
          Configuration handlerConfig = handlerConfigs[i];

          String handlerName = handlerConfig.getChild("handler-name")
              .getValue();

          // create handler
          Handler handler = (Handler) InstanceCreator
              .createConfiguredInstance(handlerConfig
                  .getChild("configured-object"));

          // set level if necessary
          try {
            String level = handlerConfig.getChild("level")
                .getValue();
            handler.setLevel(Level.parse(level));
          } catch (NotFoundXmlTagException notFoundEx) {
            out.println("handler:" + handlerName
                + " :skipped setting level.");
          }

          // set formatter if necessary
          try {
            String formatterName = handlerConfig.getChild(
                "formatter").getValue();
            java.util.logging.Formatter formatter = (java.util.logging.Formatter) Class
                .forName(formatterName).newInstance();
            handler.setFormatter(formatter);
          } catch (NotFoundXmlTagException notFoundEx) {
            out.println("handler:" + handlerName
                + " :skipped setting formatter.");
          }

          // set encoding if necessary
          try {
            String encoding = handlerConfig.getChild("encoding")
                .getValue();
            handler.setEncoding(encoding);
          } catch (NotFoundXmlTagException notFoundEx) {
            out.println("handler:" + handlerName
                + ":skipped setting encoding charset.");
          }

          // ���̺� ��� ���ѵд�.
          handlers.put(handlerName, handler);
        }
      } catch (NotFoundXmlTagException noTag) {
        out.println("skipped making handlers.");
      }

      // loggers
      try {
        Configuration[] loggerConfigs = config.getChildren("logger");

        for (int i = 0; i < loggerConfigs.length; ++i) {
          Configuration loggerConfig = loggerConfigs[i];

          String loggerName = loggerConfig.getChild("logger-name")
              .getValue();
          Logger logger = Logger.getLogger(loggerName);

          Configuration[] handlerNameConfigs = loggerConfig
              .getChildren("handler-name");
          for (int j = 0; j < handlerNameConfigs.length; ++j) {
            String handlerName = handlerNameConfigs[j].getValue();
            Handler handler = (Handler) handlers.get(handlerName);

            if (handler == null)
              throw new InvalidSetupException(
                  "not found handler:" + handlerName);

            logger.addHandler(handler);
          }
        }
      } catch (NotFoundXmlTagException noTag) {
        out.println("skipped setting loggers.");
      }

      // mapping
      try {
        Configuration[] loggerMappingConfigs = config
            .getChildren("logger-mapping");
        for (int i = 0; i < loggerMappingConfigs.length; ++i) {
          Configuration loggerMappingConfig = loggerMappingConfigs[i];

          String pattern = loggerMappingConfig.getChild("pattern")
              .getValue();
          String loggerName = loggerMappingConfig.getChild(
              "logger-name").getValue();

          addMapping(pattern, loggerName);
        }
      } catch (NotFoundXmlTagException noTag) {
        out.println("skipped setting mapping.");
      }

      out.println("initialized.");

    } catch (Exception ex) {
      throw new InvalidSetupException(ex);
    }
  }
View Full Code Here


     
      emanager = HttpExceptionManager.getExceptionManager("Common HTTP Exception Manager");
      emanager.addHandler(new DupValOnIndexExceptionHandler()) ;
      emanager.addHandler(new LastOutExceptionHandler("contact me : bleujin@gamil.com")) ;
    } catch (Exception e) {
      throw new InvalidSetupException(e) ;
    }
  }
View Full Code Here

TOP

Related Classes of com.bleujin.framework.util.InvalidSetupException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.