avalon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Donald <pe...@apache.org>
Subject Re: cvs commit: jakarta-avalon-excalibur/event/src/java/org/apache/excalibur/mpool PoolUtil.java FixedSizePool.java VariableSizePool.java BlockingFixedSizePool.java
Date Wed, 25 Sep 2002 21:34:21 GMT
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:   <mailto:avalon-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:avalon-dev-help@jakarta.apache.org>


Mime
View raw message