{
ComponentHandlerEntry entry = (ComponentHandlerEntry) it.next();
ComponentHandlerMetaData metaData = entry.getMetaData();
String name = metaData.getName();
Vertex v = (Vertex) vertexMap.get( name );
if ( v == null )
{
v = new Vertex( name, entry.getHandler() );
vertexMap.put( name, v );
vertices.add( v );
}
MetaInfoEntry meta = m_metaManager.getMetaInfoForClassname( metaData.getClassname() );
Iterator dit = meta.getDependencies().iterator();
while ( dit.hasNext() )
{
Map deps = (Map) m_mapper.get( dit.next() );
/* Ignore for now... It is probably due to a component requiring a Container
* component.... This happens when a required Service is not _directly_ handled
* by this container.
*/
if ( null == deps ) continue;
Iterator mdit = deps.entrySet().iterator();
while ( mdit.hasNext() )
{
Map.Entry depEntry = (Map.Entry) mdit.next();
// If this key is neither the DEFAULT_ENTRY or the SELECTOR_ENTRY then we
// want to add a dependency vertex.
if ( !( depEntry.getKey().equals( DEFAULT_ENTRY ) ||
depEntry.getKey().equals( SELECTOR_ENTRY ) ) )
{
String dName = depEntry.getKey().toString();
Vertex dv = (Vertex) vertexMap.get( dName );
if ( dv == null )
{
dv = new Vertex( dName, depEntry.getValue() );
vertexMap.put( dName, dv );
vertices.add( dv );
}
v.addDependency( dv );
}
}
}
}
DirectedAcyclicGraphVerifier.topologicalSort( vertices );
if ( getLogger().isDebugEnabled() )
{
getLogger().debug( "Component initialization order:" );
int i = 1;
for ( Iterator iter = vertices.iterator(); iter.hasNext(); i++ )
{
Vertex v = (Vertex) iter.next();
getLogger().debug( " #" + i + " (" + v.getOrder() + ") : " + v.getName() );
}
}
Collections.reverse( vertices );