cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From un...@apache.org
Subject cvs commit: cocoon-2.1/src/blocks/repository/java/org/apache/cocoon/components/source/impl AbstractConfigurableSourceDescriptor.java AbstractConfigurableSourceInspector.java
Date Wed, 19 Nov 2003 14:39:13 GMT
unico       2003/11/19 06:39:13

  Modified:    src/blocks/repository/java/org/apache/cocoon/components/source/impl
                        AbstractConfigurableSourceDescriptor.java
                        AbstractConfigurableSourceInspector.java
  Log:
  documentation improvments
  
  Revision  Changes    Path
  1.4       +34 -8     cocoon-2.1/src/blocks/repository/java/org/apache/cocoon/components/source/impl/AbstractConfigurableSourceDescriptor.java
  
  Index: AbstractConfigurableSourceDescriptor.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/repository/java/org/apache/cocoon/components/source/impl/AbstractConfigurableSourceDescriptor.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- AbstractConfigurableSourceDescriptor.java	28 Oct 2003 15:01:00 -0000	1.3
  +++ AbstractConfigurableSourceDescriptor.java	19 Nov 2003 14:39:12 -0000	1.4
  @@ -55,14 +55,27 @@
   import org.apache.excalibur.source.SourceException;
   
   /**
  - * Abstract base class for configurable SourceInspectors.
  + * Abstract base class SourceDescriptors that want to 
  + * configure the set of properties they handle beforehand.
  + * 
  + * <p>
  + * Knowing which properties an inspector handles beforehand
  + * greatly improves property management performance.
  + * </p> 
    * 
    * @author <a href="mailto:unico@apache.org">Unico Hommes</a>
    */
   public abstract class AbstractConfigurableSourceDescriptor 
   extends AbstractConfigurableSourceInspector implements SourceDescriptor {
   
  -    
  +
  +    // ---------------------------------------------------- SourceDescriptor methods
  +
  +    /**
  +     * Checks if this SourceDescriptor is configured to handle the 
  +     * given property and if so forwards the call to 
  +     * <code>doRemoveSourceProperty()</code>.
  +     */
       public final void removeSourceProperty(Source source, String namespace, String name)
           throws SourceException {
           
  @@ -74,7 +87,12 @@
               doRemoveSourceProperty(source,namespace,name);
           }
       }
  -    
  +
  +    /**
  +     * Checks if this SourceDescriptor is configured to handle the 
  +     * given property and if so forwards the call to 
  +     * <code>doSetSourceProperty()</code>.
  +     */
       public final void setSourceProperty(Source source, SourceProperty property) 
           throws SourceException {
           
  @@ -86,11 +104,19 @@
               doSetSourceProperty(source,property);
           }
       }
  -    
  -    protected abstract void doRemoveSourceProperty(Source source, String namespace,String
name) 
  +
  +    // ---------------------------------------------------- abstract methods
  +
  +    /**
  +     * Do the actual work of removing the given property from the provided Source.
  +     */
  +    protected abstract void doRemoveSourceProperty(Source source, String namespace,String
name)
           throws SourceException;
  -    
  -    protected abstract void doSetSourceProperty(Source source, SourceProperty property)

  +
  +    /**
  +     * Do the actual work of setting the provided SourceProperty on the given Source.
  +     */
  +    protected abstract void doSetSourceProperty(Source source, SourceProperty property)
           throws SourceException;
  -    
  +
   }
  
  
  
  1.4       +57 -12    cocoon-2.1/src/blocks/repository/java/org/apache/cocoon/components/source/impl/AbstractConfigurableSourceInspector.java
  
  Index: AbstractConfigurableSourceInspector.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/repository/java/org/apache/cocoon/components/source/impl/AbstractConfigurableSourceInspector.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- AbstractConfigurableSourceInspector.java	28 Oct 2003 15:01:00 -0000	1.3
  +++ AbstractConfigurableSourceInspector.java	19 Nov 2003 14:39:12 -0000	1.4
  @@ -63,21 +63,34 @@
   import org.apache.excalibur.source.SourceException;
   
   /**
  - * Abstract base class for configurable SourceInspectors.
  + * Abstract base class for SourceInspectors that want to 
  + * configure the set of properties they handle beforehand.
  + * 
  + * <p>
  + * Knowing which properties an inspector handles beforehand
  + * greatly improves property management performance.
  + * </p>
    * 
    * @author <a href="mailto:unico@apache.org">Unico Hommes</a>
    */
   public abstract class AbstractConfigurableSourceInspector extends AbstractLogEnabled 
  -    implements SourceInspector, Configurable {
  +implements SourceInspector, Configurable {
   
       // the set of properties this inspector is configured to handle
       private Set m_properties;
  -    
  +
  +
  +    // ---------------------------------------------------- lifecycle
  +
       public AbstractConfigurableSourceInspector() {
       }
  -    
  +
       /**
        * Configure this source inspector to handle properties of required types.
  +     * <p>
  +     *  Configuration is in the form of a set of property elements as follows:<br>
  +     *  <code>&lt;property name="owner" namespace="meta"&gt;</code>
  +     * </p>
        */
       public void configure(Configuration configuration) throws ConfigurationException {
           final Configuration[] properties = configuration.getChildren("property");
  @@ -90,10 +103,22 @@
                       + properties[i].getLocation();
                   throw new ConfigurationException(message);
               }
  -            m_properties.add(namespace + "#" + name);
  +            String property = namespace + "#" + name;
  +            if (getLogger().isDebugEnabled()) {
  +                getLogger().debug("Handling '" + property + "'");
  +            }
  +            m_properties.add(property);
           }
       }
  -    
  +
  +    // ---------------------------------------------------- SourceInspector methods
  +
  +    /**
  +     * Iterates over the configured set of properties to handle,
  +     * for each property calls <code>doGetSourceProperty()</code>,
  +     * and returns the list of properties thus obtained. Subclasses
  +     * may want to overide this behavior to improve performance.
  +     */
       public SourceProperty[] getSourceProperties(Source source) throws SourceException {
           final Set result = new HashSet();
           final Iterator properties = m_properties.iterator();
  @@ -102,14 +127,18 @@
               int index = property.indexOf('#');
               String namespace = property.substring(0,index);
               String name      = property.substring(index+1);
  -            SourceProperty sp = getSourceProperty(source,namespace,name);
  +            SourceProperty sp = doGetSourceProperty(source,namespace,name);
               if (sp != null) {
                   result.add(sp);
               }
           }
           return (SourceProperty[]) result.toArray(new SourceProperty[result.size()]);
       }
  -    
  +
  +    /**
  +     * Checks if this inspector is configured to handle the requested property
  +     * and if so forwards the call to <code>doGetSourceProperty</code>.
  +     */
       public final SourceProperty getSourceProperty(Source source, String namespace, String
name) 
           throws SourceException {
           
  @@ -122,15 +151,31 @@
           }
           return null;
       }
  -    
  +
  +    // ---------------------------------------------------- abstract methods
  +
  +    /**
  +     * Do the actual work of getting the requested SourceProperty for the given Source.
  +     */
  +    protected abstract SourceProperty doGetSourceProperty(Source source, String ns, String
name)
  +        throws SourceException;
  +
  +
  +    // ---------------------------------------------------- utility methods
  +
  +    /**
  +     * Check if this inspector is configured to handle properties of 
  +     * the given type.
  +     */
       protected final boolean handlesProperty(String namespace, String name) {
           return m_properties.contains(namespace + "#" + name);
       }
       
  -    protected abstract SourceProperty doGetSourceProperty(Source source, String ns, String
name)
  -        throws SourceException;
  -    
  +    /**
  +     * Provide subclasses access to the set of configured properties.
  +     */
       protected final Set getPropertyTypes() {
           return m_properties;
       }
  +
   }
  
  
  

Mime
View raw message