Author: bentmann
Date: Sun Apr  4 13:41:38 2010
New Revision: 930689

URL: http://svn.apache.org/viewvc?rev=930689&view=rev
Log:
o Cleaned up code

Modified:
    
maven/maven-3/trunk/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelProcessor.java
    
maven/maven-3/trunk/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelProcessor.java

Modified: 
maven/maven-3/trunk/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelProcessor.java
URL: 
http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelProcessor.java?rev=930689&r1=930688&r2=930689&view=diff
==============================================================================
--- 
maven/maven-3/trunk/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelProcessor.java
 (original)
+++ 
maven/maven-3/trunk/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelProcessor.java
 Sun Apr  4 13:41:38 2010
@@ -1,5 +1,24 @@
 package org.apache.maven.model.building;
 
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
@@ -7,86 +26,43 @@ import java.io.Reader;
 import java.util.Map;
 
 import org.apache.maven.model.Model;
-import org.apache.maven.model.io.ModelParseException;
-import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
+import org.apache.maven.model.io.ModelReader;
+import org.apache.maven.model.locator.ModelLocator;
 import org.codehaus.plexus.component.annotations.Component;
-import org.codehaus.plexus.util.IOUtil;
-import org.codehaus.plexus.util.ReaderFactory;
-import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
+import org.codehaus.plexus.component.annotations.Requirement;
 
-...@component(role = ModelProcessor.class)
+...@component( role = ModelProcessor.class )
 public class DefaultModelProcessor
     implements ModelProcessor
 {
+
+    @Requirement
+    private ModelLocator locator;
+
+    @Requirement
+    private ModelReader reader;
+
     public File locatePom( File projectDirectory )
     {
-        return new File( projectDirectory, "pom.xml" );
+        return locator.locatePom( projectDirectory );
     }
 
     public Model read( File input, Map<String, ?> options )
         throws IOException
     {
-        if ( input == null )
-        {
-            throw new IllegalArgumentException( "input file missing" );
-        }
-
-        Model model = read( ReaderFactory.newXmlReader( input ), options );
-
-        model.setPomFile( input );
-
-        return model;
+        return reader.read( input, options );
     }
 
     public Model read( Reader input, Map<String, ?> options )
         throws IOException
     {
-        if ( input == null )
-        {
-            throw new IllegalArgumentException( "input reader missing" );
-        }
-
-        try
-        {
-            MavenXpp3Reader r = new MavenXpp3Reader();
-            return r.read( input, isStrict( options ) );
-        }
-        catch ( XmlPullParserException e )
-        {
-            throw new ModelParseException( e.getMessage(), e.getLineNumber(), 
e.getColumnNumber(), e );
-        }
-        finally
-        {
-            IOUtil.close( input );
-        }
+        return reader.read( input, options );
     }
 
     public Model read( InputStream input, Map<String, ?> options )
         throws IOException
     {
-        if ( input == null )
-        {
-            throw new IllegalArgumentException( "input stream missing" );
-        }
-
-        try
-        {
-            MavenXpp3Reader r = new MavenXpp3Reader();
-            return r.read( input, isStrict( options ) );
-        }
-        catch ( XmlPullParserException e )
-        {
-            throw new ModelParseException( e.getMessage(), e.getLineNumber(), 
e.getColumnNumber(), e );
-        }
-        finally
-        {
-            IOUtil.close( input );
-        }
+        return reader.read( input, options );
     }
 
-    private boolean isStrict( Map<String, ?> options )
-    {
-        Object value = ( options != null ) ? options.get( IS_STRICT ) : null;
-        return value == null || Boolean.parseBoolean( value.toString() );
-    }
 }

Modified: 
maven/maven-3/trunk/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelProcessor.java
URL: 
http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelProcessor.java?rev=930689&r1=930688&r2=930689&view=diff
==============================================================================
--- 
maven/maven-3/trunk/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelProcessor.java
 (original)
+++ 
maven/maven-3/trunk/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelProcessor.java
 Sun Apr  4 13:41:38 2010
@@ -1,5 +1,24 @@
 package org.apache.maven.model.building;
 
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
 import org.apache.maven.model.io.ModelReader;
 import org.apache.maven.model.locator.ModelLocator;
 


Reply via email to