One way to accomplish what you are trying to do is to make the state java
object, e.g. ComponentState, that has instance methods for validating the 
component's state.

Usage pattern would then be something like:

// Checks what lifecycle interfaces are implemented and returns the
// initial state
private ComponentState state = new ComponentState(this);

Thenthe  user would call the check methods for component state validation

state.configure();
state.initialize();
state.start();
state.stop();
state.dispose();

// invalid state, throws some type of IllegalStateException
state.initialize();

Anyway, just a thought. Another idea would be to make the state object
opaque and passed into the static check methods of ComponentUtil. What do
you think?

Regards,

--mike

On Sat, 1 Dec 2001, Leo Sutic wrote:

> 
> 
> > -----Original Message-----
> > From: Peter Donald [mailto:[EMAIL PROTECTED]
> > 
> > a) a dodgy container
> > or
> > b) evil clients who can get direct reference to component
> > 
> > if (a) is true then it should be fixed not worked around.
> 
> True, it should be fixed in the container. There is no reasonable way to 
> survive the handling of a container that calls the methods in the wrong 
> order. And that is just the point: Fail early. Do not wait and fail later. If 
> the container is dodgy, the component can help by failing fast, much like the 
> Iterator classes.
> 
> Here's a patch for some refactoring of AbstractComponent.
> 
> /LS
> 


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to