Package org.apache.joran

Examples of org.apache.joran.ExecutionContext


  public void doConfigure(URL url, LoggerRepository repository) {
    // This line is needed here because there is logging from inside this method.
    this.repository = repository;

    ExecutionContext ec = joranInterpreter.getExecutionContext();
    List errorList = ec.getErrorList();

    int result = XMLUtil.checkIfWellFormed(url, errorList);
    switch (result) {
    case XMLUtil.ILL_FORMED:
    case XMLUtil.UNRECOVERABLE_ERROR:
      errorList.add(
        new ErrorItem(
          "Problem parsing XML document. See previously reported errors. Abandoning all furhter processing."));
      return;
    }

    String errMsg;
    try {
      InputStream in = url.openStream();
      doConfigure(in, repository);
      in.close();
    } catch (IOException ioe) {
      errMsg = "Could not open [" + url + "].";
      getLogger(repository).error(errMsg, ioe);
      ec.addError(new ErrorItem(errMsg, ioe));
    }
  }
View Full Code Here


    // This line is needed here because there is logging from inside this method.
    this.repository = repository;
    getLogger(repository).info(
      "in JoranConfigurator doConfigure {}", filename);

    ExecutionContext ec = joranInterpreter.getExecutionContext();
    List errorList = ec.getErrorList();

    int result = XMLUtil.checkIfWellFormed(filename, errorList);
    switch (result) {
    case XMLUtil.ILL_FORMED:
    case XMLUtil.UNRECOVERABLE_ERROR:
      errorList.add(
        new ErrorItem(
          "Problem parsing XML document. See previously reported errors. Abandoning all furhter processing."));
      return;
    }

    FileInputStream fis = null;
    try {
      fis = new FileInputStream(filename);
      doConfigure(fis, repository);
    } catch (IOException ioe) {
      String errMsg = "Could not open [" + filename + "].";
      getLogger(repository).error(errMsg, ioe);
      ec.addError(new ErrorItem(errMsg, ioe));
    } finally {
      if (fis != null) {
        try {
          fis.close();
        } catch (java.io.IOException e) {
View Full Code Here

   * All doConfigure methods evenually call this form.
   * */
  public void doConfigure(
    InputSource inputSource, LoggerRepository repository) {
    this.repository = repository;
    ExecutionContext ec = joranInterpreter.getExecutionContext();
    ec.pushObject(repository);
    String errMsg;
    try {
      attachListAppender(repository);

      getLogger(repository).debug("Starting to parse input source.");
      SAXParserFactory spf = SAXParserFactory.newInstance();

      // we want non-validating parsers
      spf.setValidating(false);
      SAXParser saxParser = spf.newSAXParser();

      saxParser.parse(inputSource, joranInterpreter);
      getLogger(repository).debug("Finished parsing.");
    } catch (SAXException e) {
      // all exceptions should have been recorded already.
    } catch (ParserConfigurationException pce) {
      errMsg = "Parser configuration error occured";
      getLogger(repository).error(errMsg, pce);
      ec.addError(new ErrorItem(errMsg, pce));
    } catch (IOException ie) {
      errMsg = "I/O error occured while parsing xml file";
      ec.addError(new ErrorItem("Parser configuration error occured", ie));
    } finally {
      detachListAppender(repository);
    }
  }
View Full Code Here

    // <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
    joranInterpreter.setEntityResolver(new Log4jEntityResolver());

    // The following line adds the capability to parse nested components
    joranInterpreter.addImplcitAction(new NestComponentIA());
    ExecutionContext ec = joranInterpreter.getExecutionContext();

    HashMap omap = ec.getObjectMap();
    omap.put(ActionConst.APPENDER_BAG, new HashMap());
  }
View Full Code Here

TOP

Related Classes of org.apache.joran.ExecutionContext

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.