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