public ComponentSetDescriptor createComponentDescriptors( Reader componentDescriptorReader, String source, ClassRealm realm )
throws PlexusConfigurationException
{
PlexusConfiguration componentDescriptorConfiguration = PlexusTools.buildConfiguration( source, componentDescriptorReader );
ComponentSetDescriptor componentSetDescriptor = new ComponentSetDescriptor();
List<ComponentDescriptor<?>> componentDescriptors = new ArrayList<ComponentDescriptor<?>>();
PlexusConfiguration[] componentConfigurations = componentDescriptorConfiguration.getChild( "components" ).getChildren( "component" );
for ( PlexusConfiguration componentConfiguration : componentConfigurations )
{
ComponentDescriptor<?> componentDescriptor;
try
{
componentDescriptor = PlexusTools.buildComponentDescriptor( componentConfiguration, realm );
}
catch ( PlexusConfigurationException e )
{
// This is not the most accurate of exceptions as the only real case where this exception
// will be thrown is when the implementation class of the component sited cannot be loaded.
// In the case where role and implementation classes do not exist then we just shouldn't
// create the component descriptor. All information should be taken from annotations which
// will be correct, so in the case we can't load the class it must be coming from and older
// hand written descriptor which is incorrect.
continue;
}
componentDescriptor.setSource( source );
componentDescriptor.setComponentType( "plexus" );
componentDescriptor.setComponentSetDescriptor( componentSetDescriptor );
componentDescriptors.add( componentDescriptor );
}
componentSetDescriptor.setComponents( componentDescriptors );
componentSetDescriptor.setSource( source );
return componentSetDescriptor;
}