{
final BlockEntry blockEntry = getBlockEntry( entry );
final HashMap map = new HashMap();
final HashMap sets = new HashMap();
final ComponentInfo info = blockEntry.getInfo();
final DependencyDirective[] roles = blockEntry.getTemplate()
.getDependencies();
for( int i = 0; i < roles.length; i++ )
{
final DependencyDirective role = roles[ i ];
final Object dependency = m_application.getBlock(
role.getProviderName() );
final String key = role.getKey();
final DependencyDescriptor candidate =
info.getDependency( key );
if( candidate.isArray() )
{
ArrayList list = (ArrayList)sets.get( key );
if( null == list )
{
list = new ArrayList();
sets.put( key, list );
}
list.add( dependency );
}
else if( candidate.isMap() )
{
HashMap smap = (HashMap)sets.get( key );
if( null == smap )
{
smap = new HashMap();
sets.put( key, smap );
}
smap.put( role.getAlias(), dependency );
}
else
{
map.put( key, dependency );
}
}
final Iterator iterator = sets.keySet().iterator();
while( iterator.hasNext() )
{
final String key = (String)iterator.next();
final Object value = sets.get( key );
if( value instanceof List )
{
final List list = (List)value;
final DependencyDescriptor dependency = info.getDependency(
key );
final Object[] result = toArray( list,
dependency.getComponentType() );
map.put( key, result );