Return-Path: Delivered-To: apmail-jakarta-avalon-dev-archive@apache.org Received: (qmail 50818 invoked from network); 18 Jan 2002 23:25:43 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 18 Jan 2002 23:25:43 -0000 Received: (qmail 16365 invoked by uid 97); 18 Jan 2002 23:25:49 -0000 Delivered-To: qmlist-jakarta-archive-avalon-dev@jakarta.apache.org Received: (qmail 16349 invoked by uid 97); 18 Jan 2002 23:25:49 -0000 Mailing-List: contact avalon-dev-help@jakarta.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 avalon-dev@jakarta.apache.org Received: (qmail 16334 invoked from network); 18 Jan 2002 23:25:48 -0000 Message-ID: <079FD72E42C9D311B854009027650E6F08F5D1A7@xatl02.atl.hp.com> From: "MCCAY,LARRY (HP-NewJersey,ex2)" To: 'Avalon Developers List' Subject: RE: Inversion of Control Question Date: Fri, 18 Jan 2002 15:25:46 -0800 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2653.19) Content-Type: text/plain; charset="iso-8859-1" X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N Ryan, I don't believe that spirit of IOC is violated in any way by passing references to the parent. The example you provide in the DefaultThreadPool is actually a good example of interface based programming. The this pointer is provided to the child component as an implementation of ObjectFactory - the SoftResourceLimitingPool is unaware of it being any other implementation. In the spirit of IOC, the SoftResourceLimitingPool needs an ObjectFactory to get its job done and it must be provided to it by the creator - in tis case DefaultThreadPool. > m_pool = new SoftResourceLimitingPool( this, capacity ); Hope this helps. Thanks, --Larry > -----Original Message----- > From: Ryan Shaw [mailto:ryan@silveregg.co.jp] > Sent: Thursday, January 17, 2002 9:40 PM > To: avalon-dev@jakarta.apache.org > Subject: Inversion of Control Question > > > Hello, > > My coworkers and I are just starteing to get heavily > involved in using Avalon. We understand the existing > packages pretty well, but there are still some conceptual > issues we are struggling with. > > One idea we are having trouble with is Inversion of > Control. We understand it abstractly, but when it comes > down to specific situations we sometimes are having > trouble deciding whether or not something breaks IOC. > > For example, suppose that the ThreadPool implementation > in Excalibur scratchpad extended SoftResourceLimitingPool > (it doesn't, but for the sake of argument suppose it did). > Then when it created new WorkerThreads it would pass > itself as a reference so that threads could put themselves > back in the pool when they finished tasks. > > Does this break IOC, because a container (the pool) is > passing a reference to itself to the things it is > managing? > > For that matter, the ThreadPool implementation in the > scratchpad creates a SoftResourceLimitingPool and passes > a reference to itself as the ObjectFactory to use: > > public DefaultThreadPool( final String name, > final int capacity, > final ThreadContext context ) > throws Exception > { > super( name ); > m_pool = new SoftResourceLimitingPool( this, capacity ); > m_context = context; > } > > Doesn't this also break IOC (child component now has reference > to parent)? > > If these examples don't break IOC, please explain why. If they > do, please explain when it is okay to break IOC and when it > isn't. > > Thanks for any light you can shed on this. > > Ryan > > -- > To unsubscribe, e-mail: For additional commands, e-mail: -- To unsubscribe, e-mail: For additional commands, e-mail: