{
public List<Assembly> readAssemblies( final AssemblerConfigurationSource configSource )
throws AssemblyReadException, InvalidAssemblerConfigurationException
{
final Locator locator = new Locator();
final List<LocatorStrategy> strategies = new ArrayList<LocatorStrategy>();
strategies.add( new RelativeFileLocatorStrategy( configSource.getBasedir() ) );
strategies.add( new FileLocatorStrategy() );
final List<LocatorStrategy> refStrategies = new ArrayList<LocatorStrategy>();
refStrategies.add( new PrefixedClasspathLocatorStrategy( "/assemblies/" ) );
final List<Assembly> assemblies = new ArrayList<Assembly>();
final String descriptor = configSource.getDescriptor();
final String descriptorId = configSource.getDescriptorId();
final String[] descriptors = configSource.getDescriptors();
final String[] descriptorRefs = configSource.getDescriptorReferences();
final File descriptorSourceDirectory = configSource.getDescriptorSourceDirectory();
if ( descriptor != null )
{
locator.setStrategies( strategies );
addAssemblyFromDescriptor( descriptor, locator, configSource, assemblies );
}
if ( descriptorId != null )
{
locator.setStrategies( refStrategies );
addAssemblyForDescriptorReference( descriptorId, configSource, assemblies );
}
if ( ( descriptors != null ) && ( descriptors.length > 0 ) )
{
locator.setStrategies( strategies );
for ( int i = 0; i < descriptors.length; i++ )
{
getLogger().info( "Reading assembly descriptor: " + descriptors[i] );
addAssemblyFromDescriptor( descriptors[i], locator, configSource, assemblies );
}
}
if ( ( descriptorRefs != null ) && ( descriptorRefs.length > 0 ) )
{
locator.setStrategies( refStrategies );
for ( int i = 0; i < descriptorRefs.length; i++ )
{
addAssemblyForDescriptorReference( descriptorRefs[i], configSource, assemblies );
}
}
if ( ( descriptorSourceDirectory != null ) && descriptorSourceDirectory.isDirectory() )
{
locator.setStrategies( Collections.singletonList( new RelativeFileLocatorStrategy(
descriptorSourceDirectory ) ) );
final DirectoryScanner scanner = new DirectoryScanner();
scanner.setBasedir( descriptorSourceDirectory );
scanner.setIncludes( new String[] { "**/*.xml" } );