View Javadoc
1   package org.codehaus.plexus.configuration.source;
2   
3   import java.util.Iterator;
4   import java.util.List;
5   
6   import org.codehaus.plexus.component.repository.ComponentDescriptor;
7   import org.codehaus.plexus.configuration.PlexusConfiguration;
8   
9   /**
10   * A configuration source that delegates to any number of underlying configuration sources. If you are an application
11   * author and want to create a custom source of configuration for the components in your application then you would most
12   * likely want to create a chained configuration source where you can decide the order of processing, but still have the
13   * container perform its default behavior.
14   * 
15   * @author Jason van Zyl
16   */
17  public class ChainedConfigurationSource
18      implements ConfigurationSource
19  {
20      private List configurationSources;
21  
22      public ChainedConfigurationSource( List configurationSources )
23      {
24          this.configurationSources = configurationSources;
25      }
26  
27      public PlexusConfiguration getConfiguration( ComponentDescriptor componentDescriptor )
28      {
29          for (Object configurationSource1 : configurationSources) {
30              ConfigurationSource configurationSource = (ConfigurationSource) configurationSource1;
31  
32              PlexusConfiguration configuration = configurationSource.getConfiguration(componentDescriptor);
33  
34              if (configuration != null) {
35                  return configuration;
36              }
37          }
38  
39          return null;
40      }
41  
42      public List getConfigurationSources()
43      {
44          return configurationSources;
45      }
46  }