sanders     01/08/13 12:49:34

  Modified:    digester/src/java/org/apache/commons/digester
                        FactoryCreateRule.java ObjectCreationFactory.java
  Log:
  Added the ability to pass the Digester instance on to the factory.
  This is to allow for classloading, debugging, checking parser props, etc.
  
  Revision  Changes    Path
  1.2       +8 -7      
jakarta-commons/digester/src/java/org/apache/commons/digester/FactoryCreateRule.java
  
  Index: FactoryCreateRule.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons/digester/src/java/org/apache/commons/digester/FactoryCreateRule.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- FactoryCreateRule.java    2001/08/04 23:46:29     1.1
  +++ FactoryCreateRule.java    2001/08/13 19:49:34     1.2
  @@ -74,7 +74,7 @@
    * in a call to either a factory method or to a non-empty constructor.
    *
    * @author Robert Burrell Donkin
  - * @version $Revision: 1.1 $ $Date: 2001/08/04 23:46:29 $
  + * @version $Revision: 1.2 $ $Date: 2001/08/13 19:49:34 $
    */
   
   public class FactoryCreateRule extends Rule {
  @@ -129,7 +129,7 @@
       public FactoryCreateRule(Digester digester,
                                ObjectCreationFactory creationFactory) {
   
  -     super(digester);
  +        super(digester);
           this.creationFactory = creationFactory;
   
       }
  @@ -168,7 +168,7 @@
        * @param attributes The attribute list of this element
        */
       public void begin(Attributes attributes) throws Exception {
  -     
  +
           Object instance = getFactory(attributes).createObject(attributes);
           if (digester.getDebug() >= 1)
               digester.log("New " + instance.getClass().getName());
  @@ -182,9 +182,9 @@
        */
       public void end() throws Exception {
   
  -     Object top = digester.pop();
  -     if (digester.getDebug() >= 1)
  -         digester.log("Pop " + top.getClass().getName());
  +        Object top = digester.pop();
  +        if (digester.getDebug() >= 1)
  +            digester.log("Pop " + top.getClass().getName());
   
       }
   
  @@ -194,7 +194,7 @@
        */
       public void finish() throws Exception {
   
  -     creationFactory = null;
  +        creationFactory = null;
   
       }
   
  @@ -225,6 +225,7 @@
               Class clazz = digester.getClassLoader().loadClass(realClassName);
               creationFactory = (ObjectCreationFactory)
                   clazz.newInstance();
  +            creationFactory.setDigester(digester);
           }
           return (creationFactory);
   
  
  
  
  1.2       +20 -6     
jakarta-commons/digester/src/java/org/apache/commons/digester/ObjectCreationFactory.java
  
  Index: ObjectCreationFactory.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons/digester/src/java/org/apache/commons/digester/ObjectCreationFactory.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ObjectCreationFactory.java        2001/08/04 23:46:29     1.1
  +++ ObjectCreationFactory.java        2001/08/13 19:49:34     1.2
  @@ -53,7 +53,7 @@
    * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
    *
  - */  
  + */
   
   package org.apache.commons.digester;
   
  @@ -65,17 +65,31 @@
    * <p> Interface for use with {@link FactoryCreateRule}.
    *
    * @author Robert Burrell Donkin
  - * @version $Revision: 1.1 $ $Date: 2001/08/04 23:46:29 $
  + * @version $Revision: 1.2 $ $Date: 2001/08/13 19:49:34 $
    */
  -public interface ObjectCreationFactory 
  -{    
  +public interface ObjectCreationFactory
  +{
   
       /**
        * <p>Factory method called by {@link FactoryCreateRule} to supply an
        * object based on the element's attributes.
        *
        * @param attributes the element's attributes
  -     */ 
  -    Object createObject(Attributes attributes);
  +     */
  +    public Object createObject(Attributes attributes);
  +
  +    /**
  +     * <p>Returns the {@link Digester} that was set by the
  +     * {@link FactoryCreateRule} upon initialization.
  +     */
  +    public Digester getDigester();
  +
  +    /**
  +     * <p>Set the {@link Digester} to allow the implementation to do logging,
  +     * classloading based on the digester's classloader, etc.
  +     *
  +     * @param digester parent Digester object
  +     */
  +    public void setDigester(Digester digester);
   
   }
  
  
  

Reply via email to