You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avalon.apache.org by Peter Donald <pe...@apache.org> on 2002/09/25 23:34:21 UTC

Re: cvs commit: jakarta-avalon-excalibur/event/src/java/org/apache/excalibur/mpool PoolUtil.java FixedSizePool.java VariableSizePool.java BlockingFixedSizePool.java

On Thu, 26 Sep 2002 01:47, bloritsch@apache.org wrote:
>   1.1                 
> jakarta-avalon-excalibur/event/src/java/org/apache/excalibur/mpool/PoolUtil
>.java
>
>   Index: PoolUtil.java
>   ===================================================================
>   /*
>    * Created by IntelliJ IDEA.
>    * User: bloritsch
>    * Date: Sep 25, 2002
>    * Time: 11:47:49 AM
>    * To change template for new class use
>    * Code Style | Class Templates options (Tools | IDE Options).
>    */

LICENSE!

>   package org.apache.excalibur.mpool;
>
>   import java.lang.reflect.Method;
>   import java.lang.reflect.Modifier;
>
>   public final class PoolUtil
>   {
>       private final static Object[] EMPTY = new Object[] {};
>       private final static Class[] EMPTY_ARGS = new Class[] {};
>
>       private PoolUtil() {}
>
>       public static Object reset( final Object obj )
>       {
>           try
>           {
>               Class klass = obj.getClass();
>               Method recycle = klass.getMethod( "recycle", EMPTY_ARGS );
>
>               if ( Modifier.isPublic( recycle.getModifiers() ) &&
>                       recycle.getReturnType().equals( void.class ) )
>               {
>                   recycle.invoke( obj, EMPTY );
>               }


I would prefer that you checked if it implemented Recyclable class (also by 
reflection). The reason being that I have classes that have a recycle method 
that are not Recyclable.

>           }
>           catch (Exception e)
>           {
>               // Not a recyclable object--don't worry about it
>           }
>
>           return obj;
>       }
>   }

-- 
Cheers,

Peter Donald
--------------------------------
 These aren't the droids you're 
 looking for. Move along. 
-------------------------------- 


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Mpool support for Recyclable (was RE: cvs commit: jakarta-avalon-excalibur/event/src/java/org/apache/excalibur/mpool PoolUtil.java FixedSizePool.java VariableSizePool.java BlockingFixedSizePool.java)

Posted by Berin Loritsch <bl...@apache.org>.
Fixed.

I have the Recyclable/Resettable set up this way:

if the Object implements Resettable, it will call the "reset()"
method.

If the "org.apache.avalon.excalibur.pool.Recyclable" class
is assignable from the Object's class we invoke the "recycle()"
method.

Otherwise we leave the class alone.

> -----Original Message-----
> From: Berin Loritsch [mailto:bloritsch@apache.org] 
> Sent: Wednesday, September 25, 2002 7:42 PM
> To: 'Avalon Developers List'
> Subject: RE: cvs commit: 
> jakarta-avalon-excalibur/event/src/java/org/apache/excalibur/m
> pool PoolUtil.java FixedSizePool.java VariableSizePool.java 
> BlockingFixedSizePool.java
> 
> 
> > From: Peter Donald [mailto:peter@apache.org] 
> > 
> > On Thu, 26 Sep 2002 01:47, bloritsch@apache.org wrote:
> > >   1.1                 
> > > 
> > jakarta-avalon-excalibur/event/src/java/org/apache/excalibur/m
> > pool/PoolUtil
> > >.java
> > >
> > >   Index: PoolUtil.java
> > >   
> > ===================================================================
> > >   /*
> > >    * Created by IntelliJ IDEA.
> > >    * User: bloritsch
> > >    * Date: Sep 25, 2002
> > >    * Time: 11:47:49 AM
> > >    * To change template for new class use
> > >    * Code Style | Class Templates options (Tools | IDE Options).
> > >    */
> > 
> > LICENSE!
> 
> Oops.  (As you can see I have an early adopters version of IDEA)
> 
> Will fix ASAP.
> 
> > 
> > 
> > I would prefer that you checked if it implemented Recyclable 
> > class (also by 
> > reflection). The reason being that I have classes that have a 
> > recycle method 
> > that are not Recyclable.
> 
> Hmm.  We need to support the Recyclable interface from the old Pool
> package
> without an artificial dependency for one class....
> 
> So we can choose to use a particular "recycle" method even if it is
> "reset" or whatever using pure reflection.  Any thoughts on how to
> satisfy it without crazy dependency checks?
> 
> I can add the check for the "Recycle" interface as well.  How do you
> feel about a "Resettable" interface for MPool, which will allow
> PoolUtil to check for the Resettable interface or the old Recyclable
> interface.  That way we can make them both work....
> 
> 
> --
> To unsubscribe, e-mail:   
> <mailto:avalon-dev-> unsubscribe@jakarta.apache.org>
> For 
> additional commands, 
> e-mail: <ma...@jakarta.apache.org>
> 


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: cvs commit: jakarta-avalon-excalibur/event/src/java/org/apache/excalibur/mpool PoolUtil.java FixedSizePool.java VariableSizePool.java BlockingFixedSizePool.java

Posted by Berin Loritsch <bl...@apache.org>.
> From: Peter Donald [mailto:peter@apache.org] 
> 
> On Thu, 26 Sep 2002 01:47, bloritsch@apache.org wrote:
> >   1.1                 
> > 
> jakarta-avalon-excalibur/event/src/java/org/apache/excalibur/m
> pool/PoolUtil
> >.java
> >
> >   Index: PoolUtil.java
> >   
> ===================================================================
> >   /*
> >    * Created by IntelliJ IDEA.
> >    * User: bloritsch
> >    * Date: Sep 25, 2002
> >    * Time: 11:47:49 AM
> >    * To change template for new class use
> >    * Code Style | Class Templates options (Tools | IDE Options).
> >    */
> 
> LICENSE!

Oops.  (As you can see I have an early adopters version of IDEA)

Will fix ASAP.

> 
> 
> I would prefer that you checked if it implemented Recyclable 
> class (also by 
> reflection). The reason being that I have classes that have a 
> recycle method 
> that are not Recyclable.

Hmm.  We need to support the Recyclable interface from the old Pool
package
without an artificial dependency for one class....

So we can choose to use a particular "recycle" method even if it is
"reset" or whatever using pure reflection.  Any thoughts on how to
satisfy it without crazy dependency checks?

I can add the check for the "Recycle" interface as well.  How do you
feel about a "Resettable" interface for MPool, which will allow
PoolUtil to check for the Resettable interface or the old Recyclable
interface.  That way we can make them both work....


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>