Return-Path: Delivered-To: apmail-incubator-geronimo-dev-archive@incubator.apache.org Received: (qmail 32031 invoked by uid 500); 14 Aug 2003 09:18:52 -0000 Mailing-List: contact geronimo-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: list-post: Reply-To: geronimo-dev@incubator.apache.org Delivered-To: mailing list geronimo-dev@incubator.apache.org Received: (qmail 32016 invoked from network); 14 Aug 2003 09:18:52 -0000 Received: from main.gmane.org (80.91.224.249) by daedalus.apache.org with SMTP; 14 Aug 2003 09:18:52 -0000 Received: from root by main.gmane.org with local (Exim 3.35 #1 (Debian)) id 19nEHK-0006Rl-00 for ; Thu, 14 Aug 2003 11:20:18 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: geronimo-dev@incubator.apache.org Received: from sea.gmane.org ([80.91.224.252]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 19nE9w-0006MX-00 for ; Thu, 14 Aug 2003 11:12:40 +0200 Received: from news by sea.gmane.org with local (Exim 3.35 #1 (Debian)) id 19nE8l-0003gg-00 for ; Thu, 14 Aug 2003 11:11:27 +0200 From: Greg Wilkins Subject: Re: [General] Container interface and AbstractContainer Date: Thu, 14 Aug 2003 19:10:17 +1000 Lines: 75 Message-ID: <3F3B51F9.4020906@mortbay.com> References: <3F3B38BC.4030709@mortbay.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@sea.gmane.org User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030704 Debian/1.4-1 X-Accept-Language: en In-Reply-To: Sender: news X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N Alex Blewitt wrote: >> I propose that the Container interface looks like: >> Container extends Component >> Components[] getComponents() >> setComponents(Component[]) >> addComponent(Component) >> removeComponent(Component) > > > Reviewing the code, I can't see why (a) you'd have a setComponents > method (given that you've already got an add/remove) and the > getComponent unecesarily returns an array. If you're using a collection, > then you can simply return a reference to the embedded data structure > which can then be anything depending on how you want to implement it. > > Arrays have given me way more headaches in implementation than they need > to, whereas the only downside of using a Container is that you need to > throw in a few casts. Given that a number of IDEs will do this > automatically for you when required, I'd vote for moving over to a > Collections-based structure instead. 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. 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'm not sure how applicable that is in this situation, as I don't know what we are doing about configuration - and an array of all components may not be the best way to do that no matter... So how about the following void addComponent(Component) void removeComponent(Component) ObjectName[] getComponents() The getComponents returns an array of JMX object names, which most JMX agents render nicely for browsing. 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() which gives you the components in the add order. OR we just give up on typing and do: interface Container extends Component, Collection { ObjectName[] getComponents() } and then throw IllegalArgumentException if anybody adds a non-Component object to the collection. >> 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 cheers