avalon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Schaible, Jörg" <Joerg.Schai...@gft.com>
Subject Patch AbstractContainer of Fortress
Date Wed, 05 Mar 2003 17:42:42 GMT
Hi,

I am currently working for some kind of dynamic created services.
All these services will be children for a container, but I do not
know how much there will be. The problem with the AbstractContainer
is that it creates a StaticBucketMap with a fixed size of 255 
(default) buckets for the hint map. Even more, the has table itself
should never be filled to that level at all. So I would like to
select my own Map used for the implementation. My patch refactores
this out into a protected createHintMap function and changes any
unnecessary cast to StaticBucketMap into Map.

Please apply. Diff attached, but also below, since we had problems 
with attachments lately.

Regards,
Jörg


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 -c -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	5 Mar 2003 16:52:16 -0000
@@ -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
+}


Mime
View raw message