From 1e33cb56fe48d66e09e29f298a35a35f8c15c204 Mon Sep 17 00:00:00 2001 From: Benjamin Bentmann Date: Sun, 30 Aug 2009 18:34:46 +0000 Subject: [PATCH] o Simplified code (multi-cast can be realized by a delegating listener if required) git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@809399 13f79535-47bb-0310-9956-ffa450edef68 --- .../maven/project/DefaultProjectBuilder.java | 7 +++--- .../model/building/DefaultModelBuilder.java | 9 +++----- .../building/DefaultModelBuildingRequest.java | 22 +++++-------------- .../model/building/ModelBuildingRequest.java | 12 +++++----- 4 files changed, 17 insertions(+), 33 deletions(-) diff --git a/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java b/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java index dbb21fa252..f4527f7620 100644 --- a/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java +++ b/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java @@ -18,7 +18,6 @@ package org.apache.maven.project; import java.io.File; import java.io.IOException; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; import org.apache.maven.Maven; @@ -102,7 +101,7 @@ public class DefaultProjectBuilder ModelBuildingRequest request = getModelBuildingRequest( configuration, null ); DefaultModelBuildingListener listener = new DefaultModelBuildingListener( projectBuildingHelper, configuration ); - request.setModelBuildingListeners( Arrays.asList( listener ) ); + request.setModelBuildingListener( listener ); if ( localProject ) { @@ -266,7 +265,7 @@ public class DefaultProjectBuilder ModelBuildingRequest request = getModelBuildingRequest( config, null ); DefaultModelBuildingListener listener = new DefaultModelBuildingListener( projectBuildingHelper, config ); - request.setModelBuildingListeners( Arrays.asList( listener ) ); + request.setModelBuildingListener( listener ); request.setModelSource( new UrlModelSource( getClass().getResource( "standalone.xml" ) ) ); @@ -364,7 +363,7 @@ public class DefaultProjectBuilder request.setModelCache( modelCache ); DefaultModelBuildingListener listener = new DefaultModelBuildingListener( projectBuildingHelper, config ); - request.setModelBuildingListeners( Arrays.asList( listener ) ); + request.setModelBuildingListener( listener ); try { diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java b/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java index 97c876bfa2..ad087a4907 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java @@ -666,16 +666,13 @@ public class DefaultModelBuilder ModelBuildingEventCatapult catapult ) throws ModelBuildingException { - List listeners = request.getModelBuildingListeners(); + ModelBuildingListener listener = request.getModelBuildingListener(); - if ( !listeners.isEmpty() ) + if ( listener != null ) { ModelBuildingEvent event = new DefaultModelBuildingEvent( model, request, problems ); - for ( ModelBuildingListener listener : listeners ) - { - catapult.fire( listener, event ); - } + catapult.fire( listener, event ); } } diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuildingRequest.java b/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuildingRequest.java index 8a692734b1..bf794962aa 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuildingRequest.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuildingRequest.java @@ -61,7 +61,7 @@ public class DefaultModelBuildingRequest private ModelResolver modelResolver; - private List modelBuildingListeners; + private ModelBuildingListener modelBuildingListener; private ModelCache modelCache; @@ -271,26 +271,14 @@ public class DefaultModelBuildingRequest return this; } - public List getModelBuildingListeners() + public ModelBuildingListener getModelBuildingListener() { - if ( modelBuildingListeners == null ) - { - modelBuildingListeners = new ArrayList(); - } - - return modelBuildingListeners; + return modelBuildingListener; } - public ModelBuildingRequest setModelBuildingListeners( List modelBuildingListeners ) + public ModelBuildingRequest setModelBuildingListener( ModelBuildingListener modelBuildingListener ) { - if ( modelBuildingListeners != null ) - { - this.modelBuildingListeners = new ArrayList( modelBuildingListeners ); - } - else - { - this.modelBuildingListeners = null; - } + this.modelBuildingListener = modelBuildingListener; return this; } diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelBuildingRequest.java b/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelBuildingRequest.java index ff0ba3f214..65b8dae3a8 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelBuildingRequest.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelBuildingRequest.java @@ -269,19 +269,19 @@ public interface ModelBuildingRequest ModelBuildingRequest setModelResolver( ModelResolver modelResolver ); /** - * Gets the model building listeners to notify during the build process. + * Gets the model building listener to notify during the build process. * - * @return The model building listeners to notify, never {@code null}. + * @return The model building listener to notify or {@code null} if none. */ - List getModelBuildingListeners(); + ModelBuildingListener getModelBuildingListener(); /** - * Sets the model building listeners to notify during the build process. + * Sets the model building listener to notify during the build process. * - * @param modelBuildingListeners The model building listeners to notify, may be {@code null}. + * @param modelBuildingListener The model building listener to notify, may be {@code null}. * @return This request, never {@code null}. */ - ModelBuildingRequest setModelBuildingListeners( List modelBuildingListeners ); + ModelBuildingRequest setModelBuildingListener( ModelBuildingListener modelBuildingListener ); /** * Gets the model cache to use for reuse of previously built models.