Return-Path: Delivered-To: apmail-avalon-dev-archive@avalon.apache.org Received: (qmail 78387 invoked by uid 500); 4 Mar 2003 19:29:48 -0000 Mailing-List: contact dev-help@avalon.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Avalon Developers List" Reply-To: "Avalon Developers List" Delivered-To: mailing list dev@avalon.apache.org Received: (qmail 78374 invoked from network); 4 Mar 2003 19:29:47 -0000 Received: from fo1.kc.aoindustries.com (HELO www1.kc.aoindustries.com) (209.15.201.17) by daedalus.apache.org with SMTP; 4 Mar 2003 19:29:47 -0000 Received: from apache.org ([66.208.12.130]) (authenticated) by www1.kc.aoindustries.com (8.11.6/8.11.6) with ESMTP id h24JTq405076 for ; Tue, 4 Mar 2003 13:29:52 -0600 Message-ID: <3E64FEAB.5000103@apache.org> Date: Tue, 04 Mar 2003 14:29:47 -0500 From: Berin Loritsch User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.2.1) Gecko/20021130 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Avalon Developers List Subject: Re: [Fortress] Single Role, Multiple Components References: <20030304192334.32535.qmail@web14302.mail.yahoo.com> In-Reply-To: <20030304192334.32535.qmail@web14302.mail.yahoo.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N J Aaron Farr wrote: > Hello again. > > Having trouble with FortressServiceManager/Selector again. > > Okay, in my roles file I have this: > > > > class="com.company.component.ImplOne" > handler="org.apache.avalon.fortress.impl.handler.FactoryComponentHandler"/> > > class="com.company.component.ImplTwo" > > handler="org.apache.avalon.fortress.impl.handler.FactoryComponentHandler"/> > > > > First off, is this valid? It sure appears to be. Yes. > So now we turn to the > container's configuration file: > > > stuff > > > > stuff > > > Now, if I use the service manager to lookup the role > "com.company.component.RoleInterface" or RoleInterface.ROLE, I should get a > ServiceSelector, correct? In other words: > > Object o = m_serviceManager.lookup(RoleInterface.ROLE); No. That gets you the default implementation. > > the object 'o' should be a ServiceSelector since I have two different > components of the same role. Instead, I'm getting 'o' as a proxy for the > "ImplOne" object. So in order for me to get an "ImplTwo" object, I have to do > something like this: > > Object o = m_serviceManager.lookup(RoleInterface.ROLE+"/componentTwo"); Right. And if you want the selector, you need to do this: Object o = m_serviceManager.lookup(RoleInterface.ROLE+"Selector"); (See the Developing with Avalon whitepaper for the documented convention). This is done to allow easier migration from ECM based projects where you had to simply *know* which roles were accessible via selector or not. This way your components are more portable. > > Is this the way it's supposed to work? I'm fairly certain that the first > example should return a ServiceSelector since I have two components defined for > the same Role. Perhaps I misunderstand the "contracts" of the ServiceManager, > so if anyone has some insight, I'd appriciate it. You just forgot to specify the selector with the +"Selector" idiom. --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org For additional commands, e-mail: dev-help@avalon.apache.org