You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by bl...@locus.apache.org on 2000/11/14 16:35:32 UTC

cvs commit: xml-cocoon/src/org/apache/cocoon CocoonComponentSelector.java DefaultComponentManager.java

bloritsch    00/11/14 07:35:32

  Modified:    src/org/apache/cocoon Tag: xml-cocoon2
                        CocoonComponentSelector.java
                        DefaultComponentManager.java
  Log:
  Changed log targets so that general information is only output at the DEBUG level--unless there is an error.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.4   +10 -2     xml-cocoon/src/org/apache/cocoon/Attic/CocoonComponentSelector.java
  
  Index: CocoonComponentSelector.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/Attic/CocoonComponentSelector.java,v
  retrieving revision 1.1.2.3
  retrieving revision 1.1.2.4
  diff -u -r1.1.2.3 -r1.1.2.4
  --- CocoonComponentSelector.java	2000/11/10 22:38:52	1.1.2.3
  +++ CocoonComponentSelector.java	2000/11/14 15:35:31	1.1.2.4
  @@ -28,10 +28,13 @@
   import org.apache.cocoon.util.ComponentPool;
   import org.apache.cocoon.util.ComponentPoolController;
   
  +import org.apache.log.Logger;
  +import org.apache.log.LogKit;
  +
   /** Default component manager for Cocoon's non sitemap components.
    * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
    * @author <a href="mailto:paul@luminas.co.uk">Paul Russell</a>
  - * @version CVS $Revision: 1.1.2.3 $ $Date: 2000/11/10 22:38:52 $
  + * @version CVS $Revision: 1.1.2.4 $ $Date: 2000/11/14 15:35:31 $
    */
   public class CocoonComponentSelector implements ComponentSelector, Composer {
       /** Hashmap of all components which this ComponentManager knows about.
  @@ -84,23 +87,28 @@
           Component component;
   
           if ( hint == null ) {
  -            throw new ComponentNotFoundException("Attempted to retrieve component will null roll.");
  +            log.error("Attempted to retrieve component with null hint.");
  +            throw new ComponentNotFoundException("Attempted to retrieve component with null hint.");
           }
   
           // Retrieve the class of the requested component.
           Class componentClass = (Class)this.components.get(hint);
   
           if ( componentClass == null ) {
  +            log.debug("componentClass is null");
               component = (Component)this.instances.get(hint);
               if ( component == null ) {
  +                log.error("Could not find component for hint '" + hint.toString() + "'.");
                   throw new ComponentNotFoundException("Could not find component for hint '" + hint.toString() + "'.");
               } else {
  +                log.debug("Found Component for hint '" + hint.toString() + "'.");
                   // we found an individual instance of a component.
                   return component;
               }
           }
   
           if ( !Component.class.isAssignableFrom(componentClass) ) {
  +            log.error("Component with hint '" + hint.toString() + "' (" + componentClass.getName() + ")does not implement Component.");
               throw new ComponentNotAccessibleException(
                   "Component with hint '" + hint.toString() + "' (" + componentClass.getName() + ")does not implement Component.",
                   null
  
  
  
  1.1.2.4   +18 -18    xml-cocoon/src/org/apache/cocoon/Attic/DefaultComponentManager.java
  
  Index: DefaultComponentManager.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/Attic/DefaultComponentManager.java,v
  retrieving revision 1.1.2.3
  retrieving revision 1.1.2.4
  diff -u -r1.1.2.3 -r1.1.2.4
  --- DefaultComponentManager.java	2000/11/10 22:38:52	1.1.2.3
  +++ DefaultComponentManager.java	2000/11/14 15:35:31	1.1.2.4
  @@ -35,7 +35,7 @@
   
   /** Default component manager for Cocoon's non sitemap components.
    * @author <a href="mailto:paul@luminas.co.uk">Paul Russell</a>
  - * @version CVS $Revision: 1.1.2.3 $ $Date: 2000/11/10 22:38:52 $
  + * @version CVS $Revision: 1.1.2.4 $ $Date: 2000/11/14 15:35:31 $
    */
   public class DefaultComponentManager implements ComponentManager {
   
  @@ -80,7 +80,7 @@
           Component component;
   
           if ( role == null ) {
  -	    log.debug("Attempted to retrieve a component with a null Role");
  +        log.debug("Attempted to retrieve a component with a null Role");
               throw new ComponentNotFoundException("Attempted to retrieve component will null roll.");
           }
   
  @@ -88,20 +88,20 @@
           Class componentClass = (Class)this.components.get(role);
   
           if ( componentClass == null ) {
  -	    log.debug("componentClass for " + role + " is null");
  +        log.debug("componentClass for " + role + " is null");
               component = (Component)this.instances.get(role);
               if ( component == null ) {
  -	        log.error(role + " could not be found");
  +                log.error(role + " could not be found");
                   throw new ComponentNotFoundException("Could not find component for role '" + role + "'.");
               } else {
  -	        log.error(role + " instance was found");
  +                log.debug(role + " instance was found");
                   // we found an individual instance of a component.
                   return component;
               }
           }
   
           if ( !Component.class.isAssignableFrom(componentClass) ) {
  -	    log.error("The object found is not a Component");
  +            log.error("The object found is not a Component");
               throw new ComponentNotAccessibleException(
                   "Component with role '" + role + "' (" + componentClass.getName() + ")does not implement Component.",
                   null
  @@ -110,23 +110,23 @@
   
           // Work out what class of component we're dealing with.
           if ( ThreadSafe.class.isAssignableFrom(componentClass) ) {
  -	    log.debug(role + " is ThreadSafe");
  +            log.debug(role + " is ThreadSafe");
               component = getThreadsafeComponent(componentClass);
           } else if ( Poolable.class.isAssignableFrom(componentClass) ) {
  -	    log.debug(role + " is Poolable");
  +            log.debug(role + " is Poolable");
               component = getPooledComponent(componentClass);
           } else if ( SingleThreaded.class.isAssignableFrom(componentClass) ) {
  -	    log.debug(role + " is SingleThreaded");
  +            log.debug(role + " is SingleThreaded");
               try {
                   component = (Component)componentClass.newInstance();
               } catch ( InstantiationException e ) {
  -	        log.error("Could not create new instance of SingleThreaded " + role, e);
  +                log.error("Could not create new instance of SingleThreaded " + role, e);
                   throw new ComponentNotAccessibleException(
                       "Could not instantiate component " + componentClass.getName() + ": " + e.getMessage(),
                       e
                   );
               } catch ( IllegalAccessException e ) {
  -	        log.error("Could not access class " + componentClass.getName(), e);
  +                log.error("Could not access class " + componentClass.getName(), e);
                   throw new ComponentNotAccessibleException(
                       "Could not access class " + componentClass.getName() + ": " + e.getMessage(),
                       e
  @@ -137,17 +137,17 @@
               /* The component doesn't implement any of the Avalon marker
                * classes, treat as normal.
                */
  -	    log.debug(role + " is a normal Component");
  +            log.debug(role + " is a normal Component");
               try {
                   component = (Component)componentClass.newInstance();
               } catch ( InstantiationException e ) {
  -	        log.error("Could not create new instance of class " + componentClass.getName(), e);
  +                log.error("Could not create new instance of class " + componentClass.getName(), e);
                   throw new ComponentNotAccessibleException(
                       "Could not instantiate component " + componentClass.getName() + ": " + e.getMessage(),
                       e
                   );
               } catch ( IllegalAccessException e ) {
  -	        log.error("Could not access class " + componentClass.getName(), e);
  +                log.error("Could not access class " + componentClass.getName(), e);
                   throw new ComponentNotAccessibleException(
                       "Could not access class " + componentClass.getName() + ": " + e.getMessage(),
                       e
  @@ -261,12 +261,12 @@
                   Configuration current = (Configuration) instances.next();
                   Object hint = current.getAttribute("name");
                   String className = (String) current.getAttribute("class");
  -		log.debug("Adding new Component " + className +
  -		              " for hint: " + hint);
  -	        try {
  +                log.debug("Adding new Component " + className +
  +                          " for hint: " + hint);
  +            try {
                       selector.addComponent(hint, ClassUtils.loadClass(className), current);
                   } catch (Exception e) {
  -		    log.error("The component instance for \"" + hint + "\" has an invalid class name.", e);
  +                    log.error("The component instance for \"" + hint + "\" has an invalid class name.", e);
                       throw new ConfigurationException("The component instance for '" + hint + "' has an invalid class name.");
                   }
               }