cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jo...@apache.org
Subject cvs commit: cocoon-2.1/src/java/org/apache/cocoon/bean CocoonWrapper.java
Date Tue, 09 Sep 2003 19:03:44 GMT
joerg       2003/09/09 12:03:44

  Modified:    src/blocks/scratchpad/java/org/apache/cocoon/ant
                        CocoonTask.java
               src/java/org/apache/cocoon Cocoon.java
               .        status.xml
               src/java/org/apache/cocoon/servlet CocoonServlet.java
               src/java/org/apache/cocoon/bean CocoonWrapper.java
  Log:
  Replaced the deprecated LogkitManager stuff with its LoggerManager counterpart. This is
Cocoon internal and should not affect components as long as you don't use LogKitManageable
interface.
  
  Revision  Changes    Path
  1.2       +40 -35    cocoon-2.1/src/blocks/scratchpad/java/org/apache/cocoon/ant/CocoonTask.java
  
  Index: CocoonTask.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/scratchpad/java/org/apache/cocoon/ant/CocoonTask.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- CocoonTask.java	4 Sep 2003 12:42:41 -0000	1.1
  +++ CocoonTask.java	9 Sep 2003 19:03:44 -0000	1.2
  @@ -58,26 +58,32 @@
   import java.util.Set;
   import java.util.StringTokenizer;
   
  +import org.apache.avalon.excalibur.logger.LogKitLoggerManager;
  +
   import org.apache.avalon.framework.configuration.Configurable;
   import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.avalon.framework.configuration.ConfigurationException;
   import org.apache.avalon.framework.configuration.DefaultConfiguration;
   import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
  +
   import org.apache.avalon.framework.context.Context;
   import org.apache.avalon.framework.context.ContextException;
   import org.apache.avalon.framework.context.Contextualizable;
   import org.apache.avalon.framework.context.DefaultContext;
  +
   import org.apache.avalon.framework.logger.AbstractLogEnabled;
   import org.apache.avalon.framework.logger.ConsoleLogger;
   import org.apache.avalon.framework.logger.LogKitLogger;
  -
  -import org.apache.avalon.excalibur.logger.DefaultLogKitManager;
  +import org.apache.avalon.framework.logger.Logger;
   
   import org.apache.cocoon.Cocoon;
   import org.apache.cocoon.Constants;
   import org.apache.cocoon.environment.commandline.CommandLineContext;
   import org.apache.cocoon.util.IOUtils;
   
  +import org.apache.log.Hierarchy;
  +import org.apache.log.Priority;
  +
   import org.apache.tools.ant.AntClassLoader;
   import org.apache.tools.ant.BuildException;
   import org.apache.tools.ant.Project;
  @@ -324,7 +330,7 @@
       /**
        *   Execute the ant task launching Cocoon
        *
  -     * @exception  BuildException  thrown iff Cocoon processing fails
  +     * @exception  BuildException  thrown if Cocoon processing fails
        */
       public void execute() throws BuildException {
   
  @@ -443,7 +449,7 @@
       /**
        *   Gets the contextDirFile attribute of the CocoonTask object.
        *   Try to locate a file name relative to Cocoon's context directory.
  -     *   Check ${contextDir}/WEB-INF, ${contextDir}/ locations iff
  +     *   Check ${contextDir}/WEB-INF, ${contextDir}/ locations if
        *   there is a file named name.
        *
        * @param  contextDir  Cocoon's context directory
  @@ -477,9 +483,9 @@
        *
        * @param  dir                 a <code>String</code> with a directory name
        * @param  type                a <code>String</code> describing the type
of directory
  -     * @param  create              true iff directory should be created
  +     * @param  create              true if directory should be created
        * @return                     a <code>File</code> value
  -     * @exception  BuildException  throw iff checks fails
  +     * @exception  BuildException  throw if checks fails
        */
       protected File getDir(String dir, boolean create, String type) throws BuildException
{
   
  @@ -508,7 +514,7 @@
       /**
        *   Check if all parameters for running Cocoon are set properly
        *
  -     * @exception  BuildException  is thrown iff at least one parameter is invalid
  +     * @exception  BuildException  is thrown if at least one parameter is invalid
        */
       protected void checkValidity() throws BuildException {
           if (destDir == null) {
  @@ -569,8 +575,8 @@
       public static class CocoonFactory extends AbstractLogEnabled
                implements Contextualizable, Configurable {
   
  -        private DefaultLogKitManager logKitManager;
  -        private org.apache.log.Logger logger;
  +        private LogKitLoggerManager logKitLoggerManager;
  +        private Logger logger;
           private DefaultContext ctx;
           private ClassLoader classLoader;
   
  @@ -596,7 +602,7 @@
            * </ul>
            *
            * @param  context               parent context
  -         * @exception  ContextException  thrown iff parent context fails to provide
  +         * @exception  ContextException  thrown if parent context fails to provide
            *   mandadory context entries
            */
           public void contextualize(Context context) throws ContextException {
  @@ -620,7 +626,7 @@
            *   Configure the Cocoon factory
            *
            * @param  configuration               Cocoon factory configuration
  -         * @exception  ConfigurationException  thrown iff configuration fails
  +         * @exception  ConfigurationException  thrown if configuration fails
            */
           public void configure(Configuration configuration) throws ConfigurationException
{
               Configuration child;
  @@ -634,11 +640,11 @@
                   logLevel = "WARN";
               }
   
  -            // configure the logKitManager, either by using a logkit.xconf file,
  -            // or by a logger
  -            final org.apache.log.Priority priority = org.apache.log.Priority.getPriorityForName(logLevel);
  -            org.apache.log.Hierarchy.getDefaultHierarchy().setDefaultPriority(priority);
  -            logger = org.apache.log.Hierarchy.getDefaultHierarchy().getLoggerFor("");
  +            // configure the logKitManager,
  +            // either by using a logkit.xconf file or by a logger
  +            final Priority priority = Priority.getPriorityForName(logLevel);
  +            Hierarchy.getDefaultHierarchy().setDefaultPriority(priority);
  +            this.logger = new LogKitLogger(Hierarchy.getDefaultHierarchy().getLoggerFor(""));
   
               child = configuration.getChild("logKit", false);
               if (child != null) {
  @@ -649,26 +655,25 @@
                       try {
                           final DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
                           final Configuration logKitConf = builder.buildFromFile(logKit);
  -                        logKitManager = new DefaultLogKitManager(org.apache.log.Hierarchy.getDefaultHierarchy());
  +                        this.logKitLoggerManager = new LogKitLoggerManager(Hierarchy.getDefaultHierarchy());
   
                           final DefaultContext subcontext = new DefaultContext(this.ctx);
                           File contextDir = (File) this.ctx.get("context-root");
                           subcontext.put("context-root", contextDir);
  -                        logKitManager.contextualize(subcontext);
  -                        logKitManager.configure(logKitConf);
  -                        logger = logKitManager.getLogger(logKitLogCategory);
  +                        this.logKitLoggerManager.contextualize(subcontext);
  +                        this.logKitLoggerManager.configure(logKitConf);
  +                        logger = this.logKitLoggerManager.getLoggerForCategory(logKitLogCategory);
                       } catch (Exception e) {
                           getLogger().error("Cannot initialize log-kit-manager from logkit-xconf
" + String.valueOf(logKit));
  -
  -                        // clean logKitManager, try init it without the logkit-xconf
  -                        logKitManager = null;
  +                        // clean logKitLoggerManager, try init it without the logkit-xconf
  +                        this.logKitLoggerManager = null;
                       }
                   }
               }
   
  -            if (logKitManager == null) {
  -                logKitManager = new DefaultLogKitManager(org.apache.log.Hierarchy.getDefaultHierarchy());
  -                logKitManager.setLogger(logger);
  +            if (this.logKitLoggerManager == null) {
  +                this.logKitLoggerManager = new LogKitLoggerManager(Hierarchy.getDefaultHierarchy());
  +                this.logKitLoggerManager.enableLogging(logger);
               }
           }
   
  @@ -677,15 +682,15 @@
            * create a new Cocoon instance
            *
            * @return                             Cocoon the Cocoon instance
  -         * @exception  ContextException        thrown iff configuring of Cocoon instance
fails
  -         * @exception  ConfigurationException  thrown iff contextualizing of Cocoon instance
fails
  -         * @exception  Exception               thrown iff initializing of Cocoon instance
fails
  +         * @exception  ContextException        thrown if configuring of Cocoon instance
fails
  +         * @exception  ConfigurationException  thrown if contextualizing of Cocoon instance
fails
  +         * @exception  Exception               thrown if initializing of Cocoon instance
fails
            */
           public Cocoon createCocoon() throws Exception, ContextException, ConfigurationException
{
               Cocoon cocoon = new Cocoon();
  -            cocoon.enableLogging(new LogKitLogger(logger));
  +            cocoon.enableLogging(logger);
               cocoon.contextualize(this.ctx);
  -            cocoon.setLogKitManager(logKitManager);
  +            cocoon.setLoggerManager(logKitLoggerManager);
               cocoon.initialize();
               return cocoon;
           }
  @@ -693,7 +698,7 @@
   
           /**
            *  Dispose a cocoon instance.
  -         *  Don't forget to invoke this method iff you have retrieved a Cocoon
  +         *  Don't forget to invoke this method if you have retrieved a Cocoon
            *  instance via <code>createCocoon()</code>.
            *
            * @param  cocoon  the Cocoon instance
  @@ -712,12 +717,12 @@
            * @param  cocoon         Cocoon instance
            * @param  configuration  of the CocoonProcessorDelegate
            * @return                CocoonProcessorDelegate instance
  -         * @exception  Exception  thrown iff contextualizing, configuring, or creating
  +         * @exception  Exception  thrown if contextualizing, configuring, or creating
            *   of CocoonProcessorDelegate instance fails.
            */
           public CocoonProcessorDelegate createCocoonProcessorDelegate(Cocoon cocoon, Configuration
configuration) throws Exception {
               CocoonProcessorDelegate cpd = new CocoonProcessorDelegate(cocoon);
  -            cpd.enableLogging(new LogKitLogger(logger));
  +            cpd.enableLogging(logger);
               cpd.contextualize(this.ctx);
               cpd.configure(configuration);
               cpd.initialize();
  
  
  
  1.15      +16 -13    cocoon-2.1/src/java/org/apache/cocoon/Cocoon.java
  
  Index: Cocoon.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/Cocoon.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- Cocoon.java	4 Sep 2003 19:41:58 -0000	1.14
  +++ Cocoon.java	9 Sep 2003 19:03:44 -0000	1.15
  @@ -61,8 +61,8 @@
   
   import org.apache.avalon.excalibur.component.DefaultRoleManager;
   import org.apache.avalon.excalibur.component.ExcaliburComponentManager;
  -import org.apache.avalon.excalibur.logger.LogKitManageable;
  -import org.apache.avalon.excalibur.logger.LogKitManager;
  +import org.apache.avalon.excalibur.logger.LoggerManager;
  +
   import org.apache.avalon.framework.activity.Disposable;
   import org.apache.avalon.framework.activity.Initializable;
   import org.apache.avalon.framework.component.Component;
  @@ -70,6 +70,7 @@
   import org.apache.avalon.framework.component.Composable;
   import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.avalon.framework.configuration.ConfigurationException;
  +import org.apache.avalon.framework.configuration.DefaultConfiguration;
   import org.apache.avalon.framework.configuration.SAXConfigurationHandler;
   import org.apache.avalon.framework.container.ContainerUtil;
   import org.apache.avalon.framework.context.Context;
  @@ -79,6 +80,7 @@
   import org.apache.avalon.framework.logger.AbstractLogEnabled;
   import org.apache.avalon.framework.parameters.Parameters;
   import org.apache.avalon.framework.thread.ThreadSafe;
  +
   import org.apache.cocoon.components.CocoonComponentManager;
   import org.apache.cocoon.components.ComponentContext;
   import org.apache.cocoon.components.EnvironmentStack;
  @@ -92,6 +94,7 @@
   import org.apache.cocoon.environment.Request;
   import org.apache.cocoon.environment.Session;
   import org.apache.cocoon.util.ClassUtils;
  +
   import org.apache.excalibur.event.Queue;
   import org.apache.excalibur.event.command.CommandManager;
   import org.apache.excalibur.event.command.TPCThreadManager;
  @@ -102,6 +105,7 @@
   import org.apache.excalibur.source.impl.URLSource;
   import org.apache.excalibur.xml.impl.XercesParser;
   import org.apache.excalibur.xml.sax.SAXParser;
  +
   import org.xml.sax.InputSource;
   
   /**
  @@ -122,7 +126,6 @@
                      Processor,
                      Contextualizable,
                      Composable,
  -                   LogKitManageable,
                      InstrumentManageable {
   
       private ThreadManager threads;
  @@ -138,8 +141,8 @@
       /** The configuration tree */
       private Configuration configuration;
   
  -    /** The logkit manager */
  -    private LogKitManager logKitManager;
  +    /** The logger manager */
  +    private LoggerManager loggerManager;
   
       /** The instrument manager */
       private InstrumentManager instrumentManager;
  @@ -241,13 +244,13 @@
       }
   
       /**
  -     * The <code>setLogKitManager</code> method will get a <code>LogKitManager</code>
  +     * The <code>setLoggerManager</code> method will get a <code>LoggerManager</code>
        * for further use.
        *
  -     * @param logKitManager a <code>LogKitManager</code> value
  +     * @param loggerManager a <code>LoggerManager</code> value
        */
  -    public void setLogKitManager(LogKitManager logKitManager) {
  -        this.logKitManager = logKitManager;
  +    public void setLoggerManager(LoggerManager loggerManager) {
  +        this.loggerManager = loggerManager;
       }
   
       /**
  @@ -306,10 +309,10 @@
           ExcaliburComponentManager startupManager = new ExcaliburComponentManager((ClassLoader)this.context.get(Constants.CONTEXT_CLASS_LOADER));
           ContainerUtil.enableLogging(startupManager, getLogger().getChildLogger("startup"));
           ContainerUtil.contextualize(startupManager, this.context);
  -        startupManager.setLogKitManager(this.logKitManager);
  +        startupManager.setLoggerManager(this.loggerManager);
   
           try {
  -            startupManager.addComponent(SAXParser.ROLE, ClassUtils.loadClass(parser), new
org.apache.avalon.framework.configuration.DefaultConfiguration("", "empty"));
  +            startupManager.addComponent(SAXParser.ROLE, ClassUtils.loadClass(parser), new
DefaultConfiguration("", "empty"));
           } catch (Exception e) {
               throw new ConfigurationException("Could not load parser " + parser, e);
           }
  @@ -443,7 +446,7 @@
           }
   
           this.componentManager.setRoleManager(drm);
  -        this.componentManager.setLogKitManager(this.logKitManager);
  +        this.componentManager.setLoggerManager(this.loggerManager);
   
           if (getLogger().isDebugEnabled()) {
               getLogger().debug("Setting up components...");
  
  
  
  1.146     +6 -1      cocoon-2.1/status.xml
  
  Index: status.xml
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/status.xml,v
  retrieving revision 1.145
  retrieving revision 1.146
  diff -u -r1.145 -r1.146
  --- status.xml	9 Sep 2003 09:18:53 -0000	1.145
  +++ status.xml	9 Sep 2003 19:03:44 -0000	1.146
  @@ -190,6 +190,11 @@
     <changes>
   
    <release version="@version@" date="@date@">
  +   <action dev="JH" type="update" fixes-bug="21730">
  +     Replaced the deprecated LogkitManager stuff with its LoggerManager
  +     counterpart. This is Cocoon internal and should not affect components as
  +     long as you don't use LogKitManageable interface.
  +   </action>
      <action dev="BRD" type="fix">
        Woody binding framework: fixed a problem with the deletion of rows by the
        repeater binding, whereby not all deleted rows where removed from the
  
  
  
  1.14      +27 -22    cocoon-2.1/src/java/org/apache/cocoon/servlet/CocoonServlet.java
  
  Index: CocoonServlet.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/servlet/CocoonServlet.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- CocoonServlet.java	1 Aug 2003 10:28:38 -0000	1.13
  +++ CocoonServlet.java	9 Sep 2003 19:03:44 -0000	1.14
  @@ -78,8 +78,9 @@
   import javax.servlet.http.HttpServletRequest;
   import javax.servlet.http.HttpServletResponse;
   
  -import org.apache.avalon.excalibur.logger.DefaultLogKitManager;
  -import org.apache.avalon.excalibur.logger.LogKitManager;
  +import org.apache.avalon.excalibur.logger.LogKitLoggerManager;
  +import org.apache.avalon.excalibur.logger.LoggerManager;
  +
   import org.apache.avalon.framework.activity.Disposable;
   import org.apache.avalon.framework.activity.Initializable;
   import org.apache.avalon.framework.component.ComponentManager;
  @@ -89,6 +90,8 @@
   import org.apache.avalon.framework.context.DefaultContext;
   import org.apache.avalon.framework.logger.LogEnabled;
   import org.apache.avalon.framework.logger.LogKitLogger;
  +import org.apache.avalon.framework.logger.Logger;
  +
   import org.apache.cocoon.Cocoon;
   import org.apache.cocoon.ConnectionResetException;
   import org.apache.cocoon.Constants;
  @@ -105,13 +108,15 @@
   import org.apache.cocoon.util.IOUtils;
   import org.apache.cocoon.util.StringUtils;
   import org.apache.cocoon.util.log.CocoonLogFormatter;
  +
   import org.apache.excalibur.instrument.InstrumentManager;
   import org.apache.excalibur.instrument.manager.DefaultInstrumentManager;
  +
   import org.apache.log.ContextMap;
   import org.apache.log.Hierarchy;
  -import org.apache.log.Logger;
   import org.apache.log.Priority;
   import org.apache.log.output.ServletOutputLogTarget;
  +import org.apache.log.util.DefaultErrorHandler;
   
   /**
    * This is the entry point for Cocoon execution as an HTTP Servlet.
  @@ -137,7 +142,7 @@
       static final float HOUR   = 60 * MINUTE;
   
       protected Logger log;
  -    protected LogKitManager logKitManager;
  +    protected LoggerManager loggerManager;
   
       /**
        * The time the cocoon instance was created
  @@ -800,9 +805,9 @@
           servTarget.setFormatter(formatter);
           Hierarchy.getDefaultHierarchy().setDefaultLogTarget(servTarget);
           Hierarchy.getDefaultHierarchy().setDefaultPriority(logPriority);
  -        final Logger logger = Hierarchy.getDefaultHierarchy().getLoggerFor("");
  -        final DefaultLogKitManager logKitManager = new DefaultLogKitManager(Hierarchy.getDefaultHierarchy());
  -        logKitManager.setLogger(logger);
  +        final Logger logger = new LogKitLogger(Hierarchy.getDefaultHierarchy().getLoggerFor(""));
  +        final LogKitLoggerManager logKitLoggerManager = new LogKitLoggerManager(Hierarchy.getDefaultHierarchy());
  +        logKitLoggerManager.enableLogging(logger);
           final DefaultContext subcontext = new DefaultContext(this.appContext);
           subcontext.put("servlet-context", this.servletContext);
           if (this.servletContextPath == null) {
  @@ -817,8 +822,8 @@
           }
   
           try {
  -            logKitManager.contextualize(subcontext);
  -            this.logKitManager = logKitManager;
  +            logKitLoggerManager.contextualize(subcontext);
  +            this.loggerManager = logKitLoggerManager;
   
               //Configure the logkit management
               String logkitConfig = getInitParameter("logkit-config", "/WEB-INF/logkit.xconf");
  @@ -834,15 +839,15 @@
               }
               final DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
               final Configuration conf = builder.build(is);
  -            logKitManager.configure(conf);
  +            logKitLoggerManager.configure(conf);
           } catch (Exception e) {
  -            Hierarchy.getDefaultHierarchy().log("Could not set up Cocoon Logger, will use
screen instead", e);
  +            new DefaultErrorHandler().error("Could not set up Cocoon Logger, will use screen
instead", e, null);
           }
   
           if (accesslogger != null) {
  -            this.log = logKitManager.getLogger(accesslogger);
  +            this.log = logKitLoggerManager.getLoggerForCategory(accesslogger);
           } else {
  -            this.log = logKitManager.getLogger("cocoon");
  +            this.log = logKitLoggerManager.getLoggerForCategory("cocoon");
           }
   
       }
  @@ -1271,7 +1276,7 @@
                                     (HttpContext) this.appContext.get(Constants.CONTEXT_ENVIRONMENT_CONTEXT),
                                     this.containerEncoding,
                                     formEncoding);
  -        env.enableLogging(new LogKitLogger(this.log));
  +        env.enableLogging(this.log);
           return env;
       }
   
  @@ -1294,7 +1299,7 @@
                   parentComponentManager = (ComponentManager) pcmc.newInstance(new Object[]{parentComponentManagerInitParam});
   
                   if (parentComponentManager instanceof LogEnabled) {
  -                    ((LogEnabled) parentComponentManager).enableLogging(new LogKitLogger(log));
  +                    ((LogEnabled) parentComponentManager).enableLogging(this.log);
                   }
                   if (parentComponentManager instanceof Contextualizable) {
                       ((Contextualizable) parentComponentManager).contextualize(this.appContext);
  @@ -1339,13 +1344,13 @@
               Cocoon c = (Cocoon) ClassUtils.newInstance("org.apache.cocoon.Cocoon");
               final String rootlogger = getInitParameter("cocoon-logger");
               if (rootlogger != null) {
  -                c.enableLogging(new LogKitLogger(this.logKitManager.getLogger(rootlogger)));
  +                c.enableLogging(this.loggerManager.getLoggerForCategory(rootlogger));
               } else {
  -                c.enableLogging(new LogKitLogger(log));
  +                c.enableLogging(log);
               }
               c.contextualize(this.appContext);
               c.compose(getParentComponentManager());
  -            c.setLogKitManager(this.logKitManager);
  +            c.setLoggerManager(this.loggerManager);
               if (this.enableInstrumentation) {
                   c.setInstrumentManager(getInstrumentManager());
               }
  @@ -1393,12 +1398,12 @@
           final Configuration conf = builder.build(is);
   
           // Get the logger for the instrument manager
  -        Logger imLogger =
  -            this.logKitManager.getLogger(conf.getAttribute( "logger", "core.instrument"
));
  +        final String imLoggerCategory = conf.getAttribute("logger", "core.instrument");
  +        Logger imLogger = this.loggerManager.getLoggerForCategory(imLoggerCategory);
   
           // Set up the Instrument Manager
           DefaultInstrumentManager instrumentManager = new DefaultInstrumentManager();
  -        instrumentManager.enableLogging(new LogKitLogger(imLogger));
  +        instrumentManager.enableLogging(imLogger);
           instrumentManager.configure(conf);
           instrumentManager.initialize();
   
  
  
  
  1.6       +62 -90    cocoon-2.1/src/java/org/apache/cocoon/bean/CocoonWrapper.java
  
  Index: CocoonWrapper.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/bean/CocoonWrapper.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- CocoonWrapper.java	4 Sep 2003 11:38:44 -0000	1.5
  +++ CocoonWrapper.java	9 Sep 2003 19:03:44 -0000	1.6
  @@ -50,41 +50,43 @@
   */
   package org.apache.cocoon.bean;
   
  -import org.apache.cocoon.util.NetUtils;
  -import org.apache.cocoon.util.IOUtils;
  -import org.apache.cocoon.util.ClassUtils;
  -import org.apache.cocoon.Constants;
  -import org.apache.cocoon.Cocoon;
  -import org.apache.cocoon.ProcessingException;
  -import org.apache.cocoon.environment.Environment;
  -import org.apache.cocoon.environment.commandline.CommandLineContext;
  -import org.apache.cocoon.environment.commandline.LinkSamplingEnvironment;
  -import org.apache.cocoon.environment.commandline.FileSavingEnvironment;
  -
  -import org.apache.avalon.excalibur.logger.DefaultLogKitManager;
  -import org.apache.avalon.excalibur.component.ExcaliburComponentManager;
  -import org.apache.avalon.framework.container.ContainerUtil;
  -import org.apache.avalon.framework.context.DefaultContext;
  -import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
  -import org.apache.avalon.framework.configuration.Configuration;
  -import org.apache.avalon.framework.logger.LogKitLogger;
  -import org.apache.log.Priority;
  -import org.apache.log.Hierarchy;
  -import org.apache.log.Logger;
  -
   import java.io.File;
  -import java.io.IOException;
  -import java.io.FileNotFoundException;
   import java.io.FileInputStream;
  +import java.io.FileNotFoundException;
  +import java.io.IOException;
   import java.io.OutputStream;
  -import java.util.Map;
  -import java.util.HashMap;
  -import java.util.TreeMap;
   import java.util.ArrayList;
  +import java.util.Arrays;
   import java.util.Collection;
  +import java.util.HashMap;
   import java.util.Iterator;
  -import java.util.Arrays;
   import java.util.List;
  +import java.util.Map;
  +import java.util.TreeMap;
  +
  +import org.apache.avalon.excalibur.component.ExcaliburComponentManager;
  +import org.apache.avalon.excalibur.logger.LogKitLoggerManager;
  +
  +import org.apache.avalon.framework.configuration.Configuration;
  +import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
  +import org.apache.avalon.framework.container.ContainerUtil;
  +import org.apache.avalon.framework.context.DefaultContext;
  +import org.apache.avalon.framework.logger.LogKitLogger;
  +import org.apache.avalon.framework.logger.Logger;
  +
  +import org.apache.cocoon.Cocoon;
  +import org.apache.cocoon.Constants;
  +import org.apache.cocoon.ProcessingException;
  +import org.apache.cocoon.environment.Environment;
  +import org.apache.cocoon.environment.commandline.CommandLineContext;
  +import org.apache.cocoon.environment.commandline.FileSavingEnvironment;
  +import org.apache.cocoon.environment.commandline.LinkSamplingEnvironment;
  +import org.apache.cocoon.util.ClassUtils;
  +import org.apache.cocoon.util.IOUtils;
  +import org.apache.cocoon.util.NetUtils;
  +
  +import org.apache.log.Hierarchy;
  +import org.apache.log.Priority;
   
   /**
    * The Cocoon Wrapper simplifies usage of the Cocoon object. Allows to create, 
  @@ -145,53 +147,44 @@
                   Constants.CONTEXT_CLASS_LOADER,
                   CocoonWrapper.class.getClassLoader());
               cliContext = new CommandLineContext(contextDir);
  -            cliContext.enableLogging(new LogKitLogger(log));
  +            cliContext.enableLogging(log);
               appContext.put(Constants.CONTEXT_ENVIRONMENT_CONTEXT, cliContext);
  -            DefaultLogKitManager logKitManager = null;
  -            if (logKit != null) {
  +            LogKitLoggerManager logKitLoggerManager =
  +                    new LogKitLoggerManager(Hierarchy.getDefaultHierarchy());
  +            logKitLoggerManager.enableLogging(log);
  +
  +            if (this.logKit != null) {
                   final FileInputStream fis = new FileInputStream(logKit);
                   final DefaultConfigurationBuilder builder =
                       new DefaultConfigurationBuilder();
                   final Configuration logKitConf = builder.build(fis);
  -                logKitManager =
  -                    new DefaultLogKitManager(Hierarchy.getDefaultHierarchy());
  -                logKitManager.setLogger(log);
  -                final DefaultContext subcontext =
  -                    new DefaultContext(appContext);
  +                final DefaultContext subcontext = new DefaultContext(appContext);
                   subcontext.put("context-root", contextDir);
  -                logKitManager.contextualize(subcontext);
  -                logKitManager.configure(logKitConf);
  +                logKitLoggerManager.contextualize(subcontext);
  +                logKitLoggerManager.configure(logKitConf);
                   if (logger != null) {
  -                    log = logKitManager.getLogger(logger);
  +                    log = logKitLoggerManager.getLoggerForCategory(logger);
                   } else {
  -                    log = logKitManager.getLogger("cocoon");
  +                    log = logKitLoggerManager.getLoggerForCategory("cocoon");
                   }
  -            } else {
  -                logKitManager =
  -                    new DefaultLogKitManager(Hierarchy.getDefaultHierarchy());
  -                logKitManager.setLogger(log);
               }
  -            appContext.put(
  -                Constants.CONTEXT_CLASSPATH,
  -                getClassPath(contextDir));
  +
  +            appContext.put(Constants.CONTEXT_CLASSPATH, getClassPath(contextDir));
               appContext.put(Constants.CONTEXT_WORK_DIR, work);
  -            appContext.put(
  -                Constants.CONTEXT_UPLOAD_DIR,
  -                contextDir + "upload-dir");
  -            File cacheDir =
  -                getDir(workDir + File.separator + "cache-dir", "cache");
  +            appContext.put(Constants.CONTEXT_UPLOAD_DIR, contextDir + "upload-dir");
  +            File cacheDir = getDir(workDir + File.separator + "cache-dir", "cache");
               appContext.put(Constants.CONTEXT_CACHE_DIR, cacheDir);
               appContext.put(Constants.CONTEXT_CONFIG_URL, conf.toURL());
   
               loadClasses(classList);
   
               cocoon = new Cocoon();
  -            ContainerUtil.enableLogging(cocoon, new LogKitLogger(log));
  +            ContainerUtil.enableLogging(cocoon, log);
               ContainerUtil.contextualize(cocoon, appContext);
  -            cocoon.setLogKitManager(logKitManager);
  +            cocoon.setLoggerManager(logKitLoggerManager);
               ContainerUtil.initialize(cocoon);
   
  -            } catch (Exception e) {
  +        } catch (Exception e) {
               log.fatalError("Exception caught", e);
               throw e;
           }
  @@ -338,7 +331,7 @@
       public void setLogLevel(String logLevel) {
           final Priority priority = Priority.getPriorityForName(logLevel);
           Hierarchy.getDefaultHierarchy().setDefaultPriority(priority);
  -        CocoonWrapper.log = Hierarchy.getDefaultHierarchy().getLoggerFor("");
  +        CocoonWrapper.log = new LogKitLogger(Hierarchy.getDefaultHierarchy().getLoggerFor(""));
       }
   
       /**
  @@ -466,8 +459,8 @@
       protected void processXSP(String uri) throws Exception {
           String markupLanguage = "xsp";
           String programmingLanguage = "java";
  -        Environment env = new LinkSamplingEnvironment("/", context, attributes, null, cliContext,
  -                                                      new LogKitLogger(log));
  +        Environment env = new LinkSamplingEnvironment("/", context, attributes,
  +                                                      null, cliContext, log);
           cocoon.precompile(uri, env, markupLanguage, programmingLanguage);
       }
   
  @@ -480,8 +473,8 @@
       protected void processXMAP(String uri) throws Exception {
           String markupLanguage = "sitemap";
           String programmingLanguage = "java";
  -        Environment env = new LinkSamplingEnvironment("/", context, attributes, null, cliContext,
  -                                                      new LogKitLogger(log));
  +        Environment env = new LinkSamplingEnvironment("/", context, attributes,
  +                                                      null, cliContext, log);
           cocoon.precompile(uri, env, markupLanguage, programmingLanguage);
       }
   
  @@ -501,13 +494,8 @@
           parameters.put("accept", accept);
   
           LinkSamplingEnvironment env =
  -            new LinkSamplingEnvironment(
  -                deparameterizedURI,
  -                context,
  -                attributes,
  -                parameters,
  -                cliContext,
  -                new LogKitLogger(log));
  +            new LinkSamplingEnvironment(deparameterizedURI, context, attributes,
  +                                        parameters, cliContext, log);
           processLenient(env);
           return env.getLinks();
       }
  @@ -535,17 +523,9 @@
           parameters.put("accept", accept);
   
           FileSavingEnvironment env =
  -            new FileSavingEnvironment(
  -                deparameterizedURI,
  -                lastModified,
  -                context,
  -                attributes,
  -                parameters,
  -                links,
  -                gatheredLinks,
  -                cliContext,
  -                stream,
  -                new LogKitLogger(log));
  +            new FileSavingEnvironment(deparameterizedURI, lastModified, context,
  +                                      attributes, parameters, links,
  +                                      gatheredLinks, cliContext, stream, log);
   
           // Here Cocoon can throw an exception if there are errors in processing the page
           cocoon.process(env);
  @@ -583,16 +563,9 @@
           parameters.put("accept", accept);
   
           FileSavingEnvironment env =
  -            new FileSavingEnvironment(
  -                deparameterizedURI,
  -                context,
  -                attributes,
  -                parameters,
  -                empty,
  -                null,
  -                cliContext,
  -                new NullOutputStream(),
  -                new LogKitLogger(log));
  +            new FileSavingEnvironment(deparameterizedURI, context, attributes,
  +                                      parameters, empty, null, cliContext,
  +                                      new NullOutputStream(), log);
           processLenient(env);
           return env.getContentType();
       }
  @@ -610,7 +583,6 @@
           } catch (ProcessingException pe) {
               return false;
           }
  -
           return true;
       }
   
  
  
  

Mime
View raw message