You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avalon.apache.org by Vincent Massol <vm...@octo.com> on 2001/11/18 12:01:47 UTC

[excalibur] Releasing components ?

The "developing with Avalon" guide suggest (strategy 1) to release
components that we use in the release() method. It doesn't say for which
kind of components, but I guess it only makes sense for poolable ones, right
? Or is there a reference count in the excalibur component manager code ?

For example, I am using the DataSourceComponent component, which is
ThreadSafe (one instance in the jvm). Why should I release it by writing :

    public void dispose()
    {
        this.manager.release(this.datasource);
    }

Thanks
-Vincent


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


Re: [excalibur] Releasing components ?

Posted by Berin Loritsch <bl...@apache.org>.
Vincent Massol wrote:

> The "developing with Avalon" guide suggest (strategy 1) to release
> components that we use in the release() method. It doesn't say for which
> kind of components, but I guess it only makes sense for poolable ones, right
> ? Or is there a reference count in the excalibur component manager code ?


Not JUST poolable components BTW, also Factory components.  The Components that
are created new for each request do need full lifecycle management.  That cannot
occur if the components are never released.


>     public void dispose()
>     {
>         this.manager.release(this.datasource);
>     }


ThreadSafe is the only version of the lifecycle interface that it would be
_technically_ ok, but not _contractually_ ok.  For instance, what would happen
if the implementation changed on you?  Your component would be introducing
problems for the rest of the system.  Not a good thing.  Just follow the
contracts as a general rule, and all will be well.




-- 

"Those who would trade liberty for
  temporary security deserve neither"
                 - Benjamin Franklin


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


Re: [excalibur] Releasing components ?

Posted by Peter Donald <do...@apache.org>.
On Sun, 18 Nov 2001 22:01, Vincent Massol wrote:
> The "developing with Avalon" guide suggest (strategy 1) to release
> components that we use in the release() method. It doesn't say for which
> kind of components, but I guess it only makes sense for poolable ones,
> right ? Or is there a reference count in the excalibur component manager
> code ?

Ideally you should always call release because you never are meant to know 
the strategy by which the ComponentManager manages components. Some CMs may 
pool, while others may be factories while others may be a hashmap with a nice 
interface. However in most cases I don't release() components because I know 
the "vertical" framework that I created using Avalon will pay the release(0 
call no heed.

-- 
Cheers,

Pete

*----------------------------------------------*
| The best defense against logic is ignorance. |
*----------------------------------------------*

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


Re: [excalibur] Releasing components ?

Posted by giacomo <gi...@apache.org>.
On Sun, 18 Nov 2001, Vincent Massol wrote:

> The "developing with Avalon" guide suggest (strategy 1) to release
> components that we use in the release() method. It doesn't say for which
> kind of components, but I guess it only makes sense for poolable ones, right
> ?

Technically, yes. But client code of components don't know their
implementation and thus it is a general contract of client code to the
ComponentManager to release EACH components obtained from it.

> Or is there a reference count in the excalibur component manager code
?
>
> For example, I am using the DataSourceComponent component, which is
> ThreadSafe (one instance in the jvm). Why should I release it by writing :
>
>     public void dispose()
>     {
>         this.manager.release(this.datasource);
>     }

See above.

Giacomo


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