avalon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Berin Loritsch" <blorit...@apache.org>
Subject RE: [Avalon5] Startable interface
Date Fri, 07 Jun 2002 20:39:40 GMT
> From: Nicola Ken Barozzi [mailto:nicolaken@apache.org] 
> From: "Berin Loritsch" <bloritsch@apache.org>
> > It seems that Peter already beat me putting a proposal Avalon 5 
> > directory out there.  Quick question regarding the Startable
> > interface:
> >
> > public interface Startable
> > {
> >     void start() throws Exception;
> >     void stop() throws Exception;
> > }
> >
> > Is there any particular reason that start() and stop() require 
> > exception throwing?  Wouldn't RuntimeExceptions (reported in the 
> > javadocs so they are documented) be better?
> Why?
> I hate RuntimeExceptions, and they have been a source of 
> really uncomprehensible error reporting in Cocoon. Could you 
> please explain?

It's either that or not allow exceptions on either.

Now, on initialization, I can understand exception throwing because
we have to not let the component be available to other components.
If the component is not stable because it couldn't allocate thread
resources that it needs, that is an Exception.

However, on the stop() method, it really isn't helpful.  We are getting
rid of the component at this stage--so why should we care if it can't
get rid of the thread it wanted.  We can force everything to shut down
hard if necessary.

> > Also, I thought that we were in favor of separating 
> Intializable and 
> > Disposable.  They aren't as tightly coupled as start()/stop() or 
> > suspend()/resume().  Otherwise, there will be a lot of 
> components with 
> > either an empty initialize() or an empty dispose() method.
> +-0
> The same thing happened with my classes for startable, since 
> 80% of the time I just start components.

? :/

Let me ask you something.  If your component starts a thread that
has to run for the duration of the component's life, then how do
you release that reasource?  If your answer is the dispose() method,
then it is a misuse.

Now, if you start up a thread that only needs to run to completion,
that is another thing entirely.  The concept behind the Startable
interface is an active component that has a thread running in the
background at all times, until it is stop()ed.

To unsubscribe, e-mail:   <mailto:avalon-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:avalon-dev-help@jakarta.apache.org>

View raw message