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
17      implements ConfigurationSource
18  {
19      private List configurationSources;
20  
21      public ChainedConfigurationSource( List configurationSources )
22      {
23          this.configurationSources = configurationSources;
24      }
25  
26      public PlexusConfiguration getConfiguration( ComponentDescriptor componentDescriptor )
27      {
28          for (Object configurationSource1 : configurationSources) {
29              ConfigurationSource configurationSource = (ConfigurationSource) configurationSource1;
30  
31              PlexusConfiguration configuration = configurationSource.getConfiguration(componentDescriptor);
32  
33              if (configuration != null) {
34                  return configuration;
35              }
36          }
37  
38          return null;
39      }
40  
41      public List getConfigurationSources()
42      {
43          return configurationSources;
44      }
45  }