cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Berin Loritsch <>
Subject Re: Getting rid of deprecated Interfaces/Classes/Methods
Date Tue, 24 Sep 2002 14:09:19 GMT
Tom Klaasen wrote:
> Berin wrote:
>>>We need a way to invoke the recycle() method in the current implementations,
>>>so a support for Recyclable is required.
>>:)  I can do that without requiring that interface!  I will use the
>>reflection facilities to determine if there is a "recycle()" method
>>with public access, and then call it.  I will probably get that done
>>within the next couple of days.
> I hope you're joking. In case you're not: 
> , item 35.
> Right now, I'm refactoring someone else's code who also liked reflection-wizardry. It's
a bitch.

You will never see the reflection "wizardry", and it is done in a way
that is called for.  The biggest thing is that I need to get Fortress
to support Recyclable.recycle() without any access to the interface--it
is in a package that has slow pools, and is unnecessary in the grand
scheme of things.  The Pool itself will perform the checks.

private final static Class[] EMPTY = new Class[] {};

public void release( Object obj )
        Class objClass = obj.getClass();
        Method meth = objClass.getMethod( "recycle", EMPTY );

        if( Modifiers.isPublic( meth.getModifiers() ) )
            meth.invoke( obj, EMPTY );
    catch (Exception e)
        // it is not recyclable

    m_available.add( obj );

It's not that bad--not that pretty either.  However it allows us to
handle the Recyclable issues well.  Otherwise I have to use reflection
to determine if it implements
"org.apache.avalon.excalibur.pool.Recyclable".  What happens if I have
something similar in another framework?

> Just my opinion. We've got such a nice framework right now, with lots of good design
patterns incorporated, and I would hate to see it wasted in this way.

How is an isolated incident of properly applied reflection a waste?


"They that give up essential liberty to obtain a little temporary safety
  deserve neither liberty nor safety."
                 - Benjamin Franklin

To unsubscribe, e-mail:
For additional commands, email:

View raw message