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 initialization() method as you like. So again the updated patch below.
Regards, J�rg > -----Original Message----- > From: Schaible, J�rg > Sent: Wednesday, March 05, 2003 6:50 PM > > > From: Berin Loritsch [mailto:[EMAIL PROTECTED] > > 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. > > 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 =================================================================== RCS file: /home/cvspublic/avalon-excalibur/fortress/src/java/org/apache/avalon/fortress/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 = new StaticBucketMap(); + protected Map m_mapper = new StaticBucketMap(); /** Contains an entry for each ComponentHandler */ protected List m_components = new ArrayList( 10 ); @@ -285,12 +285,12 @@ // ServiceSelector and put that in as SELECTOR_ENTRY. if( null != role && null != classname && null != handler ) { - Map hintMap = (StaticBucketMap)m_mapper.get( role ); + Map hintMap = (Map)m_mapper.get( role ); // Initialize the hintMap if it doesn't exist yet. if( null == hintMap ) { - hintMap = new StaticBucketMap(); + hintMap = createHintMap(); hintMap.put( DEFAULT_ENTRY, handler ); m_mapper.put( role, hintMap ); } @@ -310,6 +310,16 @@ } } + /** + * 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(); + } + /** * 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 = (StaticBucketMap)m_mapper.get( role ); + final Map hintMap = (Map)m_mapper.get( role ); Object value; if( null == hintMap ) @@ -494,7 +504,7 @@ */ public boolean has( final String role, final Object hint ) { - final Map hintMap = (StaticBucketMap)m_mapper.get( role ); + final Map hintMap = (Map)m_mapper.get( role ); boolean hasComponent = false; if( null != hintMap ) @@ -627,4 +637,4 @@ { return m_serviceManager; } -} \ No newline at end of file +} --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
