dain        2004/02/12 23:22:22

  Modified:    modules/deployment/src/java/org/apache/geronimo/deployment
                        Deployer.java
               modules/kernel/src/java/org/apache/geronimo Geronimo.java
               modules/kernel/src/java/org/apache/geronimo/kernel/log
                        GeronimoLogFactory.java
               modules/system/src/java/org/apache/geronimo/system/repository
                        ReadOnlyRepository.java
  Added:       modules/kernel/src/java/org/apache/geronimo/kernel/log
                        BootstrapJdk14Log.java BootstrapLog4jLog.java
                        BootstrapLogFactory.java GeronimoLogging.java
  Log:
  Logging fixes
    * Logging now uses a Bootstrap log factory which selects either the
      geronimo BootstrapLog4jLog or BootstrapJdk14Log based on availability
      of the log4j classes
    * GeronimoLog now keeps instances and delegate log factory in a static
      fields as commons-logging likes to create a factory per classloader
    * Added GeronimoLogging, which is used to install our logging code
    * Changed Geronimo.java and Deployer.java to use the new GeronimpLogging
      initialization code
  
  Revision  Changes    Path
  1.2       +3 -4      
incubator-geronimo/modules/deployment/src/java/org/apache/geronimo/deployment/Deployer.java
  
  Index: Deployer.java
  ===================================================================
  RCS file: 
/home/cvs/incubator-geronimo/modules/deployment/src/java/org/apache/geronimo/deployment/Deployer.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Deployer.java     12 Feb 2004 18:27:39 -0000      1.1
  +++ Deployer.java     13 Feb 2004 07:22:22 -0000      1.2
  @@ -70,14 +70,13 @@
   import org.apache.commons.cli.Options;
   import org.apache.commons.cli.ParseException;
   import org.apache.commons.cli.PosixParser;
  -import org.apache.commons.logging.LogFactory;
   import org.apache.geronimo.gbean.GBeanInfo;
   import org.apache.geronimo.gbean.GBeanInfoFactory;
   import org.apache.geronimo.gbean.GConstructorInfo;
   import org.apache.geronimo.gbean.GOperationInfo;
   import org.apache.geronimo.gbean.GReferenceInfo;
   import org.apache.geronimo.kernel.Kernel;
  -import org.apache.geronimo.kernel.log.GeronimoLogFactory;
  +import org.apache.geronimo.kernel.log.GeronimoLogging;
   import org.apache.geronimo.kernel.config.LocalConfigStore;
   import org.apache.xmlbeans.SchemaTypeLoader;
   import org.apache.xmlbeans.XmlBeans;
  @@ -92,7 +91,7 @@
   public class Deployer {
       static {
           // This MUST be done before the first log is acquired
  -        System.setProperty(LogFactory.FACTORY_PROPERTY, 
GeronimoLogFactory.class.getName());
  +        GeronimoLogging.initialize(GeronimoLogging.ERROR);
       }
   
       public static final URI DEFAULT_CONFIG = 
URI.create("org/apache/geronimo/J2EEDeployer");
  
  
  
  1.9       +3 -5      
incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/Geronimo.java
  
  Index: Geronimo.java
  ===================================================================
  RCS file: 
/home/cvs/incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/Geronimo.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- Geronimo.java     12 Feb 2004 18:23:58 -0000      1.8
  +++ Geronimo.java     13 Feb 2004 07:22:22 -0000      1.9
  @@ -63,10 +63,9 @@
   import java.util.Iterator;
   import java.util.List;
   
  -import org.apache.commons.logging.LogFactory;
   import org.apache.geronimo.kernel.Kernel;
   import org.apache.geronimo.kernel.config.LocalConfigStore;
  -import org.apache.geronimo.kernel.log.GeronimoLogFactory;
  +import org.apache.geronimo.kernel.log.GeronimoLogging;
   
   /**
    * @version $Revision$ $Date$
  @@ -74,7 +73,7 @@
   public class Geronimo {
       static {
           // This MUST be done before the first log is acquired
  -        System.setProperty(LogFactory.FACTORY_PROPERTY, 
GeronimoLogFactory.class.getName());
  +        GeronimoLogging.initialize(GeronimoLogging.INFO);
       }
   
       private Geronimo() {
  @@ -112,7 +111,6 @@
               }
               configs.add(configID);
           }
  -
           final Kernel kernel;
           File storeDir = new File(storeDirName);
           if (storeDir.exists()) {
  
  
  
  1.2       +76 -39    
incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/kernel/log/GeronimoLogFactory.java
  
  Index: GeronimoLogFactory.java
  ===================================================================
  RCS file: 
/home/cvs/incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/kernel/log/GeronimoLogFactory.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- GeronimoLogFactory.java   11 Feb 2004 03:14:11 -0000      1.1
  +++ GeronimoLogFactory.java   13 Feb 2004 07:22:22 -0000      1.2
  @@ -59,81 +59,118 @@
   import java.util.HashSet;
   import java.util.Iterator;
   import java.util.Set;
  +import java.util.Map;
   
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogConfigurationException;
   import org.apache.commons.logging.LogFactory;
  -import org.apache.commons.logging.impl.LogFactoryImpl;
   
   /**
    * @version $Revision$ $Date$
    */
   public class GeronimoLogFactory extends LogFactory {
  -    private LogFactory logFactory = new LogFactoryImpl();
  -    private final HashMap instances = new HashMap();
  +    private final static Object factoryLock = new Object();
  +    // todo this should use weak references
  +    private static final HashMap instancesByClassLoader = new HashMap();
   
  -    public synchronized LogFactory getLogFactory() {
  -        return logFactory;
  +    private static LogFactory logFactory = new BootstrapLogFactory();
  +
  +    public GeronimoLogFactory() {
  +        System.out.println("Created Geronimo log factory");
       }
   
  -    public void setLogFactory(LogFactory logFactory) {
  -        Set logs;
  -        synchronized (this) {
  -            this.logFactory = logFactory;
  -            logs = new HashSet(instances.values());
  +    public LogFactory getLogFactory() {
  +        synchronized (factoryLock) {
  +            return logFactory;
           }
  +    }
  +
  +    public void setLogFactory(LogFactory logFactory) {
  +        // change the log factory
  +        this.logFactory = logFactory;
   
  +        // update all known logs to use instances of the new factory
  +        Set logs = getInstances();
           for (Iterator iterator = logs.iterator(); iterator.hasNext();) {
               GeronimoLog log = (GeronimoLog) iterator.next();
               log.setLog(logFactory.getInstance(log.getName()));
           }
       }
   
  -    public synchronized Set getInstances() {
  -        return new HashSet(instances.values());
  +    public Set getInstances() {
  +        synchronized (factoryLock) {
  +            Set logs = new HashSet();
  +            for (Iterator iterator = 
instancesByClassLoader.values().iterator(); iterator.hasNext();) {
  +                Map instanceMap = ((Map) iterator.next());
  +                logs.addAll(instanceMap.values());
  +
  +            }
  +            return logs;
  +        }
       }
   
  -    public synchronized Log getInstance(Class clazz) throws 
LogConfigurationException {
  -        return getInstance(clazz.getName());
  +    public Log getInstance(Class clazz) throws LogConfigurationException {
  +        synchronized (factoryLock) {
  +            return getInstance(clazz.getName());
  +        }
       }
   
  -    public synchronized Log getInstance(String name) throws 
LogConfigurationException {
  -        ClassLoader oldCL = Thread.currentThread().getContextClassLoader();
  -        try {
  -            
Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
  -            Log instance = (Log) instances.get(name);
  -            if (instance == null) {
  -                instance = new GeronimoLog(name, 
logFactory.getInstance(name));
  -                instances.put(name, instance);
  +    public Log getInstance(String name) throws LogConfigurationException {
  +        synchronized (factoryLock) {
  +            // get the instances for the context classloader
  +            ClassLoader contextClassLoader = 
Thread.currentThread().getContextClassLoader();
  +            Map instances = (Map) 
instancesByClassLoader.get(contextClassLoader);
  +            if(instances == null) {
  +                instances = new HashMap();
  +                instancesByClassLoader.put(contextClassLoader, instances);
               }
  -            return instance;
  -        } finally {
  -            Thread.currentThread().setContextClassLoader(oldCL);
  +
  +            // get the log
  +            Log log = (Log) instances.get(name);
  +            if (log == null) {
  +                log = new GeronimoLog(name, logFactory.getInstance(name));
  +                instances.put(name, log);
  +            }
  +            return log;
           }
       }
   
  -    public synchronized void release() {
  -        for (Iterator iterator = instances.values().iterator(); 
iterator.hasNext();) {
  -            GeronimoLog log = (GeronimoLog) iterator.next();
  -            log.setLog(null);
  +    public void release() {
  +        synchronized (factoryLock) {
  +            for (Iterator maps = instancesByClassLoader.values().iterator(); 
maps.hasNext();) {
  +                Map instances = (Map) maps.next();
  +                for (Iterator logs = instances.values().iterator(); 
logs.hasNext();) {
  +                    GeronimoLog log = (GeronimoLog) logs.next();
  +                    log.setLog(null);
  +
  +                }
  +            }
  +            instancesByClassLoader.clear();
           }
  -        instances.clear();
       }
   
  -    public synchronized Object getAttribute(String name) {
  -        return logFactory.getAttribute(name);
  +    public Object getAttribute(String name) {
  +        synchronized (factoryLock) {
  +            return logFactory.getAttribute(name);
  +        }
       }
   
  -    public synchronized String[] getAttributeNames() {
  -        return logFactory.getAttributeNames();
  +    public String[] getAttributeNames() {
  +        synchronized (factoryLock) {
  +            return logFactory.getAttributeNames();
  +        }
       }
   
  -    public synchronized void removeAttribute(String name) {
  -        logFactory.removeAttribute(name);
  +    public  void removeAttribute(String name) {
  +        synchronized (factoryLock) {
  +            logFactory.removeAttribute(name);
  +        }
       }
   
  -    public synchronized void setAttribute(String name, Object value) {
  -        logFactory.setAttribute(name, value);
  +    public void setAttribute(String name, Object value) {
  +        synchronized (factoryLock) {
  +            logFactory.setAttribute(name, value);
  +        }
       }
   }
   
  
  
  
  1.1                  
incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/kernel/log/BootstrapJdk14Log.java
  
  Index: BootstrapJdk14Log.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Geronimo" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Geronimo", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * ====================================================================
   */
  package org.apache.geronimo.kernel.log;
  
  import java.util.logging.Logger;
  import java.util.logging.Level;
  import java.util.logging.Handler;
  import java.util.logging.ConsoleHandler;
  
  import org.apache.commons.logging.Log;
  
  /**
   * @version $Revision: 1.1 $ $Date: 2004/02/13 07:22:22 $
   */
  public class BootstrapJdk14Log implements Log {
      static {
          Logger root = Logger.getLogger("");
  
          GeronimoLogging geronimoLevel = GeronimoLogging.getDefaultLevel();
          Level javaLevel;
          if (geronimoLevel == GeronimoLogging.TRACE) {
              javaLevel = Level.FINEST;
          } else if (geronimoLevel == GeronimoLogging.DEBUG) {
              javaLevel = Level.FINE;
          } else if (geronimoLevel == GeronimoLogging.INFO) {
              javaLevel = Level.INFO;
          } else if (geronimoLevel == GeronimoLogging.WARN) {
              javaLevel = Level.WARNING;
          } else {
              javaLevel = Level.SEVERE;
          }
  
          // set the root level
          root.setLevel(javaLevel);
  
          // set the console handler level (if present)
          Handler[] handlers = root.getHandlers();
          for (int index = 0; index < handlers.length; index++) {
              if (handlers[index] instanceof ConsoleHandler) {
                  handlers[index].setLevel(javaLevel);
              }
          }
      }
  
      private Logger logger = null;
  
      public BootstrapJdk14Log(String name) {
          logger = Logger.getLogger(name);
      }
  
      private void log(Level level, String messge, Throwable throwable) {
          if (logger.isLoggable(level)) {
              // need to determine if caller class name and method
              StackTraceElement locations[] = new Throwable().getStackTrace();
  
              // Caller will be the forth element
              String cname = "unknown";
              String method = "unknown";
              if (locations != null && locations.length > 3) {
                  StackTraceElement caller = locations[3];
                  cname = caller.getClassName();
                  method = caller.getMethodName();
              }
              if (throwable == null) {
                  logger.logp(level, cname, method, messge);
              } else {
                  logger.logp(level, cname, method, messge, throwable);
              }
          }
      }
  
      public void debug(Object message) {
          log(Level.FINE, String.valueOf(message), null);
      }
  
      public void debug(Object message, Throwable exception) {
          log(Level.FINE, String.valueOf(message), exception);
      }
  
      public void error(Object message) {
          log(Level.SEVERE, String.valueOf(message), null);
      }
  
      public void error(Object message, Throwable exception) {
          log(Level.SEVERE, String.valueOf(message), exception);
      }
  
      public void fatal(Object message) {
          log(Level.SEVERE, String.valueOf(message), null);
      }
  
      public void fatal(Object message, Throwable exception) {
          log(Level.SEVERE, String.valueOf(message), exception);
      }
  
      public Logger getLogger() {
          return this.logger;
      }
  
      public void info(Object message) {
          log(Level.INFO, String.valueOf(message), null);
      }
  
      public void info(Object message, Throwable exception) {
          log(Level.INFO, String.valueOf(message), exception);
      }
  
      public boolean isDebugEnabled() {
          return (logger.isLoggable(Level.FINE));
      }
  
      public boolean isErrorEnabled() {
          return (logger.isLoggable(Level.SEVERE));
      }
  
      public boolean isFatalEnabled() {
          return (logger.isLoggable(Level.SEVERE));
      }
  
      public boolean isInfoEnabled() {
          return (logger.isLoggable(Level.INFO));
      }
  
      public boolean isTraceEnabled() {
          return (logger.isLoggable(Level.FINEST));
      }
  
      public boolean isWarnEnabled() {
          return (logger.isLoggable(Level.WARNING));
      }
  
      public void trace(Object message) {
          log(Level.FINEST, String.valueOf(message), null);
      }
  
      public void trace(Object message, Throwable exception) {
          log(Level.FINEST, String.valueOf(message), exception);
      }
  
      public void warn(Object message) {
          log(Level.WARNING, String.valueOf(message), null);
      }
  
      public void warn(Object message, Throwable exception) {
          log(Level.WARNING, String.valueOf(message), exception);
      }
  }
  
  
  
  1.1                  
incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/kernel/log/BootstrapLog4jLog.java
  
  Index: BootstrapLog4jLog.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Geronimo" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Geronimo", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * ====================================================================
   */
  package org.apache.geronimo.kernel.log;
  
  import org.apache.commons.logging.Log;
  import org.apache.log4j.Level;
  import org.apache.log4j.Logger;
  import org.apache.log4j.ConsoleAppender;
  import org.apache.log4j.PatternLayout;
  
  /**
   * @version $Revision: 1.1 $ $Date: 2004/02/13 07:22:22 $
   */
  public class BootstrapLog4jLog implements Log {
      static {
          Logger root = Logger.getRootLogger();
          root.addAppender(new ConsoleAppender(new PatternLayout("%d{ABSOLUTE} 
%-5p [%c{1}] %m%n")));
  
          GeronimoLogging level = GeronimoLogging.getDefaultLevel();
          if(level == null) {
              root.setLevel(Level.ERROR);
          } else if(level == GeronimoLogging.TRACE) {
              root.setLevel(Level.DEBUG);
          } else if(level == GeronimoLogging.DEBUG) {
              root.setLevel(Level.DEBUG);
          } else if(level == GeronimoLogging.INFO) {
              root.setLevel(Level.INFO);
          } else if(level == GeronimoLogging.WARN) {
              root.setLevel(Level.WARN);
          } else if(level == GeronimoLogging.ERROR) {
              root.setLevel(Level.ERROR);
          } else if(level == GeronimoLogging.FATAL) {
              root.setLevel(Level.FATAL);
          }
  
      }
  
      private static final String FQCN = BootstrapLog4jLog.class.getName();
      private Logger logger;
  
      public BootstrapLog4jLog(String name) {
          logger = Logger.getLogger(name);
      }
  
      public boolean isTraceEnabled() {
          return logger.isEnabledFor(Level.DEBUG);
      }
  
      public void trace(Object message) {
          logger.log(FQCN, Level.DEBUG, message, null);
      }
  
      public void trace(Object message, Throwable throwable) {
          logger.log(FQCN, Level.DEBUG, message, throwable);
      }
  
      public boolean isDebugEnabled() {
          return logger.isEnabledFor(Level.DEBUG);
      }
  
      public void debug(Object message) {
          logger.log(FQCN, Level.DEBUG, message, null);
      }
  
      public void debug(Object message, Throwable throwable) {
          logger.log(FQCN, Level.DEBUG, message, throwable);
      }
  
      public boolean isInfoEnabled() {
          return logger.isEnabledFor(Level.INFO);
      }
  
      public void info(Object message) {
          logger.log(FQCN, Level.INFO, message, null);
      }
  
      public void info(Object message, Throwable throwable) {
          logger.log(FQCN, Level.INFO, message, throwable);
      }
  
      public boolean isWarnEnabled() {
          return logger.isEnabledFor(Level.WARN);
      }
  
      public void warn(Object message) {
          logger.log(FQCN, Level.WARN, message, null);
      }
  
      public void warn(Object message, Throwable throwable) {
          logger.log(FQCN, Level.WARN, message, throwable);
      }
  
      public boolean isErrorEnabled() {
          return logger.isEnabledFor(Level.ERROR);
      }
  
      public void error(Object message) {
          logger.log(FQCN, Level.ERROR, message, null);
      }
  
      public void error(Object message, Throwable throwable) {
          logger.log(FQCN, Level.ERROR, message, throwable);
      }
  
      public boolean isFatalEnabled() {
          return logger.isEnabledFor(Level.FATAL);
      }
  
      public void fatal(Object message) {
          logger.log(FQCN, Level.FATAL, message, null);
      }
  
      public void fatal(Object message, Throwable throwable) {
          logger.log(FQCN, Level.FATAL, message, throwable);
      }
  }
  
  
  
  1.1                  
incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/kernel/log/BootstrapLogFactory.java
  
  Index: BootstrapLogFactory.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Geronimo" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Geronimo", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * ====================================================================
   */
  package org.apache.geronimo.kernel.log;
  
  import org.apache.commons.logging.impl.LogFactoryImpl;
  
  /**
   * @version $Revision: 1.1 $ $Date: 2004/02/13 07:22:22 $
   */
  public class BootstrapLogFactory extends LogFactoryImpl {
      private String logClassName;
      protected String getLogClassName() {
          if (logClassName != null) {
              return logClassName;
          }
  
          if (isLog4JAvailable()) {
              logClassName = "org.apache.geronimo.kernel.log.BootstrapLog4jLog";
          } else {
              logClassName = "org.apache.geronimo.kernel.log.BootstrapJdk14Log";
          }
          return logClassName;
      }
  }
  
  
  
  1.1                  
incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/kernel/log/GeronimoLogging.java
  
  Index: GeronimoLogging.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Geronimo" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Geronimo", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * ====================================================================
   */
  package org.apache.geronimo.kernel.log;
  
  import org.apache.commons.logging.LogFactory;
  
  /**
   * @version $Revision: 1.1 $ $Date: 2004/02/13 07:22:22 $
   */
  public class GeronimoLogging {
      public static final GeronimoLogging TRACE = new GeronimoLogging("TRACE");
      public static final GeronimoLogging DEBUG = new GeronimoLogging("DEBUG");
      public static final GeronimoLogging INFO = new GeronimoLogging("INFO");
      public static final GeronimoLogging WARN = new GeronimoLogging("WARN");
      public static final GeronimoLogging ERROR = new GeronimoLogging("ERROR");
      public static final GeronimoLogging FATAL = new GeronimoLogging("FATAL");
  
      private static boolean initialized = false;
      private static GeronimoLogging defaultLevel;
  
      /**
       * Initializes the logging system used by Geronimo.  This MUST be called 
in
       * in the main class used to start the geronimo server.  This method 
forces
       * commons logging to use GeronimoLogFacotry, starts the initial 
commons-logging
       * logging system, and forces mx4j to use commons logging.
       *
       * @param level
       */
      public static void initialize(GeronimoLogging level) {
          if (!initialized) {
              defaultLevel = level;
  
              // force commons-logging to use our log factory
              System.setProperty(LogFactory.FACTORY_PROPERTY, 
GeronimoLogFactory.class.getName());
  
              // force the log factory to initialize
              LogFactory.getLog(GeronimoLogging.class);
  
              // force mx4j to use commons logging
              // todo do this with reflection so mx4j is not required (this is 
important in JDK 1.5)
              mx4j.log.Log.redirectTo(new mx4j.log.CommonsLogger());
  
              initialized = true;
          }
  
      }
  
      public static GeronimoLogging getDefaultLevel() {
          return defaultLevel;
      }
  
      private final String level;
  
      private GeronimoLogging(String level) {
          this.level = level;
      }
  
      public String toString() {
          return level;
      }
  
      public boolean equals(Object object) {
          return object == this;
      }
  }
  
  
  
  1.2       +5 -2      
incubator-geronimo/modules/system/src/java/org/apache/geronimo/system/repository/ReadOnlyRepository.java
  
  Index: ReadOnlyRepository.java
  ===================================================================
  RCS file: 
/home/cvs/incubator-geronimo/modules/system/src/java/org/apache/geronimo/system/repository/ReadOnlyRepository.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ReadOnlyRepository.java   12 Feb 2004 18:12:52 -0000      1.1
  +++ ReadOnlyRepository.java   13 Feb 2004 07:22:22 -0000      1.2
  @@ -71,6 +71,8 @@
   import org.apache.geronimo.gbean.WaitingException;
   import org.apache.geronimo.kernel.repository.Repository;
   import org.apache.geronimo.system.serverinfo.ServerInfo;
  +import org.apache.commons.logging.Log;
  +import org.apache.commons.logging.LogFactory;
   
   /**
    *
  @@ -78,6 +80,7 @@
    * @version $Revision$ $Date$
    */
   public class ReadOnlyRepository implements Repository, GBean {
  +    private static final Log log = 
LogFactory.getLog(ReadOnlyRepository.class);
       private final URI root;
       private final ServerInfo serverInfo;
       private URI rootURI;
  @@ -111,7 +114,7 @@
   
       public void doStart() throws WaitingException, Exception {
           rootURI = serverInfo.resolve(root);
  -        System.out.println("Repository root is "+rootURI);
  +        log.info("Repository root is "+rootURI);
       }
   
       public void doStop() throws WaitingException, Exception {
  
  
  

Reply via email to