geronimo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Blewitt <>
Subject Re: [General] Container interface and AbstractContainer
Date Thu, 14 Aug 2003 09:44:40 GMT

On Thursday, Aug 14, 2003, at 10:10 Europe/London, Greg Wilkins wrote:

> I think Jan added the array methods at my prompting.
> The reason I like them is that add/remove are good for
> scripting & programming, but are not very good for configuration.

You just need to be able to read through the configuration using an 
Iterator, surely?

> I've been using a system that uses MBean for persistent configuration,
> so it is important that everything can be set and got via getters
> and setters.

I don't think that it's necessarily a good thing to allow components to 
be built in this way. I think the container should be passed each 
component individually and then put in, rather than forcing an array to 
be put in.

At least, it doesn't have to be implemented using an array internally, 
even if there are requirements to get/set it as an array.

> So how about the following
>      void addComponent(Component)
>      void removeComponent(Component)
>      ObjectName[] getComponents()

Even worse, IMHO. A container contains components, not JMX 
objects/ObjectNames. And you've still got the array, which was what I 
meant in my last e-mail.

> But we still don't have a method to iterate over all the
> Components, or get them all.  So either we need something like
>     ListIterator getComponentIterator()

Why not just Iterator? I don't see the benefit of ListIterator.

> OR we just give up on typing and do:
>    interface Container extends Component, Collection
>    {
>      ObjectName[] getComponents()
>    }

Urg. No, I don't like that at all. A Container shouldn't implement 
Collection -- if it does, it breaks all manner of things (not the least 
of which is that you have to add a whole bunch of spurious methods to a 
Container implementation to get it to work.

You might like to read for more 
discussion on this, but a Container /is-not-a/ Collection, a Container 
/has-a/ Collection. You can then expose some/all of it as necessary 
using the Iterator, or failing that, return a read-only Collection 

public interface Container extends Component {

   public Iterator getComponents();
   public void addComponent(Component component);
   public void removeComponent(Component component);



>>> I also propose that the Component interface has one extra method:
>>>     String getObjectName();
>> Why not just getName(), by the way?
> Because it is a JMX ObjectName

I think this is one of the examples where because JMXAsKernel is being 
used, JMXIsEverywhere :-/

View raw message