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:05:50 UTC
cvs commit: jakarta-turbine/src/java/org/apache/turbine/util/pool ArrayCtorRecyclable.java BoundedBuffer.java InitableRecyclable.java ObjectInputStreamForContext.java Recyclable.java RecyclableSupport.java
jvanzyl 01/06/20 11:05:50
Modified: src/java/org/apache/turbine/util/pool
ArrayCtorRecyclable.java BoundedBuffer.java
InitableRecyclable.java
ObjectInputStreamForContext.java Recyclable.java
RecyclableSupport.java
Log:
- these are the proxies for backward compatibility.
Revision Changes Path
1.2 +4 -8 jakarta-turbine/src/java/org/apache/turbine/util/pool/ArrayCtorRecyclable.java
Index: ArrayCtorRecyclable.java
===================================================================
RCS file: /home/cvs/jakarta-turbine/src/java/org/apache/turbine/util/pool/ArrayCtorRecyclable.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ArrayCtorRecyclable.java 2001/03/21 00:27:20 1.1
+++ ArrayCtorRecyclable.java 2001/06/20 18:05:45 1.2
@@ -60,14 +60,10 @@
* 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/03/21 00:27:20 jmcnally Exp $
+ * @version $Id: ArrayCtorRecyclable.java,v 1.2 2001/06/20 18:05:45 jvanzyl Exp $
+ * @deprecated use org.apache.turbine.services.pool.util package.
*/
-public interface ArrayCtorRecyclable extends Recyclable
+public interface ArrayCtorRecyclable
+ extends org.apache.turbine.services.pool.util.ArrayCtorRecyclable
{
- /**
- * 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.4 +9 -114 jakarta-turbine/src/java/org/apache/turbine/util/pool/BoundedBuffer.java
Index: BoundedBuffer.java
===================================================================
RCS file: /home/cvs/jakarta-turbine/src/java/org/apache/turbine/util/pool/BoundedBuffer.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- BoundedBuffer.java 2001/03/06 06:14:31 1.3
+++ BoundedBuffer.java 2001/06/20 18:05:46 1.4
@@ -61,124 +61,19 @@
* <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.3 2001/03/06 06:14:31 chrise Exp $
+ * @version $Id: BoundedBuffer.java,v 1.4 2001/06/20 18:05:46 jvanzyl Exp $
+ * @deprecated use org.apache.turbine.services.pool.util package.
*/
public class BoundedBuffer
+ extends org.apache.turbine.services.pool.util.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()
+ super();
+ }
+
+ public BoundedBuffer(int i)
{
- if (usedSlots_ > 0)
- {
- --usedSlots_;
- Object old = array_[takePtr_];
- array_[takePtr_] = null;
- if (++takePtr_ >= array_.length)
- takePtr_ = 0;
- emptySlots_++;
- return old;
- }
- else
- return null;
- }
+ super(i);
+ }
}
1.3 +4 -10 jakarta-turbine/src/java/org/apache/turbine/util/pool/InitableRecyclable.java
Index: InitableRecyclable.java
===================================================================
RCS file: /home/cvs/jakarta-turbine/src/java/org/apache/turbine/util/pool/InitableRecyclable.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- InitableRecyclable.java 2001/05/14 18:00:59 1.2
+++ InitableRecyclable.java 2001/06/20 18:05:46 1.3
@@ -54,9 +54,6 @@
* <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
@@ -65,13 +62,10 @@
* introspection/reflection when pooling an object.
*
* @author <a href="mailto:jmcnally@collab.net">John McNally</a>
- * @version $Id: InitableRecyclable.java,v 1.2 2001/05/14 18:00:59 jmcnally Exp $
+ * @version $Id: InitableRecyclable.java,v 1.3 2001/06/20 18:05:46 jvanzyl Exp $
+ * @deprecated use org.apache.turbine.services.pool.util package.
*/
-public interface InitableRecyclable extends Recyclable
+public interface InitableRecyclable
+ extends org.apache.turbine.services.pool.util.InitableRecyclable
{
- /**
- * This method should be called after retrieving the object from
- * the pool.
- */
- public void init(Object initObj) throws TurbineException;
}
1.3 +10 -18 jakarta-turbine/src/java/org/apache/turbine/util/pool/ObjectInputStreamForContext.java
Index: ObjectInputStreamForContext.java
===================================================================
RCS file: /home/cvs/jakarta-turbine/src/java/org/apache/turbine/util/pool/ObjectInputStreamForContext.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ObjectInputStreamForContext.java 2001/03/06 06:14:32 1.2
+++ ObjectInputStreamForContext.java 2001/06/20 18:05:47 1.3
@@ -54,23 +54,23 @@
* <http://www.apache.org/>.
*/
-import java.io.InputStream;
-import java.io.ObjectInputStream;
-import java.io.ObjectStreamClass;
import java.io.IOException;
+import java.io.InputStream;
/**
* 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.2 2001/03/06 06:14:32 chrise Exp $
+ * @version $Id: ObjectInputStreamForContext.java,v 1.3 2001/06/20 18:05:47 jvanzyl Exp $
+ * @deprecated use org.apache.turbine.services.pool.util package.
*/
-public class ObjectInputStreamForContext extends ObjectInputStream
+public class ObjectInputStreamForContext
+ extends org.apache.turbine.services.pool.util.ObjectInputStreamForContext
{
- /**
- * The class loader of the context.
- */
- private ClassLoader classLoader;
+ public ObjectInputStreamForContext()
+ throws IOException
+ {
+ }
/**
* Contructs a new object stream for a context.
@@ -83,15 +83,7 @@
ClassLoader loader)
throws IOException
{
- super(in);
- classLoader = loader;
+ super(in, loader);
}
- protected Class resolveClass(ObjectStreamClass v)
- throws IOException,
- ClassNotFoundException
- {
- return classLoader == null ?
- super.resolveClass(v) : classLoader.loadClass(v.getName());
- }
}
1.3 +3 -25 jakarta-turbine/src/java/org/apache/turbine/util/pool/Recyclable.java
Index: Recyclable.java
===================================================================
RCS file: /home/cvs/jakarta-turbine/src/java/org/apache/turbine/util/pool/Recyclable.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Recyclable.java 2001/03/06 06:14:33 1.2
+++ Recyclable.java 2001/06/20 18:05:47 1.3
@@ -59,32 +59,10 @@
* recycled several times by different clients.
*
* @author <a href="mailto:ilkka.priha@simsoft.fi">Ilkka Priha</a>
- * @version $Id: Recyclable.java,v 1.2 2001/03/06 06:14:33 chrise Exp $
+ * @version $Id: Recyclable.java,v 1.3 2001/06/20 18:05:47 jvanzyl Exp $
+ * @deprecated use org.apache.turbine.services.pool.util package.
*/
public interface Recyclable
+ extends org.apache.turbine.services.pool.util.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.7 +4 -60 jakarta-turbine/src/java/org/apache/turbine/util/pool/RecyclableSupport.java
Index: RecyclableSupport.java
===================================================================
RCS file: /home/cvs/jakarta-turbine/src/java/org/apache/turbine/util/pool/RecyclableSupport.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- RecyclableSupport.java 2001/03/31 00:36:42 1.6
+++ RecyclableSupport.java 2001/06/20 18:05:48 1.7
@@ -54,70 +54,14 @@
* <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.6 2001/03/31 00:36:42 jmcnally Exp $
+ * @version $Id: RecyclableSupport.java,v 1.7 2001/06/20 18:05:48 jvanzyl Exp $
+ * @deprecated use org.apache.turbine.services.pool.util package.
*/
-public class RecyclableSupport implements Recyclable
+public class RecyclableSupport
+ extends org.apache.turbine.services.pool.util.RecyclableSupport
{
- /**
- * 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