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 org.apache.maven.settings.io.DefaultSettingsReader;
23  import org.apache.maven.settings.io.DefaultSettingsWriter;
24  import org.apache.maven.settings.io.SettingsReader;
25  import org.apache.maven.settings.io.SettingsWriter;
26  import org.apache.maven.settings.validation.DefaultSettingsValidator;
27  import org.apache.maven.settings.validation.SettingsValidator;
28  
29  /**
30   * A factory to create settings builder instances when no dependency injection is available. <em>Note:</em> This class
31   * is only meant as a utility for developers that want to employ the settings builder outside of the Maven build system,
32   * Maven plugins should always acquire settings builder instances via dependency injection. Developers might want to
33   * subclass this factory to provide custom implementations for some of the components used by the settings builder.
34   *
35   * @author Benjamin Bentmann
36   */
37  public class DefaultSettingsBuilderFactory
38  {
39  
40      protected SettingsReader newSettingsReader()
41      {
42          return new DefaultSettingsReader();
43      }
44  
45      protected SettingsWriter newSettingsWriter()
46      {
47          return new DefaultSettingsWriter();
48      }
49  
50      protected SettingsValidator newSettingsValidator()
51      {
52          return new DefaultSettingsValidator();
53      }
54  
55      /**
56       * Creates a new settings builder instance.
57       *
58       * @return The new settings builder instance, never {@code null}.
59       */
60      public DefaultSettingsBuilder newInstance()
61      {
62          return new DefaultSettingsBuilder( newSettingsReader(),
63                                             newSettingsWriter(),
64                                             newSettingsValidator() );
65      }
66  
67  }