You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avalon.apache.org by "Schaible, Jörg" <Jo...@gft.com> on 2003/03/05 18:42:42 UTC
Patch AbstractContainer of Fortress
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
+}
Re: Patch AbstractContainer of Fortress
Posted by Berin Loritsch <bl...@apache.org>.
Schaible, Jörg wrote:
> 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.
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.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org
For additional commands, e-mail: dev-help@avalon.apache.org
Re: Patch AbstractContainer of Fortress
Posted by Berin Loritsch <bl...@apache.org>.
Schaible, Jörg wrote:
> 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.
Your patch has been applied. I appologize for the delay.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org
For additional commands, e-mail: dev-help@avalon.apache.org