You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avalon.apache.org by Leif Mortenson <le...@silveregg.co.jp> on 2002/02/02 01:43:43 UTC

Question about some pools not implementing Poolable

I noticed a couple places in the pool package where classes are not
implementing Initializable, when they should.  Wanted to make sure that
these were not by design before making any changes.

1) The SoftResourceLimitingPool relies on its initialize() method being
called, but the class does not currently implement Initializable.
HardResourceLimitingPool currently extends SoftResourceLimitingPool and
does implement Initialize. It should be removed from the later.

2) This one is more a style issue, but it seems like something that
should be fixed.  The SingleThreadedPool class contains the following code:
----
public SingleThreadedPool( final ObjectFactory factory,
	final PoolController controller,
	final int initial,
	final int maximum ) throws Exception
{
	m_count = 0;
	m_factory = factory;
	m_controller = controller;
	m_maximum = maximum;
	m_initial = initial;

	if( !(this instanceof Initializable) )
	{
		initialize();
	}
}

public void initialize()
	throws Exception
{
	grow( m_maximum );
	fill( m_initial );
}
----
If the class is subclassed with something that is initializable the
constructor has one behavior, but if it does implement initializable, it
has another.  This seems like a confusing and error prone way of doing
things.  :-)  Is there any reason why this class does not just Implement
Initializable and require that initialize is called?  The other pool
classes have similar requirements.
This class should also probably implement Disposable so that the
factory's decommision method will always be called on any poolables.
It doesn't look like this class is being used by any Avalon code.  It
may be being used by users however.

Cheers,
Leif



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


Re: Question about some pools not implementing Poolable

Posted by Leif Mortenson <le...@silveregg.co.jp>.

Berin Loritsch wrote:

> Leif Mortenson wrote:
> 
> 
>>I noticed a couple places in the pool package where classes are not
>>implementing Initializable, when they should.  Wanted to make sure that
>>these were not by design before making any changes.
>>
>>1) The SoftResourceLimitingPool relies on its initialize() method being
>>called, but the class does not currently implement Initializable.
>>HardResourceLimitingPool currently extends SoftResourceLimitingPool and
>>does implement Initialize. It should be removed from the later.
>>
> 
> 
> This was to address a limitation that I can't remember what it is right
> now.  The goal was to move toward an Initializable pool.  However there
> are environments where the user just wants to create the pool and be
> done with it.  It is a Subversion of Control to directly manage your
> own lifecycle classes though.
> 
> My take on it is that I am ready to implement new light-weight
> asynchronously managed pools.  I started this in Scratchpad.  There is
> the FixedSizePool for hard limits (it does not resize making the
> implementation simple and quick).  The VariableSizedPool can be
> externally managed.


Ok, that sounds good.


About the SingleThreadedPool though.  It had an additional problem with
its interaction with the ObjectFactory.  Created Objects were never
being decommissioned.  I fixed those problems, but had to add a
Disposable interface and make it extend the AbstractLogEnabled class so
that I had something to do with the exceptions thrown by the
decommission method.
The change in the API should not affect anyone using the class as I
implemented it in such a way that the class will behave correctly even
if the code using the class does not call enableLogging() and disable()
in turn.

Cheers,
Leif


> 
> 
> 
> 
> 
> ----------------------------------------------------
> Sign Up for NetZero Platinum Today
> Only $9.95 per month!
> http://my.netzero.net/s/signup?r=platinum&refcd=PT97
> 
> --
> To unsubscribe, e-mail:   <ma...@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: Question about some pools not implementing Poolable

Posted by Berin Loritsch <bl...@apache.org>.
Leif Mortenson wrote:

> I noticed a couple places in the pool package where classes are not
> implementing Initializable, when they should.  Wanted to make sure that
> these were not by design before making any changes.
> 
> 1) The SoftResourceLimitingPool relies on its initialize() method being
> called, but the class does not currently implement Initializable.
> HardResourceLimitingPool currently extends SoftResourceLimitingPool and
> does implement Initialize. It should be removed from the later.


This was to address a limitation that I can't remember what it is right
now.  The goal was to move toward an Initializable pool.  However there
are environments where the user just wants to create the pool and be
done with it.  It is a Subversion of Control to directly manage your
own lifecycle classes though.

My take on it is that I am ready to implement new light-weight
asynchronously managed pools.  I started this in Scratchpad.  There is
the FixedSizePool for hard limits (it does not resize making the
implementation simple and quick).  The VariableSizedPool can be
externally managed.





----------------------------------------------------
Sign Up for NetZero Platinum Today
Only $9.95 per month!
http://my.netzero.net/s/signup?r=platinum&refcd=PT97

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