You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by mc...@apache.org on 2002/09/17 01:17:05 UTC
cvs commit: jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/service DefaultRegistry.java
mcconnell 2002/09/16 16:17:05
Modified: assembly/src/java/org/apache/excalibur/merlin/service
DefaultRegistry.java
Log:
Fixed a bug in the registry concerning the handling of map entries.
Revision Changes Path
1.5 +19 -31 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/service/DefaultRegistry.java
Index: DefaultRegistry.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/service/DefaultRegistry.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- DefaultRegistry.java 16 Sep 2002 21:42:42 -0000 1.4
+++ DefaultRegistry.java 16 Sep 2002 23:17:05 -0000 1.5
@@ -47,7 +47,7 @@
/**
* A hashtable of resources keyed by service name.
*/
- private Map m_children = new Hashtable();
+ private Map m_resources = new Hashtable();
//=============================================================
@@ -147,7 +147,7 @@
throw new NullPointerException("name");
}
- if( m_children.get( name ) != null )
+ if( m_table.get( name ) != null )
{
final String error = "Duplicate name: " + name;
throw new IllegalArgumentException( error );
@@ -155,7 +155,7 @@
Registry context =
new DefaultRegistry( this, name );
- m_children.put( name, context );
+ m_table.put( name, context );
return context;
}
@@ -167,15 +167,15 @@
*/
public void bind( Resource resource )
{
- synchronized( m_children )
+ synchronized( m_resources )
{
final String name = resource.getProfile().getName();
- if( m_children.get( name ) != null )
+ if( m_resources.get( name ) != null )
{
final String error = "Duplicate name: " + name;
throw new IllegalArgumentException( error );
}
- m_children.put( name, resource );
+ m_resources.put( name, resource );
}
}
@@ -187,16 +187,16 @@
*/
public void unbind( Resource resource )
{
- synchronized( m_children )
+ synchronized( m_resources )
{
String name = resource.getProfile().getName();
- Iterator iterator = m_children.entrySet().iterator();
+ Iterator iterator = m_resources.entrySet().iterator();
while( iterator.hasNext() )
{
Resource res = (Resource) iterator.next();
if( res.getProfile().getName().equals( name ) )
{
- m_children.remove( name );
+ m_resources.remove( name );
break;
}
}
@@ -235,25 +235,19 @@
// its an immediate resource
//
- Registry child = (Registry) m_children.get( uri );
+ Object child = m_table.get( uri );
if( child != null )
{
- //
- // then forward the request to the child
- //
-
- return child.locate("");
+ return ((Registry)child).locate("");
}
- else
+
+ Resource resource = (Resource) m_resources.get( uri );
+ if( resource != null )
{
- Resource resource = (Resource) m_children.get( uri );
- if( resource != null )
- {
- return resource;
- }
- final String error = "Could not locate the requested service.";
- throw new UnknownServiceException( uri, error );
+ return resource;
}
+ final String error = "Could not locate the requested service.";
+ throw new UnknownServiceException( uri, error );
}
}
@@ -267,13 +261,7 @@
*/
public synchronized Resource[] getResources()
{
- Object[] children = m_children.keySet().toArray();
- ArrayList list = new ArrayList();
- for( int i=0; i<children.length; i++ )
- {
- list.add( m_children.get( children[i] ) );
- }
- return (Resource[]) list.toArray( new Resource[0] );
+ return (Resource[]) m_resources.values().toArray( new Resource[0] );
}
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>