View Javadoc
1   package org.apache.maven.settings.building;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import java.io.File;
23  import java.util.Properties;
24  
25  /**
26   * Collects settings that control building of effective settings.
27   * 
28   * @author Benjamin Bentmann
29   */
30  public class DefaultSettingsBuildingRequest
31      implements SettingsBuildingRequest
32  {
33  
34      private File globalSettingsFile;
35  
36      private File userSettingsFile;
37  
38      private SettingsSource globalSettingsSource;
39  
40      private SettingsSource userSettingsSource;
41  
42      private Properties systemProperties;
43  
44      private Properties userProperties;
45  
46      public File getGlobalSettingsFile()
47      {
48          return globalSettingsFile;
49      }
50  
51      public DefaultSettingsBuildingRequest setGlobalSettingsFile( File globalSettingsFile )
52      {
53          this.globalSettingsFile = globalSettingsFile;
54  
55          return this;
56      }
57  
58      public SettingsSource getGlobalSettingsSource()
59      {
60          return globalSettingsSource;
61      }
62  
63      public DefaultSettingsBuildingRequest setGlobalSettingsSource( SettingsSource globalSettingsSource )
64      {
65          this.globalSettingsSource = globalSettingsSource;
66  
67          return this;
68      }
69  
70      public File getUserSettingsFile()
71      {
72          return userSettingsFile;
73      }
74  
75      public DefaultSettingsBuildingRequest setUserSettingsFile( File userSettingsFile )
76      {
77          this.userSettingsFile = userSettingsFile;
78  
79          return this;
80      }
81  
82      public SettingsSource getUserSettingsSource()
83      {
84          return userSettingsSource;
85      }
86  
87      public DefaultSettingsBuildingRequest setUserSettingsSource( SettingsSource userSettingsSource )
88      {
89          this.userSettingsSource = userSettingsSource;
90  
91          return this;
92      }
93  
94      public Properties getSystemProperties()
95      {
96          if ( systemProperties == null )
97          {
98              systemProperties = new Properties();
99          }
100 
101         return systemProperties;
102     }
103 
104     public DefaultSettingsBuildingRequest setSystemProperties( Properties systemProperties )
105     {
106         if ( systemProperties != null )
107         {
108             this.systemProperties = new Properties();
109             // MNG-5670 guard against ConcurrentModificationException
110             for ( String key : System.getProperties().stringPropertyNames() )
111             {
112                 this.systemProperties.put( key, System.getProperty( key ) );
113             }
114         }
115         else
116         {
117             this.systemProperties = null;
118         }
119 
120         return this;
121     }
122 
123     public Properties getUserProperties()
124     {
125         if ( userProperties == null )
126         {
127             userProperties = new Properties();
128         }
129 
130         return userProperties;
131     }
132 
133     public DefaultSettingsBuildingRequest setUserProperties( Properties userProperties )
134     {
135         if ( userProperties != null )
136         {
137             this.userProperties = new Properties();
138             this.userProperties.putAll( userProperties );
139         }
140         else
141         {
142             this.userProperties = null;
143         }
144 
145         return this;
146     }
147 
148 }