You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by jm...@apache.org on 2001/03/13 04:44:06 UTC

cvs commit: jakarta-turbine/src/java/org/apache/turbine/services/intake/model BigDecimalField.java Field.java FieldFactory.java Group.java IntakeValue.java IntegerField.java StringField.java

jmcnally    01/03/12 19:44:06

  Modified:    src/java/org/apache/turbine/services/intake
                        IntakeService.java TurbineIntake.java
                        TurbineIntakeService.java
               src/java/org/apache/turbine/services/intake/model
                        BigDecimalField.java Field.java FieldFactory.java
                        Group.java IntakeValue.java IntegerField.java
                        StringField.java
  Added:       src/java/org/apache/turbine/services/intake IntakeTool.java
  Removed:     src/java/org/apache/turbine/services/intake
                        IntakePullSystem.java
  Log:
  still a work in progress.
  Added some javadoc/license
  added code related to pull tool
  renamed IntakePullSystem to IntakeTool
  
  Revision  Changes    Path
  1.2       +45 -7     jakarta-turbine/src/java/org/apache/turbine/services/intake/IntakeService.java
  
  Index: IntakeService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine/src/java/org/apache/turbine/services/intake/IntakeService.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- IntakeService.java	2001/03/09 11:38:05	1.1
  +++ IntakeService.java	2001/03/13 03:44:05	1.2
  @@ -55,6 +55,7 @@
    */
   
   import org.apache.turbine.util.TurbineException;
  +import org.apache.turbine.util.ParameterParser;
   import org.apache.turbine.util.pool.Recyclable;
   import org.apache.turbine.services.intake.xmlmodel.*;
   import org.apache.turbine.services.intake.model.*;
  @@ -64,7 +65,7 @@
    * on an XML specification.
    * 
    * @author <a href="mailto:jmcnally@collab.net">John McNally</a>
  - * @version $Id: IntakeService.java,v 1.1 2001/03/09 11:38:05 jmcnally Exp $
  + * @version $Id: IntakeService.java,v 1.2 2001/03/13 03:44:05 jmcnally Exp $
    */
   public interface IntakeService
   {
  @@ -84,22 +85,49 @@
       public static final int DEFAULT_POOL_CAPACITY = 1024;
   
       /**
  -     * Gets an instance of a specified group either from the pool
  -     * or by instatiating a Group if the pool is empty.
  +     * Gets an instance of a named group either from the pool
  +     * or by calling the Factory Service if the pool is empty.
        *
  -     * @param groupName the group.
  -     * @return the instance.
  +     * @param groupName the name of the group.
  +     * @return a Group instance.
  +     * @throws TurbineException if recycling fails.
  +     */
  +    public Group getGroup(String groupName)
  +        throws Exception;
  +
  +    /**
  +     * Gets an instance of a named group either from the pool
  +     * or by calling the Factory Service if the pool is empty and
  +     * then initialize it using the ParameterParser looking for 
  +     * a NEW id.
  +     *
  +     * @param groupName the name of the group.
  +     * @param pp the request parameters that may contain matching keys
  +     * @return a Group instance.
        * @throws TurbineException if recycling fails.
        */
  -    public Group getInstance(String groupName)
  +    public Group getGroup(String groupName, ParameterParser pp)
           throws Exception;
   
       /**
  +     * Gets an instance of a named group either from the pool
  +     * or by calling the Factory Service if the pool is empty and
  +     * then initialize it using the ParameterParser looking for id.
  +     *
  +     * @param groupName the name of the group.
  +     * @param pp the request parameters that may contain matching keys
  +     * @return a Group instance.
  +     * @throws TurbineException if recycling fails.
  +     */
  +    public Group getGroup(String groupName, ParameterParser pp, String id)
  +        throws Exception;
  +
  +    /**
        * Puts a group back to the pool.
        * @param instance the object instance to recycle.
        * @return true if the instance was accepted.
        */
  -    public boolean putInstance(Group instance);
  +    public boolean releaseGroup(Group instance);
   
       /**
        * Gets the capacity of the pool for a named group.
  @@ -146,6 +174,14 @@
       public String getGroupKey(String groupName);
   
       /**
  +     * Gets an object that is used in templates to get groups.
  +     *
  +     * @param groupName the name of the group.
  +     * @return the the key.
  +     */
  +    public Object getPuller(String groupName);
  +
  +    /**
        * Gets an object associated with the fields in a group.
        *
        * @param groupName the name of the group.
  @@ -153,6 +189,8 @@
        */
       public Retrievable getRetrievableObject(String groupName);
   }
  +
  +
   
   
   
  
  
  
  1.2       +54 -9     jakarta-turbine/src/java/org/apache/turbine/services/intake/TurbineIntake.java
  
  Index: TurbineIntake.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine/src/java/org/apache/turbine/services/intake/TurbineIntake.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TurbineIntake.java	2001/03/09 11:38:05	1.1
  +++ TurbineIntake.java	2001/03/13 03:44:05	1.2
  @@ -57,6 +57,7 @@
   // Turbine Stuff
   import org.apache.turbine.services.TurbineServices;
   import org.apache.turbine.util.TurbineException;
  +import org.apache.turbine.util.ParameterParser;
   import org.apache.turbine.services.intake.xmlmodel.*;
   import org.apache.turbine.services.intake.model.*;
   
  @@ -68,22 +69,55 @@
    * the settings in TurbineResources.
    *
    * @author <a href="mailto:jmcnally@collab.net">John McNally</a>
  - * @version $Id: TurbineIntake.java,v 1.1 2001/03/09 11:38:05 jmcnally Exp $
  + * @version $Id: TurbineIntake.java,v 1.2 2001/03/13 03:44:05 jmcnally Exp $
    */
   public abstract class TurbineIntake
   {
       /**
  -     * Gets an instance of a specified group either from the pool
  -     * or by instatiating a Group if the pool is empty.
  +     * Gets an instance of a named group either from the pool
  +     * or by calling the Factory Service if the pool is empty.
        *
  -     * @param groupName the group.
  -     * @return the instance.
  +     * @param groupName the name of the group.
  +     * @return a Group instance.
  +     * @throws TurbineException if recycling fails.
  +     */
  +    public static Group getGroup(String groupName)
  +        throws Exception
  +    {
  +        return getService().getGroup(groupName);
  +    }
  +    /**
  +     * Gets an instance of a named group either from the pool
  +     * or by calling the Factory Service if the pool is empty and
  +     * then initialize it using the ParameterParser looking for 
  +     * a NEW id.
  +     *
  +     * @param groupName the name of the group.
  +     * @param pp the request parameters that may contain matching keys
  +     * @return a Group instance.
  +     * @throws TurbineException if recycling fails.
  +     */
  +    public static Group getGroup(String groupName, ParameterParser pp)
  +        throws Exception
  +    {
  +        return getService().getGroup(groupName, pp);
  +    }
  +
  +    /**
  +     * Gets an instance of a named group either from the pool
  +     * or by calling the Factory Service if the pool is empty and
  +     * then initialize it using the ParameterParser looking for id.
  +     *
  +     * @param groupName the name of the group.
  +     * @param pp the request parameters that may contain matching keys
  +     * @return a Group instance.
        * @throws TurbineException if recycling fails.
        */
  -    public static Group getInstance(String groupName)
  +    public static Group getGroup(String groupName, 
  +                                 ParameterParser pp, String id)
           throws Exception
       {
  -        return getService().getInstance(groupName);
  +        return getService().getGroup(groupName, pp, id);
       }
   
       /**
  @@ -91,9 +125,9 @@
        * @param instance the object instance to recycle.
        * @return true if the instance was accepted.
        */
  -    public static boolean putInstance(Group instance)
  +    public static boolean releaseGroup(Group instance)
       {
  -        return getService().putInstance(instance);
  +        return getService().releaseGroup(instance);
       }
   
       /**
  @@ -155,6 +189,17 @@
       public static String getGroupKey(String groupName)
       {
           return getService().getGroupKey(groupName);
  +    }
  +
  +    /**
  +     * Gets an object that is used in templates to get groups.
  +     *
  +     * @param groupName the name of the group.
  +     * @return the the key.
  +     */
  +    public static Object getPuller(String groupName)
  +    {
  +        return getService().getPuller(groupName);
       }
   
       /**
  
  
  
  1.2       +71 -9     jakarta-turbine/src/java/org/apache/turbine/services/intake/TurbineIntakeService.java
  
  Index: TurbineIntakeService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine/src/java/org/apache/turbine/services/intake/TurbineIntakeService.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TurbineIntakeService.java	2001/03/09 11:38:05	1.1
  +++ TurbineIntakeService.java	2001/03/13 03:44:05	1.2
  @@ -73,15 +73,15 @@
    * on an XML specification.
    * 
    * @author <a href="mailto:jmcnally@collab.net">John McNally</a>
  - * @version $Id: TurbineIntakeService.java,v 1.1 2001/03/09 11:38:05 jmcnally Exp $
  + * @version $Id: TurbineIntakeService.java,v 1.2 2001/03/13 03:44:05 jmcnally Exp $
    */
   public class TurbineIntakeService
       extends TurbineBaseService
       implements IntakeService
   {
  -    private static final String XML_PATH = "xmlpath";
  +    private static final String XML_PATH = "xml.path";
   
  -    /** The cache of groups. **/
  +    /** The cache of group keys. **/
       private Map groupKeyMap;
   
       /** A cache of Retrievable objects, used by Fields to load values */
  @@ -126,12 +126,15 @@
               groupKeyMap = new HashMap();
               objectMap = new HashMap();
               String pkg = appData.getBasePackage();
  +            IntakeTool it = new IntakeTool();
   
               Iterator iter = appData.getGroups().iterator();            
               while ( iter.hasNext() ) 
               {
                   XmlGroup g = (XmlGroup)iter.next();
  -                groupKeyMap.put(g.getName(), g.getKey());
  +                String groupName = g.getName();
  +                groupKeyMap.put(groupName, g.getKey());
  +                it.addPuller( groupName );
   
                   List classNames = g.getMapToObjects();
                   Iterator iter2 = classNames.iterator();
  @@ -250,24 +253,71 @@
        * or by calling the Factory Service if the pool is empty.
        *
        * @param groupName the name of the group.
  -     * @return the instance.
  +     * @return a Group instance.
        * @throws TurbineException if recycling fails.
        */
  -    public Group getInstance(String groupName)
  +    public Group getGroup(String groupName)
           throws Exception
       {
           Group instance = (Group)pollInstance(groupName);
  -        return instance == null ?
  -            new Group( appData.getGroup(groupName) ) : instance;
  +        if ( instance == null ) 
  +        {
  +            appData.getGroup(groupName);
  +        }
  +        return instance;
  +    }
  +    /**
  +     * Gets an instance of a named group either from the pool
  +     * or by calling the Factory Service if the pool is empty and
  +     * then initialize it using the ParameterParser looking for 
  +     * a NEW id.
  +     *
  +     * @param groupName the name of the group.
  +     * @param pp the request parameters that may contain matching keys
  +     * @return a Group instance.
  +     * @throws TurbineException if recycling fails.
  +     */
  +    public Group getGroup(String groupName, ParameterParser pp)
  +        throws Exception
  +    {
  +        Group instance = (Group)pollInstance(groupName);
  +        if ( instance == null ) 
  +        {
  +            appData.getGroup(groupName);
  +        }
  +        instance.init(pp);
  +        return instance;
       }
   
       /**
  +     * Gets an instance of a named group either from the pool
  +     * or by calling the Factory Service if the pool is empty and
  +     * then initialize it using the ParameterParser looking for id.
  +     *
  +     * @param groupName the name of the group.
  +     * @param pp the request parameters that may contain matching keys
  +     * @return a Group instance.
  +     * @throws TurbineException if recycling fails.
  +     */
  +    public Group getGroup(String groupName, ParameterParser pp, String id)
  +        throws Exception
  +    {
  +        Group instance = (Group)pollInstance(groupName);
  +        if ( instance == null ) 
  +        {
  +            appData.getGroup(groupName);
  +        }
  +        instance.init(id, pp);
  +        return instance;
  +    }
  +
  +    /**
        * Puts a Group back to the pool.
        *
        * @param instance the object instance to recycle.
        * @return true if the instance was accepted.
        */
  -    public boolean putInstance(Group instance)
  +    public boolean releaseGroup(Group instance)
       {
           if (instance != null)
           {
  @@ -395,6 +445,18 @@
       public String getGroupKey(String groupName)
       {
           return (String)groupKeyMap.get(groupName);
  +    }
  +
  +    /**
  +     * Gets an object that is used in templates to get groups.
  +     *
  +     * @param groupName the name of the group.
  +     * @return the the key.
  +     */
  +    public Object getPuller(String groupName)
  +    {
  +        // remove this method
  +        return null;
       }
   
       /**
  
  
  
  1.1                  jakarta-turbine/src/java/org/apache/turbine/services/intake/IntakeTool.java
  
  Index: IntakeTool.java
  ===================================================================
  package org.apache.turbine.services.intake;
  
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and 
   *    "Apache Turbine" must not be used to endorse or promote products 
   *    derived from this software without prior written permission. For 
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Turbine", nor may "Apache" appear in their name, without 
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  // JDK classes
  import java.util.*;
  
  // Turbine classes
  import org.apache.turbine.util.RunData;
  import org.apache.turbine.util.StringUtils;
  import org.apache.turbine.util.ParameterParser;
  import org.apache.turbine.util.Log;
  import org.apache.turbine.util.TurbineException;
  import org.apache.turbine.services.intake.model.*;
  import org.apache.turbine.services.pull.ApplicationTool;
  import org.apache.turbine.util.pool.Recyclable;
  
  public class IntakeTool 
      implements ApplicationTool, Recyclable
  {
      private RunData data;
      private HashMap groups;
  
      /** The cache of PullHelpers. **/
      private static Map pullMap = new HashMap();
  
      public IntakeTool()
      {
          groups = new HashMap();
      }
  
      /**
       * Prepares intake for a single request
       */
      public void init(Object runData)
      {
          data = (RunData)runData;
      }
  
      /**
       * Implementation of ApplicationTool interface is not needed for this
       * tool as it is request scoped
       */
      public void refresh()
      {
          // empty
      }
  
      /**
       * Inner class to present a nice interface to the template designer
       */
      private class PullHelper
      {
          String groupName;
  
          private PullHelper(String groupName)
          {
              this.groupName = groupName;
          }
  
          public Group setKey(String key)
              throws Exception
          {
              Group g = null;
  
              String inputKey = TurbineIntake.getGroupKey(groupName) + key;
              if ( groups.containsKey(inputKey)) 
              {
                  g = (Group)groups.get(inputKey);
              }
              else 
              {
                  g = TurbineIntake.getGroup(groupName, 
                                             data.getParameters(), key);
                  groups.put(inputKey, g);
              }
  
              return g;
          }
      }
      
      /**
       * Used by the service to populate pullMap
       * @param groupName  groupName to key pullMap.
       * @param v  Value to assign to puller.
       */
      void addPuller(String groupName) 
      {
          pullMap.put(groupName, new IntakeTool.PullHelper(groupName));
      }
      
      
      public Object get(String groupName)
          throws Exception
      {
          return pullMap.get(groupName);
      }
  
  
      /*
      public Group get(String groupName)
          throws Exception
      {
          return get(groupName, Group.NEW);
      }
  
      public Group get(String groupName, String key)
          throws Exception
      {
          Group g = null;
  
          String inputKey = TurbineIntake.getGroupKey(groupName) + key;
          if ( groups.containsKey(inputKey)) 
          {
              g = (Group)groups.get(inputKey);
          }
          else 
          {
              g = TurbineIntake.getGroup(groupName, data.getParameters(), key);
              groups.put(inputKey, g);
          }
  
          return g;
      }
      */
  
  
      // ****************** Recyclable implementation ************************
  
      private boolean disposed;
  
      /**
       * Recycles the object for a new client. Recycle methods with
       * parameters must be added to implementing object and they will be
       * automatically called by pool implementations when the object is
       * taken from the pool for a new client. The parameters must
       * correspond to the parameters of the constructors of the object.
       * For new objects, constructors can call their corresponding recycle
       * methods whenever applicable.
       * The recycle methods must call their super.
       */
      public void recycle()
      {
          disposed = false;
      }
  
      /**
       * Disposes the object after use. The method is called
       * when the object is returned to its pool.
       * The dispose method must call its super.
       */
      public void dispose()
      {
          Iterator iter = groups.values().iterator();
          while ( iter.hasNext() ) 
          {
              Group g = (Group)iter.next();
              TurbineIntake.releaseGroup(g);
          }
  
          groups.clear(); 
          data = null;
  
          disposed = true;
      }
  
      /**
       * Checks whether the recyclable has been disposed.
       * @return true, if the recyclable is disposed.
       */
      public boolean isDisposed()
      {
          return disposed;
      }
  
  
  }
  
  
  
  
  
  
  
  
  
  1.2       +55 -0     jakarta-turbine/src/java/org/apache/turbine/services/intake/model/BigDecimalField.java
  
  Index: BigDecimalField.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine/src/java/org/apache/turbine/services/intake/model/BigDecimalField.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- BigDecimalField.java	2001/03/09 11:38:07	1.1
  +++ BigDecimalField.java	2001/03/13 03:44:05	1.2
  @@ -1,5 +1,59 @@
   package org.apache.turbine.services.intake.model;
   
  +/* ====================================================================
  + * The Apache Software License, Version 1.1
  + *
  + * Copyright (c) 2001 The Apache Software Foundation.  All rights
  + * reserved.
  + *
  + * Redistribution and use in source and binary forms, with or without
  + * modification, are permitted provided that the following conditions
  + * are met:
  + *
  + * 1. Redistributions of source code must retain the above copyright
  + *    notice, this list of conditions and the following disclaimer.
  + *
  + * 2. Redistributions in binary form must reproduce the above copyright
  + *    notice, this list of conditions and the following disclaimer in
  + *    the documentation and/or other materials provided with the
  + *    distribution.
  + *
  + * 3. The end-user documentation included with the redistribution,
  + *    if any, must include the following acknowledgment:
  + *       "This product includes software developed by the
  + *        Apache Software Foundation (http://www.apache.org/)."
  + *    Alternately, this acknowledgment may appear in the software itself,
  + *    if and wherever such third-party acknowledgments normally appear.
  + *
  + * 4. The names "Apache" and "Apache Software Foundation" and 
  + *    "Apache Turbine" must not be used to endorse or promote products 
  + *    derived from this software without prior written permission. For 
  + *    written permission, please contact apache@apache.org.
  + *
  + * 5. Products derived from this software may not be called "Apache",
  + *    "Apache Turbine", nor may "Apache" appear in their name, without 
  + *    prior written permission of the Apache Software Foundation.
  + *
  + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  + * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  + * SUCH DAMAGE.
  + * ====================================================================
  + *
  + * This software consists of voluntary contributions made by many
  + * individuals on behalf of the Apache Software Foundation.  For more
  + * information on the Apache Software Foundation, please see
  + * <http://www.apache.org/>.
  + */
  +
   // JDK classes
   import java.util.*;
   import java.beans.*;
  @@ -16,6 +70,7 @@
   import org.apache.turbine.util.Log;
   import org.apache.turbine.util.TurbineException;
   import org.apache.turbine.services.intake.xmlmodel.*;
  +import org.apache.turbine.services.intake.*;
   
   
   /**  */
  
  
  
  1.2       +14 -1     jakarta-turbine/src/java/org/apache/turbine/services/intake/model/Field.java
  
  Index: Field.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine/src/java/org/apache/turbine/services/intake/model/Field.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Field.java	2001/03/09 11:38:08	1.1
  +++ Field.java	2001/03/13 03:44:05	1.2
  @@ -76,7 +76,7 @@
    * Base class for Intake generated input processing classes.
    *
    * @author <a href="mailto:jmcnally@collab.net>John McNally</a>
  - * @version $Id: Field.java,v 1.1 2001/03/09 11:38:08 jmcnally Exp $
  + * @version $Id: Field.java,v 1.2 2001/03/13 03:44:05 jmcnally Exp $
    */
   public abstract class Field
   {
  @@ -242,6 +242,19 @@
               // iv.reconcileNotPresent();
           }
           return this;
  +    }
  +
  +    /**
  +     * Disposes the object after use. The method is called
  +     * when the Group is returned to its pool.
  +     * if overridden, super.dispose() should be called.
  +     */
  +    public void dispose()
  +    {
  +        set_flag = false;
  +        valid_flag = false;
  +        message = null;
  +        iv.dispose();
       }
   
       protected IntakeValue getNewIntakeValue(String property)
  
  
  
  1.2       +2 -1      jakarta-turbine/src/java/org/apache/turbine/services/intake/model/FieldFactory.java
  
  Index: FieldFactory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine/src/java/org/apache/turbine/services/intake/model/FieldFactory.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- FieldFactory.java	2001/03/09 11:38:08	1.1
  +++ FieldFactory.java	2001/03/13 03:44:06	1.2
  @@ -66,13 +66,14 @@
   import org.apache.turbine.util.Log;
   import org.apache.turbine.util.TurbineException;
   import org.apache.turbine.services.intake.xmlmodel.*;
  +import org.apache.turbine.services.intake.*;
   
   
   /**
    * Creates Field objects.
    *
    * @author <a href="mailto:jmcnally@collab.net>John McNally</a>
  - * @version $Id: FieldFactory.java,v 1.1 2001/03/09 11:38:08 jmcnally Exp $
  + * @version $Id: FieldFactory.java,v 1.2 2001/03/13 03:44:06 jmcnally Exp $
    */
   public abstract class FieldFactory
   {
  
  
  
  1.2       +189 -3    jakarta-turbine/src/java/org/apache/turbine/services/intake/model/Group.java
  
  Index: Group.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine/src/java/org/apache/turbine/services/intake/model/Group.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Group.java	2001/03/09 11:38:09	1.1
  +++ Group.java	2001/03/13 03:44:06	1.2
  @@ -1,5 +1,59 @@
   package org.apache.turbine.services.intake.model;
   
  +/* ====================================================================
  + * The Apache Software License, Version 1.1
  + *
  + * Copyright (c) 2001 The Apache Software Foundation.  All rights
  + * reserved.
  + *
  + * Redistribution and use in source and binary forms, with or without
  + * modification, are permitted provided that the following conditions
  + * are met:
  + *
  + * 1. Redistributions of source code must retain the above copyright
  + *    notice, this list of conditions and the following disclaimer.
  + *
  + * 2. Redistributions in binary form must reproduce the above copyright
  + *    notice, this list of conditions and the following disclaimer in
  + *    the documentation and/or other materials provided with the
  + *    distribution.
  + *
  + * 3. The end-user documentation included with the redistribution,
  + *    if any, must include the following acknowledgment:
  + *       "This product includes software developed by the
  + *        Apache Software Foundation (http://www.apache.org/)."
  + *    Alternately, this acknowledgment may appear in the software itself,
  + *    if and wherever such third-party acknowledgments normally appear.
  + *
  + * 4. The names "Apache" and "Apache Software Foundation" and 
  + *    "Apache Turbine" must not be used to endorse or promote products 
  + *    derived from this software without prior written permission. For 
  + *    written permission, please contact apache@apache.org.
  + *
  + * 5. Products derived from this software may not be called "Apache",
  + *    "Apache Turbine", nor may "Apache" appear in their name, without 
  + *    prior written permission of the Apache Software Foundation.
  + *
  + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  + * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  + * SUCH DAMAGE.
  + * ====================================================================
  + *
  + * This software consists of voluntary contributions made by many
  + * individuals on behalf of the Apache Software Foundation.  For more
  + * information on the Apache Software Foundation, please see
  + * <http://www.apache.org/>.
  + */
  +
   // JDK classes
   import java.util.*;
   import java.beans.*;
  @@ -14,19 +68,61 @@
   import org.apache.turbine.util.TurbineException;
   import org.apache.turbine.services.intake.xmlmodel.*;
   import org.apache.turbine.services.intake.*;
  +import org.apache.turbine.util.pool.Recyclable;
   
   /** Holds a group of Fields */
   public class Group
  +    implements Recyclable
   {
  +
  +    /*
  +     * An id representing a new object.
  +     */
       public static final String NEW = "0";
  +
  +    /**
  +     * The key used to represent this group in a parameter.
  +     * This key is usually a prefix as part of a field key.
  +     */
       public final String cid;
  +
  +    /**
  +     * The name used in templates and java code to refer to this group.
  +     */
       public final String name;
  +
  +    /**
  +     * The number of Groups with the same name that will be pooled.
  +     */
       public final int poolCapacity;
  +
  +    /**
  +     * A map of the fields in this group mapped by field name.
  +     */
       public final Map fields;
  +
  +    /**
  +     * An array of fields in this group.
  +     */
       public final Field[] fieldsArray;
   
  -    protected String oid;
  +    /**
  +     * The object id used to associate this group to a bean
  +     * for one request cycle
  +     */
  +    protected String oid;    
   
  +    /**
  +     * Constructs a new Group based on the xml specification.  Groups are
  +     * instantiated and pooled by the IntakeService and should not
  +     * be instantiated otherwise.
  +     *
  +     * @param group a <code>XmlGroup</code> value
  +     * @exception RESyntaxException if an error occurs
  +     * @exception ClassNotFoundException if an error occurs
  +     * @exception IntrospectionException if an error occurs
  +     * @exception TurbineException if an error occurs
  +     */
       public Group(XmlGroup group)
           throws RESyntaxException, ClassNotFoundException,
                  IntrospectionException, TurbineException
  @@ -48,11 +144,24 @@
           }
       } 
          
  +    /**
  +     * Describe <code>init</code> method here.
  +     *
  +     * @param pp a <code>ParameterParser</code> value
  +     * @return a <code>Group</code> value
  +     */
       public Group init(ParameterParser pp)
       {
           return init(NEW, pp);
       }
   
  +    /**
  +     * Describe <code>init</code> method here.
  +     *
  +     * @param oid a <code>String</code> value
  +     * @param pp a <code>ParameterParser</code> value
  +     * @return a <code>Group</code> value
  +     */
       public Group init(String oid, ParameterParser pp)
       {
           this.oid = oid;
  @@ -63,26 +172,53 @@
           return this;
       }
   
  +    /**
  +     * Describe <code>getName</code> method here.
  +     *
  +     * @return a <code>String</code> value
  +     */
       public String getName()
       {
           return name;
       }
   
  +    /**
  +     * Describe <code>getPoolCapacity</code> method here.
  +     *
  +     * @return an <code>int</code> value
  +     */
       public int getPoolCapacity()
       {
           return poolCapacity;
       }
   
  +    /**
  +     * Describe <code>getCID</code> method here.
  +     *
  +     * @return a <code>String</code> value
  +     */
       public String getCID()
       {
           return cid;
       }
   
  +    /**
  +     * Describe <code>getObjectKey</code> method here.
  +     *
  +     * @return a <code>String</code> value
  +     */
       public String getObjectKey()
       {
           return cid + oid;
       }
   
  +    /**
  +     * Describe <code>getObjects</code> method here.
  +     *
  +     * @param pp a <code>ParameterParser</code> value
  +     * @return an <code>ArrayList</code> value
  +     * @exception Exception if an error occurs
  +     */
       public ArrayList getObjects(ParameterParser pp)
           throws Exception
       {
  @@ -93,7 +229,7 @@
               objs = new ArrayList(oids.length);
               for (int i=oids.length-1; i>=0; i--)
               {
  -                objs.add( TurbineIntake.getInstance(name).init(oids[i], pp) );
  +                objs.add( TurbineIntake.getGroup(name).init(oids[i], pp) );
               }
           }
           return objs;
  @@ -108,6 +244,11 @@
           return (Field)fields.get(fieldName);
       }
   
  +    /**
  +     * Describe <code>isAllValid</code> method here.
  +     *
  +     * @return a <code>boolean</code> value
  +     */
       public boolean isAllValid()
       {
           boolean valid = true;
  @@ -120,7 +261,7 @@
   
       /**
        * Calls a setter methods on obj, for fields which have been set.
  -     * @exception throws up any Exceptions resulting from failure to 
  +     * @exception throws up any exceptions resulting from failure to 
        * check input validity.
        */
       public void setProperties(Object obj) 
  @@ -133,6 +274,51 @@
                   fieldsArray[i].getValue().setProperty(obj);
               }
           }
  +    }
  +
  +
  +    // ****************** Recyclable implementation ************************
  +
  +    private boolean disposed;
  +
  +    /**
  +     * Recycles the object for a new client. Recycle methods with
  +     * parameters must be added to implementing object and they will be
  +     * automatically called by pool implementations when the object is
  +     * taken from the pool for a new client. The parameters must
  +     * correspond to the parameters of the constructors of the object.
  +     * For new objects, constructors can call their corresponding recycle
  +     * methods whenever applicable.
  +     * The recycle methods must call their super.
  +     */
  +    public void recycle()
  +    {
  +        disposed = false;
  +    }
  +
  +    /**
  +     * Disposes the object after use. The method is called
  +     * when the object is returned to its pool.
  +     * The dispose method must call its super.
  +     */
  +    public void dispose()
  +    {
  +        oid = null;
  +        for (int i=fieldsArray.length-1; i>=0; i--) 
  +        {
  +            fieldsArray[i].dispose();
  +        }
  +
  +        disposed = true;
  +    }
  +
  +    /**
  +     * Checks whether the recyclable has been disposed.
  +     * @return true, if the recyclable is disposed.
  +     */
  +    public boolean isDisposed()
  +    {
  +        return disposed;
       }
   }
   
  
  
  
  1.2       +13 -1     jakarta-turbine/src/java/org/apache/turbine/services/intake/model/IntakeValue.java
  
  Index: IntakeValue.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine/src/java/org/apache/turbine/services/intake/model/IntakeValue.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- IntakeValue.java	2001/03/09 11:38:09	1.1
  +++ IntakeValue.java	2001/03/13 03:44:06	1.2
  @@ -69,7 +69,7 @@
    * dealing with a parameter value
    *
    * @author <a href="mailto:jmcnally@collab.net>John McNally</a>
  - * @version $Id: IntakeValue.java,v 1.1 2001/03/09 11:38:09 jmcnally Exp $
  + * @version $Id: IntakeValue.java,v 1.2 2001/03/13 03:44:06 jmcnally Exp $
    */
   public final class IntakeValue
   {
  @@ -85,6 +85,18 @@
           this.field = field;
           this.propertyName = propertyName;
           valArray = new Object[1];
  +    }
  +
  +    /**
  +     * Disposes the object after use. The method is called
  +     * when the Group is returned to its pool.
  +     * if overridden, super.dispose() should be called.
  +     */
  +    public void dispose()
  +    {
  +        validValue = null;
  +        testValue = null;
  +        valArray[0] = null;
       }
   
       void setValidValue(Object obj)
  
  
  
  1.2       +55 -0     jakarta-turbine/src/java/org/apache/turbine/services/intake/model/IntegerField.java
  
  Index: IntegerField.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine/src/java/org/apache/turbine/services/intake/model/IntegerField.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- IntegerField.java	2001/03/09 11:38:09	1.1
  +++ IntegerField.java	2001/03/13 03:44:06	1.2
  @@ -1,5 +1,59 @@
   package org.apache.turbine.services.intake.model;
   
  +/* ====================================================================
  + * The Apache Software License, Version 1.1
  + *
  + * Copyright (c) 2001 The Apache Software Foundation.  All rights
  + * reserved.
  + *
  + * Redistribution and use in source and binary forms, with or without
  + * modification, are permitted provided that the following conditions
  + * are met:
  + *
  + * 1. Redistributions of source code must retain the above copyright
  + *    notice, this list of conditions and the following disclaimer.
  + *
  + * 2. Redistributions in binary form must reproduce the above copyright
  + *    notice, this list of conditions and the following disclaimer in
  + *    the documentation and/or other materials provided with the
  + *    distribution.
  + *
  + * 3. The end-user documentation included with the redistribution,
  + *    if any, must include the following acknowledgment:
  + *       "This product includes software developed by the
  + *        Apache Software Foundation (http://www.apache.org/)."
  + *    Alternately, this acknowledgment may appear in the software itself,
  + *    if and wherever such third-party acknowledgments normally appear.
  + *
  + * 4. The names "Apache" and "Apache Software Foundation" and 
  + *    "Apache Turbine" must not be used to endorse or promote products 
  + *    derived from this software without prior written permission. For 
  + *    written permission, please contact apache@apache.org.
  + *
  + * 5. Products derived from this software may not be called "Apache",
  + *    "Apache Turbine", nor may "Apache" appear in their name, without 
  + *    prior written permission of the Apache Software Foundation.
  + *
  + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  + * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  + * SUCH DAMAGE.
  + * ====================================================================
  + *
  + * This software consists of voluntary contributions made by many
  + * individuals on behalf of the Apache Software Foundation.  For more
  + * information on the Apache Software Foundation, please see
  + * <http://www.apache.org/>.
  + */
  +
   // JDK classes
   import java.util.*;
   import java.beans.*;
  @@ -15,6 +69,7 @@
   import org.apache.turbine.util.Log;
   import org.apache.turbine.util.TurbineException;
   import org.apache.turbine.services.intake.xmlmodel.*;
  +import org.apache.turbine.services.intake.*;
   
   
   /**  */
  
  
  
  1.2       +56 -1     jakarta-turbine/src/java/org/apache/turbine/services/intake/model/StringField.java
  
  Index: StringField.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine/src/java/org/apache/turbine/services/intake/model/StringField.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- StringField.java	2001/03/09 11:38:09	1.1
  +++ StringField.java	2001/03/13 03:44:06	1.2
  @@ -1,5 +1,59 @@
   package org.apache.turbine.services.intake.model;
   
  +/* ====================================================================
  + * The Apache Software License, Version 1.1
  + *
  + * Copyright (c) 2001 The Apache Software Foundation.  All rights
  + * reserved.
  + *
  + * Redistribution and use in source and binary forms, with or without
  + * modification, are permitted provided that the following conditions
  + * are met:
  + *
  + * 1. Redistributions of source code must retain the above copyright
  + *    notice, this list of conditions and the following disclaimer.
  + *
  + * 2. Redistributions in binary form must reproduce the above copyright
  + *    notice, this list of conditions and the following disclaimer in
  + *    the documentation and/or other materials provided with the
  + *    distribution.
  + *
  + * 3. The end-user documentation included with the redistribution,
  + *    if any, must include the following acknowledgment:
  + *       "This product includes software developed by the
  + *        Apache Software Foundation (http://www.apache.org/)."
  + *    Alternately, this acknowledgment may appear in the software itself,
  + *    if and wherever such third-party acknowledgments normally appear.
  + *
  + * 4. The names "Apache" and "Apache Software Foundation" and 
  + *    "Apache Turbine" must not be used to endorse or promote products 
  + *    derived from this software without prior written permission. For 
  + *    written permission, please contact apache@apache.org.
  + *
  + * 5. Products derived from this software may not be called "Apache",
  + *    "Apache Turbine", nor may "Apache" appear in their name, without 
  + *    prior written permission of the Apache Software Foundation.
  + *
  + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  + * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  + * SUCH DAMAGE.
  + * ====================================================================
  + *
  + * This software consists of voluntary contributions made by many
  + * individuals on behalf of the Apache Software Foundation.  For more
  + * information on the Apache Software Foundation, please see
  + * <http://www.apache.org/>.
  + */
  +
   // JDK classes
   import java.util.*;
   import java.beans.*;
  @@ -14,13 +68,14 @@
   import org.apache.turbine.util.Log;
   import org.apache.turbine.util.TurbineException;
   import org.apache.turbine.services.intake.xmlmodel.*;
  +import org.apache.turbine.services.intake.*;
   
   
   /**
    * Base class for Intake generated input processing classes.
    *
    * @author <a href="mailto:jmcnally@collab.net>John McNally</a>
  - * @version $Id: StringField.java,v 1.1 2001/03/09 11:38:09 jmcnally Exp $
  + * @version $Id: StringField.java,v 1.2 2001/03/13 03:44:06 jmcnally Exp $
    */
   public class StringField extends Field
   {    
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org