cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From p...@apache.org
Subject cvs commit: cocoon-2.2/src/kernel/org/apache/cocoon/kernel/startup AbstractLogger.java KernelLoader.java KernelServlet.java Logger.java
Date Thu, 06 May 2004 20:09:33 GMT
pier        2004/05/06 13:09:33

  Modified:    src/kernel/org/apache/cocoon/kernel BlockLoader.java
                        DeployedWirings.java Installer.java
                        KernelDeployer.java ProxyWire.java
               src/kernel/org/apache/cocoon/kernel/composition
                        AbstractComposer.java Component.java Composer.java
                        Lifecycle.java WiringsWrapper.java
               src/kernel/org/apache/cocoon/kernel/configuration
                        Configurable.java
               src/kernel/org/apache/cocoon/kernel/startup
                        AbstractLogger.java KernelLoader.java
                        KernelServlet.java
  Added:       src/kernel/org/apache/cocoon/kernel/composition
                        AbstractComponent.java
               src/kernel/org/apache/cocoon/kernel/logging Logger.java
                        Logging.java
  Removed:     src/kernel/org/apache/cocoon/kernel/startup Logger.java
  Log:
  Adding logging in core: this Logger (as pointed out by the javadoc) should
  be used when a logger is not available (example, initializing a logging
  block). Maybe the "Logging" interface should be deprecated to start with.
  
  Revision  Changes    Path
  1.7       +0 -0      cocoon-2.2/src/kernel/org/apache/cocoon/kernel/BlockLoader.java
  
  Index: BlockLoader.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.2/src/kernel/org/apache/cocoon/kernel/BlockLoader.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  
  
  
  1.9       +18 -6     cocoon-2.2/src/kernel/org/apache/cocoon/kernel/DeployedWirings.java
  
  Index: DeployedWirings.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.2/src/kernel/org/apache/cocoon/kernel/DeployedWirings.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- DeployedWirings.java	6 May 2004 19:14:09 -0000	1.8
  +++ DeployedWirings.java	6 May 2004 20:09:32 -0000	1.9
  @@ -26,10 +26,13 @@
   import org.apache.cocoon.kernel.composition.Wire;
   import org.apache.cocoon.kernel.composition.WiringException;
   import org.apache.cocoon.kernel.composition.Wirings;
  +import org.apache.cocoon.kernel.composition.WiringsWrapper;
   import org.apache.cocoon.kernel.deployment.DeploymentException;
   import org.apache.cocoon.kernel.deployment.Instance;
   import org.apache.cocoon.kernel.identification.BlockDescriptor;
   import org.apache.cocoon.kernel.identification.Descriptor;
  +import org.apache.cocoon.kernel.logging.Logger;
  +import org.apache.cocoon.kernel.logging.Logging;
   import org.apache.cocoon.kernel.resolution.CompoundResolver;
   import org.apache.cocoon.kernel.resolution.Resolver;
   import org.apache.cocoon.kernel.resolution.Resource;
  @@ -58,6 +61,9 @@
       
       /** <p>The {@link Resolver} for resources accessible by wired blocks.</p>
*/
       private CompoundResolver pubresolver = new CompoundResolver();
  +    
  +    /** <p>The {@link Logger} instance to provide to new instances.</p> */
  +    private Logger logger = new Logger();
   
       /* ====================================================================== */
   
  @@ -70,13 +76,13 @@
        * @param deployer the {@link KernelDeployer} deploying this instance.
        * @throws DeploymentException if this instance can not be created.
        */
  -    public DeployedWirings(DeployableInstance instance, KernelDeployer deployer)
  +    public DeployedWirings(DeployableInstance i, KernelDeployer d, Logger l)
       throws DeploymentException {
  -        this.instance = instance;
  -        this.deployer = deployer;
  +        this.instance = i;
  +        this.deployer = d;
   
           /* Retrieve all we need from our instance regarding composers */
  -        LoadedBlock block = (LoadedBlock) instance.block();
  +        LoadedBlock block = (LoadedBlock) i.block();
           BlockDescriptor descriptor = (BlockDescriptor) block.descriptor();
           String composer = descriptor.providedComposer();
           String component = descriptor.providedClass();
  @@ -102,6 +108,9 @@
               } else {
                   this.composer = (Composer) clazz.newInstance();
               }
  +            if (this.composer instanceof Logging) {
  +                ((Logging)this.composer).logger(this.logger);
  +            }
           } catch (Throwable t) {
               if (t instanceof InvocationTargetException)
                   if (t.getCause() != null) t = t.getCause();
  @@ -109,7 +118,7 @@
               else composer = "composer  class \"" + composer + "\"";
               throw new DeploymentException("Cannot create " + composer
                                             + " instance for block \""
  -                                          + instance + "\"", t);
  +                                          + i + "\"", t);
           }
   
           /* Allocate the table of resource prefixes against wiring names */
  @@ -159,7 +168,10 @@
           if (this.composer == null) {
               throw new WiringException("Block does not provide components");
           }
  -        return(new ProxyWire(this.composer, role, this, resolver).getWire());
  +        WiringsWrapper wrapper = new WiringsWrapper(this);
  +        ProxyWire wire = new ProxyWire(this.composer, role, wrapper, resolver,
  +                                       this.logger);
  +        return((wire).getWire());
       }
   
       /* ====================================================================== */
  
  
  
  1.7       +0 -0      cocoon-2.2/src/kernel/org/apache/cocoon/kernel/Installer.java
  
  Index: Installer.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.2/src/kernel/org/apache/cocoon/kernel/Installer.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  
  
  
  1.10      +4 -3      cocoon-2.2/src/kernel/org/apache/cocoon/kernel/KernelDeployer.java
  
  Index: KernelDeployer.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.2/src/kernel/org/apache/cocoon/kernel/KernelDeployer.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- KernelDeployer.java	6 May 2004 19:14:09 -0000	1.9
  +++ KernelDeployer.java	6 May 2004 20:09:32 -0000	1.10
  @@ -35,7 +35,8 @@
   import org.apache.cocoon.kernel.identification.DescriptorBuilder;
   import org.apache.cocoon.kernel.identification.IdentificationException;
   import org.apache.cocoon.kernel.identification.Identifier;
  -import org.apache.cocoon.kernel.startup.Logger;
  +import org.apache.cocoon.kernel.logging.Logger;
  +import org.apache.cocoon.kernel.logging.Logging;
   
   /**
    * <p>A {@link KernelDeployer} is a simple implementation of the {@link Deployer}
  @@ -44,7 +45,7 @@
    * @author <a href="mailto:pier@apache.org">Pier Fumagalli</a>
    * @version 1.0 (CVS $Revision$)
    */
  -public class KernelDeployer implements Deployer {
  +public class KernelDeployer implements Deployer, Logging {
   
       /** <p>The XML configuration namespace.</p> */
       public static final String NAMESPACE = 
  @@ -250,7 +251,7 @@
           }
   
           /* Deploy the sucker (finally) */
  -        DeployedWirings deployed = new DeployedWirings(deployable, this);
  +        DeployedWirings deployed = new DeployedWirings(deployable, this, log);
           try {
               deployed.init();
           } catch (Throwable t) {
  
  
  
  1.9       +14 -9     cocoon-2.2/src/kernel/org/apache/cocoon/kernel/ProxyWire.java
  
  Index: ProxyWire.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.2/src/kernel/org/apache/cocoon/kernel/ProxyWire.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- ProxyWire.java	6 May 2004 19:14:09 -0000	1.8
  +++ ProxyWire.java	6 May 2004 20:09:32 -0000	1.9
  @@ -25,6 +25,8 @@
   import org.apache.cocoon.kernel.composition.Wire;
   import org.apache.cocoon.kernel.composition.WiringException;
   import org.apache.cocoon.kernel.composition.Wirings;
  +import org.apache.cocoon.kernel.logging.Logger;
  +import org.apache.cocoon.kernel.logging.Logging;
   import org.apache.cocoon.kernel.resolution.Resolver;
   
   /**
  @@ -92,7 +94,7 @@
        * the interface role specified in this constructor, and all the interfaces
        * implemented by the original object.</p>
        *
  -     * @param composer the {@link Composer} where acquisition, release and/or
  +     * @param c the {@link Composer} where acquisition, release and/or
        *                 disposal of proxied component instances will occur.
        * @param role an interface {@link Class} to which the {@link Wire}
        *             returned by {@link #getWire()} <b>must</b> be castable to.
  @@ -100,15 +102,17 @@
        *          where the proxied component is deployed.
        * @param r The {@link Resolver} providing resolution in the context of the
        *          block instance requesting the component instance.
  +     * @param l The {@link Logger} to provide to the component if it implements
  +     *          the {@link Logging} interface.
        * @throws WiringException if an error occurred acquiring the original
        *                              object or creating the {@link Wire}.
        * @throws NullPointerException if any of the parameters were <b>null</b>.
        */
  -    public ProxyWire(Composer composer, Class role, Wirings w, Resolver r)
  +    public ProxyWire(Composer c, Class role, Wirings w, Resolver r, Logger l)
       throws WiringException {
           ProxyWire.initialize();
   
  -        ClassLoader loader = composer.getClass().getClassLoader();
  +        ClassLoader loader = c.getClass().getClassLoader();
   
           /* Check that the requested role is actually an interface */
           if (!role.isInterface()) {
  @@ -125,14 +129,15 @@
           /* Acquire and check that the instance implements the given role */
           Object instance = null;
           try {
  -            instance = composer.acquire();
  +            instance = c.acquire();
  +            if (instance instanceof Logging) ((Logging)instance).logger(l);
           } catch (Throwable t) {
               throw new WiringException("Unable to acquire component", t);
           }
   
           if (!role.isAssignableFrom(instance.getClass())) {
               /* Remember to release components with wrong interfaces */
  -            composer.release(instance);
  +            c.release(instance);
               throw new WiringException("Acquired object instance \""
                                         + instance.getClass().getName()
                                         + "\" does not implement the "
  @@ -142,8 +147,8 @@
   
           try {
               /* Create the proxy instance */
  -            Class c[] = new Class[] { Wire.class, role };
  -            this.wire = (Wire)Proxy.newProxyInstance(loader, c, this);
  +            Class classes[] = new Class[] { Wire.class, role };
  +            this.wire = (Wire)Proxy.newProxyInstance(loader, classes, this);
   
               /* Contextualize the instance with the wire */
               if (instance instanceof Component) {
  @@ -151,11 +156,11 @@
               }
   
               /* Record the original composer and instance */
  -            this.composer = composer;
  +            this.composer = c;
               this.instance = instance;
           } catch (Throwable t) {
               /* Something bad happened releasing, release the instance */
  -            composer.release(instance);
  +            c.release(instance);
               throw new WiringException("Unable to create wrapper for "
                                         + "composed component instance", t);
           }
  
  
  
  1.2       +2 -3      cocoon-2.2/src/kernel/org/apache/cocoon/kernel/composition/AbstractComposer.java
  
  Index: AbstractComposer.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.2/src/kernel/org/apache/cocoon/kernel/composition/AbstractComposer.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AbstractComposer.java	6 May 2004 19:14:09 -0000	1.1
  +++ AbstractComposer.java	6 May 2004 20:09:33 -0000	1.2
  @@ -21,13 +21,12 @@
   /**
    * <p>An abstract implementation of the {@link Composer} interface.</p> 
    *
  - *
    * @author <a href="mailto:pier@apache.org">Pier Fumagalli</a>
    * @version 1.0 (CVS $Revision$)
    */
   public abstract class AbstractComposer implements Composer {
   
  -    /** <p>The {@link Wirings} instance contextualized in this instance.</p>
*/
  +     /** <p>The {@link Wirings} instance contextualized in this instance.</p>
*/
       protected Wirings wirings = null;
   
       /** <p>The {@link Parameters} instance configured in this instance.</p>
*/
  @@ -66,7 +65,7 @@
        * <p>Configure this instance and store the supplied {@link Parameters}
        * instance.</p>
        * 
  -     * <p>The configure {@link Parameters} instance will be available in the
  +     * <p>The configured {@link Parameters} instance will be available in the
        * protected {@link #parameters} field.</p>
        * 
        * @param parameters the {@link Parameters} configuring this instance.
  
  
  
  1.6       +0 -0      cocoon-2.2/src/kernel/org/apache/cocoon/kernel/composition/Component.java
  
  Index: Component.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.2/src/kernel/org/apache/cocoon/kernel/composition/Component.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  
  
  
  1.5       +0 -0      cocoon-2.2/src/kernel/org/apache/cocoon/kernel/composition/Composer.java
  
  Index: Composer.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.2/src/kernel/org/apache/cocoon/kernel/composition/Composer.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  
  
  
  1.5       +0 -0      cocoon-2.2/src/kernel/org/apache/cocoon/kernel/composition/Lifecycle.java
  
  Index: Lifecycle.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.2/src/kernel/org/apache/cocoon/kernel/composition/Lifecycle.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  
  
  
  1.2       +0 -0      cocoon-2.2/src/kernel/org/apache/cocoon/kernel/composition/WiringsWrapper.java
  
  Index: WiringsWrapper.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.2/src/kernel/org/apache/cocoon/kernel/composition/WiringsWrapper.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  
  
  
  1.1                  cocoon-2.2/src/kernel/org/apache/cocoon/kernel/composition/AbstractComponent.java
  
  Index: AbstractComponent.java
  ===================================================================
  /* ========================================================================== *
   * Copyright (C) 1996-2004 VNU Business Publications LTD. All rights reserved *
   * ========================================================================== */
  package org.apache.cocoon.kernel.composition;
  
  import org.apache.cocoon.kernel.resolution.Resolver;
  
  
  /**
   * <p></p> 
   *
   * @author <a href="mailto:pier@apache.org">Pier Fumagalli</a>
   * @version 1.0 (CVS $Revision: 1.1 $)
   */
  public class AbstractComponent implements Component {
   
      /** <p>The {@link Wire} instance contextualized in this instance.</p> */
      protected Wire wire = null;
  
      /** <p>The {@link Resolver} instance contextualized in this instance.</p>
*/
      protected Resolver resolver = null;
  
      /**
       * <p>Create a new {@link AbstractComposer} instance.</p>
       */
      public AbstractComponent() {
          super();
      }
  
      /**
       * <p>Contextualize this {@link Component} instance.</p>
       *
       * <p>The contextualized {@link Wire} and {@link Resolver} instances will
       * be available in the {@link #wire} and {@link #resolver} fields
       * respectively.</p>
       *
       * @param wire the {@link Wire} instance through which the block requesting
       *             this instance is accessing it.
       * @param resolver the {@link Resolver} instance resolving resources in the
       *                 calling block instance.
       */
      public void contextualize(Wire wire, Resolver resolver) {
          this.resolver = resolver;
          this.wire = wire;
      }
  }
  
  
  
  1.5       +0 -0      cocoon-2.2/src/kernel/org/apache/cocoon/kernel/configuration/Configurable.java
  
  Index: Configurable.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.2/src/kernel/org/apache/cocoon/kernel/configuration/Configurable.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  
  
  
  1.1                  cocoon-2.2/src/kernel/org/apache/cocoon/kernel/logging/Logger.java
  
  Index: Logger.java
  ===================================================================
  /*
   * Copyright 1999-2004 The Apache Software Foundation.
   * 
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   * 
   *      http://www.apache.org/licenses/LICENSE-2.0
   * 
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  package org.apache.cocoon.kernel.logging;
  
  /**
   * <p>The {@link Logger} represents the root class for all core loggers of
   * the framework.</p>
   *
   * <p>This implementation never logs.</p>
   *
   * @author <a href="mailto:pier@apache.org">Pier Fumagalli</a>
   * @version 1.0 (CVS $Revision: 1.1 $)
   */
  public class Logger {
  
      /**
       * <p>Create a new {@link Logger}.</p>
       */
      public Logger() {
          super();
      }
      
      /**
       * <p>Log a debug message.</p>
       *
       * @param message the message.
       */
      public void debug(String message) {
      }
      
      /**
       * <p>Log a debug message.</p>
       *
       * @param message the message.
       * @param throwable the throwable.
       */
      public void debug(String message, Throwable throwable) {
      }
      
      /**
       * <p>Log a info message.</p>
       *
       * @param message the message.
       */
      public void info(String message) {
      }
      
      /**
       * <p>Log a info message.</p>
       *
       * @param message the message.
       * @param throwable the throwable.
       */
      public void info(String message, Throwable throwable) {
      }
     
      /**
       * <p>Log a warn message.</p>
       *
       * @param message the message.
       */
      public void warn(String message) {
      }
      
      /**
       * <p>Log a warn message.</p>
       *
       * @param message the message.
       * @param throwable the throwable.
       */
      public void warn(String message, Throwable throwable) {
      }
      
      /**
       * <p>Log an error message.</p>
       *
       * @param message the message.
       */
      public void error(String message) {
      }
      
      /**
       * <p>Log a error message.</p>
       *
       * @param message the message.
       * @param throwable the throwable.
       */
      public void error(String message, Throwable throwable) {
      }
      
      /**
       * <p>Log a fatal error message.</p>
       *
       * @param message the message.
       */
      public void fatal(String message) {
      }
      
      /**
       * <p>Log a fatal error message.</p>
       *
       * @param message the message.
       * @param throwable the throwable.
       */
      public void fatal(String message, Throwable throwable) {
      }
  }
  
  
  
  1.1                  cocoon-2.2/src/kernel/org/apache/cocoon/kernel/logging/Logging.java
  
  Index: Logging.java
  ===================================================================
  /*
   * Copyright 1999-2004 The Apache Software Foundation.
   * 
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   * 
   *      http://www.apache.org/licenses/LICENSE-2.0
   * 
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  package org.apache.cocoon.kernel.logging;
  
  
  /**
   * <p>The {@link Logging} interface marks a component requiring to log through
   * the core kernel logging facility.</p>
   *
   * <p>Instead of relying on this interface, blocks should define their logging
   * requirements in their deployment descriptor (as with any other required
   * block) but in some cases the core loggers might be required (for example,
   * during the initialization of a block providing loggers).</p>
   *
   * @author <a href="mailto:pier@apache.org">Pier Fumagalli</a>
   * @version 1.0 (CVS $Revision: 1.1 $)
   */
  public interface Logging {
  
      /**
       * <p>Setup the {@link Logger} instance this component can use to
       * perform logging operations.</p>
       *
       * @param logger a <b>non null</b> {@link Logger} instance.
       */
      public void logger(Logger logger);
  
  }
  
  
  
  1.8       +2 -1      cocoon-2.2/src/kernel/org/apache/cocoon/kernel/startup/AbstractLogger.java
  
  Index: AbstractLogger.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.2/src/kernel/org/apache/cocoon/kernel/startup/AbstractLogger.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- AbstractLogger.java	6 May 2004 08:43:18 -0000	1.7
  +++ AbstractLogger.java	6 May 2004 20:09:33 -0000	1.8
  @@ -21,6 +21,7 @@
   import javax.servlet.ServletException;
   import javax.xml.transform.TransformerException;
   
  +import org.apache.cocoon.kernel.logging.Logger;
   import org.xml.sax.SAXException;
   
   /**
  
  
  
  1.2       +2 -2      cocoon-2.2/src/kernel/org/apache/cocoon/kernel/startup/KernelLoader.java
  
  Index: KernelLoader.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.2/src/kernel/org/apache/cocoon/kernel/startup/KernelLoader.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- KernelLoader.java	4 May 2004 17:38:53 -0000	1.1
  +++ KernelLoader.java	6 May 2004 20:09:33 -0000	1.2
  @@ -34,7 +34,7 @@
           }
   
           /* Create a logger for startup operations */
  -        Logger logger = new ConsoleLogger();
  +        ConsoleLogger logger = new ConsoleLogger();
   
           try {
               /* Now let's create our core deployer */
  
  
  
  1.4       +2 -2      cocoon-2.2/src/kernel/org/apache/cocoon/kernel/startup/KernelServlet.java
  
  Index: KernelServlet.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.2/src/kernel/org/apache/cocoon/kernel/startup/KernelServlet.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- KernelServlet.java	6 May 2004 19:14:09 -0000	1.3
  +++ KernelServlet.java	6 May 2004 20:09:33 -0000	1.4
  @@ -42,7 +42,7 @@
   
       protected static KernelServlet instance = null;
   
  -    private Logger logger = null;
  +    private ServletLogger logger = null;
       private Wirings wirings = null;
       private ServletConfig config = null;
       private KernelDeployer deployer = null;
  @@ -146,7 +146,7 @@
           return("Apache Cocoon Kernel Servlet");
       }
       
  -    public Logger getLogger() {
  +    public ServletLogger getLogger() {
           return(this.logger);
       }
   
  
  
  

Mime
View raw message