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/servlet CocoonServlet.java
Date Tue, 11 May 2004 17:20:41 GMT
joerg       2004/05/11 10:20:41

  Modified:    .        status.xml
               src/java/org/apache/cocoon/servlet CocoonServlet.java
  Log:
  Extended CocoonServlet to allow any org.apache.avalon.excalibur.logger.LoggerManager to
be used (bug 28860, thanks to Ralph Goers).
  
  Revision  Changes    Path
  1.324     +7 -2      cocoon-2.1/status.xml
  
  Index: status.xml
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/status.xml,v
  retrieving revision 1.323
  retrieving revision 1.324
  diff -u -r1.323 -r1.324
  --- status.xml	11 May 2004 12:57:44 -0000	1.323
  +++ status.xml	11 May 2004 17:20:40 -0000	1.324
  @@ -211,7 +211,12 @@
     <changes>
   
    <release version="@version@" date="@date@">
  -   <action dev="MPO" type="update" >
  +   <action dev="JH" type="add" fixes-bug="28860" due-to="Ralph Goers" due-to-email="Ralph_Goers@dslextreme.com">
  +     Extended CocoonServlet to allow any
  +     <link href="http://avalon.apache.org/excalibur/api/org/apache/avalon/excalibur/logger/LoggerManager.html">org.apache.avalon.excalibur.logger.LoggerManager</link>
  +     to be used.
  +   </action>
  +   <action dev="MPO" type="update">
        Deprectated getWidget from the Widget interface in cforms.
        People should consider using getChild(id) or lookupWidget(path) instead.
        On the level of the flowscript 'Form' API a semantical distinct getWidget()
  
  
  
  1.28      +33 -13    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.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- CocoonServlet.java	4 May 2004 14:11:16 -0000	1.27
  +++ CocoonServlet.java	11 May 2004 17:20:40 -0000	1.28
  @@ -51,6 +51,7 @@
   import org.apache.avalon.framework.component.ComponentManager;
   import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
  +import org.apache.avalon.framework.configuration.Configurable;
   import org.apache.avalon.framework.container.ContainerUtil;
   import org.apache.avalon.framework.context.Contextualizable;
   import org.apache.avalon.framework.context.DefaultContext;
  @@ -779,14 +780,15 @@
           defaultHierarchy.setDefaultLogTarget(servTarget);
           defaultHierarchy.setDefaultPriority(logPriority);
           final Logger logger = new LogKitLogger(Hierarchy.getDefaultHierarchy().getLoggerFor(""));
  -                
  +        final String loggerManagerClass =
  +            this.getInitParameter("logger-class", LogKitLoggerManager.class.getName());
  +
           // the log4j support requires currently that the log4j system is already configured
elsewhere
  -        final boolean isLog4JLogger = "log4j".equals(this.getInitParameter("logger-type",
"logkit"));
  -        
  -        final LoggerManager logKitLoggerManager = (isLog4JLogger ? (LoggerManager)new Log4JLoggerManager()
  -                                                                 : new LogKitLoggerManager(defaultHierarchy));
  -        ContainerUtil.enableLogging(logKitLoggerManager, logger);
  -        
  +
  +        final LoggerManager loggerManager =
  +                newLoggerManager(loggerManagerClass, defaultHierarchy);
  +        ContainerUtil.enableLogging(loggerManager, logger);
  +
           final DefaultContext subcontext = new DefaultContext(this.appContext);
           subcontext.put("servlet-context", this.servletContext);
           if (this.servletContextPath == null) {
  @@ -801,13 +803,13 @@
           }
   
           try {
  -            ContainerUtil.contextualize(logKitLoggerManager, subcontext);
  -            this.loggerManager = logKitLoggerManager;
  +            ContainerUtil.contextualize(loggerManager, subcontext);
  +            this.loggerManager = loggerManager;
   
  -            if ( !isLog4JLogger ) {
  +            if (loggerManager instanceof Configurable) {
                   //Configure the logkit management
                   String logkitConfig = getInitParameter("logkit-config", "/WEB-INF/logkit.xconf");
  -    
  +
                   // test if this is a qualified url
                   InputStream is = null;
                   if ( logkitConfig.indexOf(':') == -1) {
  @@ -819,13 +821,31 @@
                   }
                   final DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
                   final Configuration conf = builder.build(is);
  -                ContainerUtil.configure(logKitLoggerManager, conf);
  +                ContainerUtil.configure(loggerManager, conf);
               }
  +            ContainerUtil.initialize(loggerManager);
  +
           } catch (Exception e) {
               errorHandler.error("Could not set up Cocoon Logger, will use screen instead",
e, null);
           }
   
           this.log = this.loggerManager.getLoggerForCategory(accesslogger);
  +    }
  +
  +    private LoggerManager newLoggerManager(String loggerManagerClass, Hierarchy hierarchy)
{
  +        if (loggerManagerClass.equals(LogKitLoggerManager.class.getName())) {
  +            return new LogKitLoggerManager(hierarchy);
  +        } else if (loggerManagerClass.equals(Log4JLoggerManager.class.getName()) ||
  +                   loggerManagerClass.equalsIgnoreCase("LOG4J")) {
  +            return new Log4JLoggerManager();
  +        } else {
  +            try {
  +                Class clazz = Class.forName(loggerManagerClass);
  +                return (LoggerManager)clazz.newInstance();
  +            } catch (Exception e) {
  +                return new LogKitLoggerManager(hierarchy);
  +            }
  +        }
       }
   
       /**
  
  
  

Mime
View raw message