geronimo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Greg Wilkins <gr...@mortbay.com>
Subject Re: [General] Container interface and AbstractContainer
Date Thu, 14 Aug 2003 10:19:13 GMT



Alex Blewitt wrote:
> You just need to be able to read through the configuration using an 
> Iterator, surely?

Not if you want automatic persistence. Making it a Bean is good.
but whatever I agree it is a bad idea for this Container.

>> So how about the following
>>
>>      void addComponent(Component)
>>      void removeComponent(Component)
>>      ObjectName[] getComponents()
> 
> 
> Even worse, IMHO. A container contains components, not JMX 
> objects/ObjectNames. 

getComponents is a conveniance method.  Each Component has
a JMX ObjectName and a common thing that you will want to do
on a Container is to find out all the ObjectNames that it contains.

 > And you've still got the array, which was what I
> meant in my last e-mail.

Some people like arrays, some people like Collection, others
prefer iterators.  I can see all sides and am happy eitherway,
so long as you are consistent.   However - JMX is not very
Collection friendly, well many JMX agents anyway.  Thus keeping
to simple types where possible is best.


>> 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.

Because:
   + Order and reverse order are important.  You want to stop
     the components in the reverse order you started them.
   + Doing some operations like removal via the iterator
     can also be simpler, more efficient and less prone to
     simultaneous modification problems.


>> 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.

Just running it up the flag pole.  I'm not sure I agree with
your distinction that a Container is not a Collection... but then
I'd like it to be typed anyway, so I was not keen on the Collection
idea.

> public interface Container extends Component {
> 
>   public Iterator getComponents();
>   public void addComponent(Component component);
>   public void removeComponent(Component component);
> }

Make that a ListIterator and I'm 95% happy.

Add the conveniance method for getting an array of ObjectNames
and I'm 100%

cheers




> Alex.
> 
>>>> 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 :-/
> 
> 




Mime
View raw message