View Javadoc
1   package org.apache.maven.model.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.io.IOException;
24  import java.io.InputStream;
25  import java.io.Reader;
26  import java.util.Map;
27  
28  import javax.inject.Inject;
29  import javax.inject.Named;
30  import javax.inject.Singleton;
31  
32  import org.apache.maven.model.Model;
33  import org.apache.maven.model.io.ModelReader;
34  import org.apache.maven.model.locator.ModelLocator;
35  import org.eclipse.sisu.Typed;
36  
37  /**
38   * DefaultModelProcessor
39   */
40  @Named
41  @Singleton
42  @Typed( ModelProcessor.class )
43  public class DefaultModelProcessor
44      implements ModelProcessor
45  {
46  
47      @Inject
48      private ModelLocator locator;
49  
50      @Inject
51      private ModelReader reader;
52  
53      public DefaultModelProcessor setModelLocator( ModelLocator locator )
54      {
55          this.locator = locator;
56          return this;
57      }
58  
59      public DefaultModelProcessor setModelReader( ModelReader reader )
60      {
61          this.reader = reader;
62          return this;
63      }
64  
65      @Override
66      public File locatePom( File projectDirectory )
67      {
68          return locator.locatePom( projectDirectory );
69      }
70  
71      @Override
72      public Model read( File input, Map<String, ?> options )
73          throws IOException
74      {
75          return reader.read( input, options );
76      }
77  
78      @Override
79      public Model read( Reader input, Map<String, ?> options )
80          throws IOException
81      {
82          return reader.read( input, options );
83      }
84  
85      @Override
86      public Model read( InputStream input, Map<String, ?> options )
87          throws IOException
88      {
89          return reader.read( input, options );
90      }
91  
92  }