mcconnell 2002/12/19 02:33:10
Modified: assembly/src/java/org/apache/avalon/assembly/profile
ProfileManager.java
Log:
Simplified the service manager implementation to use a list of services as opposed
to prior version that was maintaining a map of services.
Revision Changes Path
1.8 +19 -56
avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/profile/ProfileManager.java
Index: ProfileManager.java
===================================================================
RCS file:
/home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/profile/ProfileManager.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- ProfileManager.java 17 Dec 2002 04:58:33 -0000 1.7
+++ ProfileManager.java 19 Dec 2002 10:33:10 -0000 1.8
@@ -51,6 +51,7 @@
package org.apache.avalon.assembly.profile;
import java.util.Hashtable;
+import java.util.List;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.Iterator;
@@ -107,7 +108,7 @@
/**
* Table of component profiles keyed by profile name.
*/
- private final Hashtable m_profiles = new Hashtable();
+ private final List m_profiles = new ArrayList();
/**
* The default profile selector.
@@ -266,22 +267,6 @@
try
{
- getNamedProfile( profile.getName() );
- if( !replace )
- {
- throw new DuplicateProfileException(
- profile.getType().getInfo().getClassname()
- + "/" + profile.getName() );
- }
- flag = true;
- }
- catch( UnknownProfileException upe )
- {
- // continue
- }
-
- try
- {
verify( profile );
}
catch( Throwable e )
@@ -294,36 +279,12 @@
if( getLogger().isDebugEnabled() )
{
- if( flag )
- {
- getLogger().debug(
- "replace: " + profile + " " + profile.getMode() );
- }
- else
- {
- getLogger().debug(
+ getLogger().debug(
"add: " + profile + " " + profile.getMode() );
- }
}
- m_profiles.put( profile.getName(), profile );
- }
+ m_profiles.add( profile );
- /**
- * Returns a profile held locally by the manager based on the profile name.
- * @param name the profile name
- * @return the profile matching the supplied name
- * @exception UnknownProfileException if the profile name is unknown within
- * the scope of the manager
- */
- public Profile getNamedProfile( String name ) throws UnknownProfileException
- {
- Profile profile = (Profile) m_profiles.get( name );
- if( profile == null )
- {
- throw new UnknownProfileException( name );
- }
- return profile;
}
/**
@@ -334,15 +295,16 @@
*/
public Profile getProfile( Type type ) throws UnknownTypeException
{
- Enumeration enum = m_profiles.elements();
- while( enum.hasMoreElements() )
+ Iterator iterator = m_profiles.iterator();
+ while( iterator.hasNext() )
{
- Profile profile = (Profile) enum.nextElement();
+ Profile profile = (Profile) iterator.next();
if( profile.getType().equals( type ) )
{
return profile;
}
}
+
if( m_parent != null )
{
return m_parent.getProfile( type );
@@ -376,10 +338,10 @@
}
}
- Enumeration enum = m_profiles.elements();
- while( enum.hasMoreElements() )
+ Iterator iterator = m_profiles.iterator();
+ while( iterator.hasNext() )
{
- Profile profile = (Profile) enum.nextElement();
+ Profile profile = (Profile) iterator.next();
if( profile.getType().equals( type ) )
{
list.add( type );
@@ -413,10 +375,11 @@
}
ReferenceDescriptor reference = dependency.getReference();
- Enumeration enum = m_profiles.elements();
- while( enum.hasMoreElements() )
+
+ Iterator iterator = m_profiles.iterator();
+ while( iterator.hasNext() )
{
- Profile profile = (Profile) enum.nextElement();
+ Profile profile = (Profile) iterator.next();
Object service = profile.getType().getService( reference );
if( service != null )
{
@@ -449,10 +412,10 @@
}
}
- Enumeration enum = m_profiles.elements();
- while( enum.hasMoreElements() )
+ Iterator iterator = m_profiles.iterator();
+ while( iterator.hasNext() )
{
- Profile profile = (Profile) enum.nextElement();
+ Profile profile = (Profile) iterator.next();
if( profile.getType().getExtension( stage ) != null )
{
list.add( profile );
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>