ricardo     01/03/19 11:55:54

  Modified:    src/org/apache/cocoon/components Tag: xml-cocoon2
                        CocoonComponentSelector.java
  Log:
  Fixed NPE arising from using the configuration name when a static instance 
was added
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.6   +21 -5     
xml-cocoon/src/org/apache/cocoon/components/Attic/CocoonComponentSelector.java
  
  Index: CocoonComponentSelector.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/components/Attic/CocoonComponentSelector.java,v
  retrieving revision 1.1.2.5
  retrieving revision 1.1.2.6
  diff -u -r1.1.2.5 -r1.1.2.6
  --- CocoonComponentSelector.java      2001/03/19 17:08:38     1.1.2.5
  +++ CocoonComponentSelector.java      2001/03/19 19:55:52     1.1.2.6
  @@ -37,7 +37,7 @@
   /** Default component manager for Cocoon's non sitemap components.
    * @author <a href="mailto:[EMAIL PROTECTED]">Berin Loritsch</a>
    * @author <a href="mailto:[EMAIL PROTECTED]">Paul Russell</a>
  - * @version CVS $Revision: 1.1.2.5 $ $Date: 2001/03/19 17:08:38 $
  + * @version CVS $Revision: 1.1.2.6 $ $Date: 2001/03/19 19:55:52 $
    */
   public class CocoonComponentSelector extends AbstractLoggable implements 
Contextualizable, ComponentSelector, Composer, Configurable, ThreadSafe, 
Disposable {
   
  @@ -127,24 +127,24 @@
           Component component = null;
   
           if ( hint == null ) {
  -            getLogger().error(this.conf.getName() + ": 
CocoonComponentSelector Attempted to retrieve component with null hint.");
  +            getLogger().error(this.getName() + ": CocoonComponentSelector 
Attempted to retrieve component with null hint.");
               throw new ComponentManagerException("Attempted to retrieve 
component with null hint.");
           }
   
           handler = (CocoonComponentHandler) this.componentHandlers.get(hint);
           // Retrieve the instance of the requested component
           if ( handler == null ) {
  -            throw new ComponentManagerException(this.conf.getName() + ": 
CocoonComponentSelector could not find the component for hint: " + hint);
  +            throw new ComponentManagerException(this.getName() + ": 
CocoonComponentSelector could not find the component for hint: " + hint);
           }
   
           try {
               component = handler.get();
           } catch (Exception e) {
  -            throw new ComponentManagerException(this.conf.getName() + ": 
CocoonComponentSelector could not access the Component for you", e);
  +            throw new ComponentManagerException(this.getName() + ": 
CocoonComponentSelector could not access the Component for you", e);
           }
   
           if (component == null) {
  -            throw new ComponentManagerException(this.conf.getName() + ": 
CocoonComponentSelector could not find the component for hint: " + hint);
  +            throw new ComponentManagerException(this.getName() + ": 
CocoonComponentSelector could not find the component for hint: " + hint);
           }
   
           this.componentMapping.put(component, handler);
  @@ -217,4 +217,20 @@
               getLogger().error("Could not set up Component for hint: " + 
hint, e);
           }
       }
  +
  +    private static final String DEFAULT_NAME = "UnnamedSelector";
  +
  +    /**
  +     * Return this selector's configuration name or a default name if no such
  +     * configuration was provided. This accounts for the case when a static
  +     * component instance has been added through
  +     * <code>addComponentInstance</code> with no associated configuration
  +     */
  +   private String getName() {
  +     if (this.conf != null) {
  +       return this.conf.getName();
  +     }
  +
  +     return DEFAULT_NAME;
  +   }
   }
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     [EMAIL PROTECTED]
To unsubscribe, e-mail:          [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to