You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by jv...@apache.org on 2001/06/20 20:02:38 UTC

cvs commit: jakarta-turbine/src/java/org/apache/turbine/services/pool/util ArrayCtorRecyclable.java BoundedBuffer.java InitableRecyclable.java ObjectInputStreamForContext.java Recyclable.java RecyclableSupport.java

jvanzyl     01/06/20 11:02:38

  Added:       src/java/org/apache/turbine/services/pool/util
                        ArrayCtorRecyclable.java BoundedBuffer.java
                        InitableRecyclable.java
                        ObjectInputStreamForContext.java Recyclable.java
                        RecyclableSupport.java
  Log:
  - these are the real pool utility classes, proxies have been
    left in the util package for backward compatibility and
    have been deprecated.
  
  Revision  Changes    Path
  1.1                  jakarta-turbine/src/java/org/apache/turbine/services/pool/util/ArrayCtorRecyclable.java
  
  Index: ArrayCtorRecyclable.java
  ===================================================================
  package org.apache.turbine.services.pool.util;
  
  /* ====================================================================
   * 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/>.
   */
  
  /**
   * An interface for objects that can be pooled and
   * recycled several times by different clients.  This interface
   * presents a recycle method that does not require introspection/reflection.
   *
   * @author <a href="mailto:jmcnally@collab.net">John McNally</a>
   * @version $Id: ArrayCtorRecyclable.java,v 1.1 2001/06/20 18:02:37 jvanzyl Exp $
   */
  public interface ArrayCtorRecyclable extends Recyclable
  {
      /**
       * Recycles the object for a new client. Objects implementing
       * this interface must also provide a matching constructor.
       * The recycle methods must call their super.
       */
      public void recycle(Object[] params);
  }
  
  
  
  1.1                  jakarta-turbine/src/java/org/apache/turbine/services/pool/util/BoundedBuffer.java
  
  Index: BoundedBuffer.java
  ===================================================================
  package org.apache.turbine.services.pool.util;
  
  /* ====================================================================
   * 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/>.
   */
  
  /**
   * Efficient array-based bounded buffer class.
   * Adapted from CPJ, chapter 8, which describes design.
   * Originally written by Doug Lea and released into the public domain.
   * <p>[<a href="http://gee.cs.oswego.edu/dl/classes/EDU/oswego/cs/dl/util/concurrent/intro.html"> Introduction to this package. </a>] <p>
   *
   * @author <a href="mailto:ilkka.priha@simsoft.fi">Ilkka Priha</a>
   * @version $Id: BoundedBuffer.java,v 1.1 2001/06/20 18:02:37 jvanzyl Exp $
   */
  public class BoundedBuffer
  {
      /**
       * The default capacity.
       */
      public static final int DEFAULT_CAPACITY = 1024;
  
      protected final Object[]  array_;      // the elements
  
      protected int takePtr_ = 0;            // circular indices
      protected int putPtr_ = 0;
  
      protected int usedSlots_ = 0;          // length
      protected int emptySlots_;             // capacity - length
  
      /**
       * Creates a buffer with the given capacity.
       *
       * @param capacity the capacity.
       * @throws IllegalArgumentException if capacity less or equal to zero.
       */
      public BoundedBuffer(int capacity)
                           throws IllegalArgumentException
      {
          if (capacity <= 0)
             throw new IllegalArgumentException();
  
          array_ = new Object[capacity];
          emptySlots_ = capacity;
      }
  
      /**
       * Creates a buffer with the default capacity
       */
      public BoundedBuffer()
      {
          this(DEFAULT_CAPACITY);
      }
  
      /**
       * Returns the number of elements in the buffer.
       * This is only a snapshot value, that may change
       * immediately after returning.
       *
       * @return the size.
       */
      public synchronized int size()
      {
          return usedSlots_;
      }
  
      /**
       * Returns the capacity of the buffer.
       *
       * @return the capacity.
       */
      public int capacity()
      {
          return array_.length;
      }
  
      /**
       * Peeks, but does not remove the top item from the buffer.
       *
       * @return the object or null.
       */
      public synchronized Object peek()
      {
          if (usedSlots_ > 0)
              return array_[takePtr_];
          else
              return null;
      }
  
      /**
       * Puts an item in the buffer only if there is capacity available.
       *
       * @param item the item to be inserted.
       * @return true if accepted, else false.
       */
      public synchronized boolean offer(Object x)
      {
          if (x == null)
              throw new IllegalArgumentException();
  
          if (emptySlots_ > 0)
          {
              --emptySlots_;
              array_[putPtr_] = x;
              if (++putPtr_ >= array_.length)
                  putPtr_ = 0;
              usedSlots_++;
              return true;
          }
          else
              return false;
      }
  
      /**
       * Polls and removes the top item from the buffer if one is available.
       *
       * @return the oldest item from the buffer, or null if the buffer is empty.
       */
      public synchronized Object poll()
      {
          if (usedSlots_ > 0)
          {
              --usedSlots_;
              Object old = array_[takePtr_];
              array_[takePtr_] = null;
              if (++takePtr_ >= array_.length)
                  takePtr_ = 0;
              emptySlots_++;
              return old;
          }
          else
              return null;
      }
  }
  
  
  
  1.1                  jakarta-turbine/src/java/org/apache/turbine/services/pool/util/InitableRecyclable.java
  
  Index: InitableRecyclable.java
  ===================================================================
  package org.apache.turbine.services.pool.util;
  
  /* ====================================================================
   * 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/>.
   */
  
  import org.apache.turbine.util.TurbineException;
  
  
  /**
   * An interface for objects that can be pooled and recycled several times 
   * by different clients.  Pooled objects that implement this interface
   * use no argument ctor and recycle methods.  Initialization is taken
   * care of using the init method.  This is a way to avoid 
   * introspection/reflection when pooling an object.
   *
   * @author <a href="mailto:jmcnally@collab.net">John McNally</a>
   * @version $Id: InitableRecyclable.java,v 1.1 2001/06/20 18:02:37 jvanzyl Exp $
   */
  public interface InitableRecyclable extends Recyclable
  {
      /**
       * This method should be called after retrieving the object from
       * the pool.
       */
      public void init(Object initObj) throws TurbineException;
  }
  
  
  
  1.1                  jakarta-turbine/src/java/org/apache/turbine/services/pool/util/ObjectInputStreamForContext.java
  
  Index: ObjectInputStreamForContext.java
  ===================================================================
  package org.apache.turbine.services.pool.util;
  
  /* ====================================================================
   * 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/>.
   */
  
  import java.io.InputStream;
  import java.io.ObjectInputStream;
  import java.io.ObjectStreamClass;
  import java.io.IOException;
  
  /**
   * A deserialization stream for a specific class loader context.
   *
   * @author <a href="mailto:ilkka.priha@simsoft.fi">Ilkka Priha</a>
   * @version $Id: ObjectInputStreamForContext.java,v 1.1 2001/06/20 18:02:38 jvanzyl Exp $
   */
  public class ObjectInputStreamForContext extends ObjectInputStream
  {
      /**
       * The class loader of the context.
       */
      private ClassLoader classLoader;
  
      // this is to make the proxy happy.
      public ObjectInputStreamForContext()
          throws IOException
      {
      }
  
      /**
       * Contructs a new object stream for a context.
       *
       * @param in the serialized input stream.
       * @param loader the class loader of the context.
       * @throws IOException on errors.
       */
      public  ObjectInputStreamForContext(InputStream in,
                                          ClassLoader loader)
                                          throws IOException
      {
          super(in);
          classLoader = loader;
      }
  
      protected Class resolveClass(ObjectStreamClass v)
                                   throws IOException,
                                   ClassNotFoundException
      {
          return classLoader == null ?
              super.resolveClass(v) : classLoader.loadClass(v.getName());
      }
  }
  
  
  
  1.1                  jakarta-turbine/src/java/org/apache/turbine/services/pool/util/Recyclable.java
  
  Index: Recyclable.java
  ===================================================================
  package org.apache.turbine.services.pool.util;
  
  /* ====================================================================
   * 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/>.
   */
  
  /**
   * An interface for objects that can be pooled and
   * recycled several times by different clients.
   *
   * @author <a href="mailto:ilkka.priha@simsoft.fi">Ilkka Priha</a>
   * @version $Id: Recyclable.java,v 1.1 2001/06/20 18:02:38 jvanzyl Exp $
   */
  public interface Recyclable
  {
      /**
       * 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();
  
      /**
       * 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();
  
      /**
       * Checks whether the recyclable has been disposed.
       * @return true, if the recyclable is disposed.
       */
      public boolean isDisposed();
  }
  
  
  
  1.1                  jakarta-turbine/src/java/org/apache/turbine/services/pool/util/RecyclableSupport.java
  
  Index: RecyclableSupport.java
  ===================================================================
  package org.apache.turbine.services.pool.util;
  
  /* ====================================================================
   * 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/>.
   */
  
  import org.apache.turbine.services.pool.TurbinePool;
  
  /**
   * A support class for recyclable objects implementing default methods.
   *
   * @author <a href="mailto:ilkka.priha@simsoft.fi">Ilkka Priha</a>
   * @version $Id: RecyclableSupport.java,v 1.1 2001/06/20 18:02:38 jvanzyl Exp $
   */
  public class RecyclableSupport implements Recyclable
  {
      /**
       * The disposed flag.
       */
      private boolean disposed;
  
      /**
       * Constructs a new recyclable support and calls the default recycle method.
       */
      public void Recyclable()
      {
          recycle();
      }
  
      /**
       * Recycles the object by removing its disposed flag.
       */
      public void recycle()
      {
          disposed = false;
      }
  
      /**
       * Disposes the object by setting its disposed flag.
       */
      public void dispose()
      {
          disposed = true;
      }
  
      /**
       * Checks whether the object is disposed.
       *
       * @return true, if the object is disposed.
       */
      public boolean isDisposed()
      {
          return disposed;
      }
      
      /**
       * A convenience method allowing a clever recyclable object 
       * to put itself into a pool for recycling.
       * 
       * @return true, if disposal was accepted by the pool.
       */
      protected boolean doDispose()
      {
          try
          {
              return TurbinePool.putInstance(this);
          }
          catch (RuntimeException x)
          {
              return false;
          }
      }
  }
  
  
  

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


Re: cvs commit: jakarta-turbine/src/java/org/apache/turbine/services/pool/util ArrayCtorRecyclable.java BoundedBuffer.java InitableRecyclable.java ObjectInputStreamForContext.java Recyclable.java RecyclableSupport.java

Posted by Jason van Zyl <jv...@apache.org>.
On 6/20/01 7:04 PM, "Daniel Rall" <dl...@finemaltcoding.com> wrote:

> Why are these in a util sub-package?

Because they were in a util package, just as all the other ancillary
service code is for the other services.

I think the service code is distinct i.e. the three files that
usually make up a service implementation. Code the service uses
to function has up until this point been placed in a separate
util package: within the service itself or in turbine's util package.

I also like the separate package because some of this utility code
is being used solely by the service but it might be possible to
move these util packages to the commons eventually.

If a service requires dozens of utility classes I think it
makes a mess having them all in the same package.

> They should be in the same
> package as the rest of the service (for reasons already stated).

Why? Where are the reasons, I must have missed them.
 
> Dan
> 
> jvanzyl@apache.org writes:
> 


-- 

jvz.

http://tambora.zenplex.org
http://jakarta.apache.org/turbine
http://jakarta.apache.org/velocity
http://jakarta.apache.org/alexandria
http://jakarta.apache.org/commons



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


Re: cvs commit: jakarta-turbine/src/java/org/apache/turbine/services/pool/util ArrayCtorRecyclable.java BoundedBuffer.java InitableRecyclable.java ObjectInputStreamForContext.java Recyclable.java RecyclableSupport.java

Posted by Daniel Rall <dl...@finemaltcoding.com>.
Why are these in a util sub-package?  They should be in the same
package as the rest of the service (for reasons already stated).

Dan

jvanzyl@apache.org writes:

> jvanzyl     01/06/20 11:02:38
> 
>   Added:       src/java/org/apache/turbine/services/pool/util
>                         ArrayCtorRecyclable.java BoundedBuffer.java
>                         InitableRecyclable.java
>                         ObjectInputStreamForContext.java Recyclable.java
>                         RecyclableSupport.java
>   Log:
>   - these are the real pool utility classes, proxies have been
>     left in the util package for backward compatibility and
>     have been deprecated.
>   
>   Revision  Changes    Path
>   1.1                  jakarta-turbine/src/java/org/apache/turbine/services/pool/util/ArrayCtorRecyclable.java
>   
>   Index: ArrayCtorRecyclable.java
>   ===================================================================
>   package org.apache.turbine.services.pool.util;
>   
>   /* ====================================================================
>    * 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/>.
>    */
>   
>   /**
>    * An interface for objects that can be pooled and
>    * recycled several times by different clients.  This interface
>    * presents a recycle method that does not require introspection/reflection.
>    *
>    * @author <a href="mailto:jmcnally@collab.net">John McNally</a>
>    * @version $Id: ArrayCtorRecyclable.java,v 1.1 2001/06/20 18:02:37 jvanzyl Exp $
>    */
>   public interface ArrayCtorRecyclable extends Recyclable
>   {
>       /**
>        * Recycles the object for a new client. Objects implementing
>        * this interface must also provide a matching constructor.
>        * The recycle methods must call their super.
>        */
>       public void recycle(Object[] params);
>   }
>   
>   
>   
>   1.1                  jakarta-turbine/src/java/org/apache/turbine/services/pool/util/BoundedBuffer.java
>   
>   Index: BoundedBuffer.java
>   ===================================================================
>   package org.apache.turbine.services.pool.util;
>   
>   /* ====================================================================
>    * 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/>.
>    */
>   
>   /**
>    * Efficient array-based bounded buffer class.
>    * Adapted from CPJ, chapter 8, which describes design.
>    * Originally written by Doug Lea and released into the public domain.
>    * <p>[<a href="http://gee.cs.oswego.edu/dl/classes/EDU/oswego/cs/dl/util/concurrent/intro.html"> Introduction to this package. </a>] <p>
>    *
>    * @author <a href="mailto:ilkka.priha@simsoft.fi">Ilkka Priha</a>
>    * @version $Id: BoundedBuffer.java,v 1.1 2001/06/20 18:02:37 jvanzyl Exp $
>    */
>   public class BoundedBuffer
>   {
>       /**
>        * The default capacity.
>        */
>       public static final int DEFAULT_CAPACITY = 1024;
>   
>       protected final Object[]  array_;      // the elements
>   
>       protected int takePtr_ = 0;            // circular indices
>       protected int putPtr_ = 0;
>   
>       protected int usedSlots_ = 0;          // length
>       protected int emptySlots_;             // capacity - length
>   
>       /**
>        * Creates a buffer with the given capacity.
>        *
>        * @param capacity the capacity.
>        * @throws IllegalArgumentException if capacity less or equal to zero.
>        */
>       public BoundedBuffer(int capacity)
>                            throws IllegalArgumentException
>       {
>           if (capacity <= 0)
>              throw new IllegalArgumentException();
>   
>           array_ = new Object[capacity];
>           emptySlots_ = capacity;
>       }
>   
>       /**
>        * Creates a buffer with the default capacity
>        */
>       public BoundedBuffer()
>       {
>           this(DEFAULT_CAPACITY);
>       }
>   
>       /**
>        * Returns the number of elements in the buffer.
>        * This is only a snapshot value, that may change
>        * immediately after returning.
>        *
>        * @return the size.
>        */
>       public synchronized int size()
>       {
>           return usedSlots_;
>       }
>   
>       /**
>        * Returns the capacity of the buffer.
>        *
>        * @return the capacity.
>        */
>       public int capacity()
>       {
>           return array_.length;
>       }
>   
>       /**
>        * Peeks, but does not remove the top item from the buffer.
>        *
>        * @return the object or null.
>        */
>       public synchronized Object peek()
>       {
>           if (usedSlots_ > 0)
>               return array_[takePtr_];
>           else
>               return null;
>       }
>   
>       /**
>        * Puts an item in the buffer only if there is capacity available.
>        *
>        * @param item the item to be inserted.
>        * @return true if accepted, else false.
>        */
>       public synchronized boolean offer(Object x)
>       {
>           if (x == null)
>               throw new IllegalArgumentException();
>   
>           if (emptySlots_ > 0)
>           {
>               --emptySlots_;
>               array_[putPtr_] = x;
>               if (++putPtr_ >= array_.length)
>                   putPtr_ = 0;
>               usedSlots_++;
>               return true;
>           }
>           else
>               return false;
>       }
>   
>       /**
>        * Polls and removes the top item from the buffer if one is available.
>        *
>        * @return the oldest item from the buffer, or null if the buffer is empty.
>        */
>       public synchronized Object poll()
>       {
>           if (usedSlots_ > 0)
>           {
>               --usedSlots_;
>               Object old = array_[takePtr_];
>               array_[takePtr_] = null;
>               if (++takePtr_ >= array_.length)
>                   takePtr_ = 0;
>               emptySlots_++;
>               return old;
>           }
>           else
>               return null;
>       }
>   }
>   
>   
>   
>   1.1                  jakarta-turbine/src/java/org/apache/turbine/services/pool/util/InitableRecyclable.java
>   
>   Index: InitableRecyclable.java
>   ===================================================================
>   package org.apache.turbine.services.pool.util;
>   
>   /* ====================================================================
>    * 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/>.
>    */
>   
>   import org.apache.turbine.util.TurbineException;
>   
>   
>   /**
>    * An interface for objects that can be pooled and recycled several times 
>    * by different clients.  Pooled objects that implement this interface
>    * use no argument ctor and recycle methods.  Initialization is taken
>    * care of using the init method.  This is a way to avoid 
>    * introspection/reflection when pooling an object.
>    *
>    * @author <a href="mailto:jmcnally@collab.net">John McNally</a>
>    * @version $Id: InitableRecyclable.java,v 1.1 2001/06/20 18:02:37 jvanzyl Exp $
>    */
>   public interface InitableRecyclable extends Recyclable
>   {
>       /**
>        * This method should be called after retrieving the object from
>        * the pool.
>        */
>       public void init(Object initObj) throws TurbineException;
>   }
>   
>   
>   
>   1.1                  jakarta-turbine/src/java/org/apache/turbine/services/pool/util/ObjectInputStreamForContext.java
>   
>   Index: ObjectInputStreamForContext.java
>   ===================================================================
>   package org.apache.turbine.services.pool.util;
>   
>   /* ====================================================================
>    * 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/>.
>    */
>   
>   import java.io.InputStream;
>   import java.io.ObjectInputStream;
>   import java.io.ObjectStreamClass;
>   import java.io.IOException;
>   
>   /**
>    * A deserialization stream for a specific class loader context.
>    *
>    * @author <a href="mailto:ilkka.priha@simsoft.fi">Ilkka Priha</a>
>    * @version $Id: ObjectInputStreamForContext.java,v 1.1 2001/06/20 18:02:38 jvanzyl Exp $
>    */
>   public class ObjectInputStreamForContext extends ObjectInputStream
>   {
>       /**
>        * The class loader of the context.
>        */
>       private ClassLoader classLoader;
>   
>       // this is to make the proxy happy.
>       public ObjectInputStreamForContext()
>           throws IOException
>       {
>       }
>   
>       /**
>        * Contructs a new object stream for a context.
>        *
>        * @param in the serialized input stream.
>        * @param loader the class loader of the context.
>        * @throws IOException on errors.
>        */
>       public  ObjectInputStreamForContext(InputStream in,
>                                           ClassLoader loader)
>                                           throws IOException
>       {
>           super(in);
>           classLoader = loader;
>       }
>   
>       protected Class resolveClass(ObjectStreamClass v)
>                                    throws IOException,
>                                    ClassNotFoundException
>       {
>           return classLoader == null ?
>               super.resolveClass(v) : classLoader.loadClass(v.getName());
>       }
>   }
>   
>   
>   
>   1.1                  jakarta-turbine/src/java/org/apache/turbine/services/pool/util/Recyclable.java
>   
>   Index: Recyclable.java
>   ===================================================================
>   package org.apache.turbine.services.pool.util;
>   
>   /* ====================================================================
>    * 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/>.
>    */
>   
>   /**
>    * An interface for objects that can be pooled and
>    * recycled several times by different clients.
>    *
>    * @author <a href="mailto:ilkka.priha@simsoft.fi">Ilkka Priha</a>
>    * @version $Id: Recyclable.java,v 1.1 2001/06/20 18:02:38 jvanzyl Exp $
>    */
>   public interface Recyclable
>   {
>       /**
>        * 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();
>   
>       /**
>        * 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();
>   
>       /**
>        * Checks whether the recyclable has been disposed.
>        * @return true, if the recyclable is disposed.
>        */
>       public boolean isDisposed();
>   }
>   
>   
>   
>   1.1                  jakarta-turbine/src/java/org/apache/turbine/services/pool/util/RecyclableSupport.java
>   
>   Index: RecyclableSupport.java
>   ===================================================================
>   package org.apache.turbine.services.pool.util;
>   
>   /* ====================================================================
>    * 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/>.
>    */
>   
>   import org.apache.turbine.services.pool.TurbinePool;
>   
>   /**
>    * A support class for recyclable objects implementing default methods.
>    *
>    * @author <a href="mailto:ilkka.priha@simsoft.fi">Ilkka Priha</a>
>    * @version $Id: RecyclableSupport.java,v 1.1 2001/06/20 18:02:38 jvanzyl Exp $
>    */
>   public class RecyclableSupport implements Recyclable
>   {
>       /**
>        * The disposed flag.
>        */
>       private boolean disposed;
>   
>       /**
>        * Constructs a new recyclable support and calls the default recycle method.
>        */
>       public void Recyclable()
>       {
>           recycle();
>       }
>   
>       /**
>        * Recycles the object by removing its disposed flag.
>        */
>       public void recycle()
>       {
>           disposed = false;
>       }
>   
>       /**
>        * Disposes the object by setting its disposed flag.
>        */
>       public void dispose()
>       {
>           disposed = true;
>       }
>   
>       /**
>        * Checks whether the object is disposed.
>        *
>        * @return true, if the object is disposed.
>        */
>       public boolean isDisposed()
>       {
>           return disposed;
>       }
>       
>       /**
>        * A convenience method allowing a clever recyclable object 
>        * to put itself into a pool for recycling.
>        * 
>        * @return true, if disposal was accepted by the pool.
>        */
>       protected boolean doDispose()
>       {
>           try
>           {
>               return TurbinePool.putInstance(this);
>           }
>           catch (RuntimeException x)
>           {
>               return false;
>           }
>       }
>   }
>   
>   
>   
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-dev-help@jakarta.apache.org

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