Return-Path: Delivered-To: apmail-avalon-dev-archive@avalon.apache.org Received: (qmail 53488 invoked by uid 500); 6 Mar 2003 16:22:39 -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 53474 invoked from network); 6 Mar 2003 16:22:39 -0000 Received: from mail.gft.de (HELO mail.gft.com) (213.68.142.133) by daedalus.apache.org with SMTP; 6 Mar 2003 16:22:39 -0000 X-MimeOLE: Produced By Microsoft Exchange V6.0.6249.0 content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Subject: [Patch] AbstractContainer of Fortress Date: Thu, 6 Mar 2003 17:22:39 +0100 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: Patch AbstractContainer of Fortress Thread-Index: AcLjPxjHyzC5d3knRNW6hm4vzUbBeQAABpZAAC8vlCA= From: =?iso-8859-1?Q?=22Schaible=2C_J=F6rg=22?= To: "Avalon Developers List" X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N Hi Berin, an Update for the patch. The reverse map (m_mapper) has to be chosen freely also. This can be achieved by changing the Type of the field to the Map interface. Now you can initialize m_mapper in your=20 initialization() method as you like. So again the updated patch below. Regards, J=F6rg > -----Original Message----- > From: Schaible, J=F6rg=20 > Sent: Wednesday, March 05, 2003 6:50 PM >=20 > > From: Berin Loritsch [mailto:bloritsch@apache.org] > > Sent: Wednesday, March 05, 2003 6:46 PM > [...] > > I can apply the diff, but be advised that the Map *MUST* manage > > synchronization itself. If you do not use a StaticBucketMap, > > you need to use a Collections.synchronizedMap() for your system. >=20 > I was not sure about that, because the code modifying the map runs > synchronized *UNLESS* you have lazy components. Then you *MUST* > use a synchronized container. At least, that was my impression looking > at the code. Naturally the current implementation must be prepared. Index: src/java/org/apache/avalon/fortress/impl/AbstractContainer.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: = /home/cvspublic/avalon-excalibur/fortress/src/java/org/apache/avalon/fort= ress/impl/AbstractContainer.java,v retrieving revision 1.10 diff -u -r1.10 AbstractContainer.java --- src/java/org/apache/avalon/fortress/impl/AbstractContainer.java 25 = Feb 2003 16:28:33 -0000 1.10 +++ src/java/org/apache/avalon/fortress/impl/AbstractContainer.java 6 = Mar 2003 16:17:18 -0000 @@ -127,7 +127,7 @@ * Contains entries mapping roles to hint maps, where the hint map = contains * mappings from hints to ComponentHandlers. */ - protected StaticBucketMap m_mapper =3D new StaticBucketMap(); + protected Map m_mapper =3D new StaticBucketMap(); /** Contains an entry for each ComponentHandler */ protected List m_components =3D new ArrayList( 10 ); =20 @@ -285,12 +285,12 @@ // ServiceSelector and put that in as SELECTOR_ENTRY. if( null !=3D role && null !=3D classname && null !=3D handler = ) { - Map hintMap =3D (StaticBucketMap)m_mapper.get( role ); + Map hintMap =3D (Map)m_mapper.get( role ); =20 // Initialize the hintMap if it doesn't exist yet. if( null =3D=3D hintMap ) { - hintMap =3D new StaticBucketMap(); + hintMap =3D createHintMap(); hintMap.put( DEFAULT_ENTRY, handler ); m_mapper.put( role, hintMap ); } @@ -310,6 +310,16 @@ } } =20 + /** + * Create the hint map for a role. The map may have to take care = for thread-safety. + * By default a StaticBucketMap is created, but you may change the = implementation + * or increment the number of buckets according your needs. + */ + protected Map createHintMap() + { + return new StaticBucketMap(); + } + =20 /** * Get a ComponentHandler with the default constructor for the = component class passed in. @@ -429,7 +439,7 @@ public Object get( final String role, final Object hint ) throws ServiceException { - final Map hintMap =3D (StaticBucketMap)m_mapper.get( role ); + final Map hintMap =3D (Map)m_mapper.get( role ); Object value; =20 if( null =3D=3D hintMap ) @@ -494,7 +504,7 @@ */ public boolean has( final String role, final Object hint ) { - final Map hintMap =3D (StaticBucketMap)m_mapper.get( role ); + final Map hintMap =3D (Map)m_mapper.get( role ); boolean hasComponent =3D false; =20 if( null !=3D hintMap ) @@ -627,4 +637,4 @@ { return m_serviceManager; } -} \ No newline at end of file +} --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org For additional commands, e-mail: dev-help@avalon.apache.org