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
This commit is contained in:
Benjamin Bentmann 2009-08-30 18:34:46 +00:00
parent 6a41005dd2
commit 1e33cb56fe
4 changed files with 17 additions and 33 deletions

View File

@ -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
{

View File

@ -666,16 +666,13 @@ public class DefaultModelBuilder
ModelBuildingEventCatapult catapult )
throws ModelBuildingException
{
List<ModelBuildingListener> 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 );
}
}

View File

@ -61,7 +61,7 @@ public class DefaultModelBuildingRequest
private ModelResolver modelResolver;
private List<ModelBuildingListener> modelBuildingListeners;
private ModelBuildingListener modelBuildingListener;
private ModelCache modelCache;
@ -271,26 +271,14 @@ public class DefaultModelBuildingRequest
return this;
}
public List<ModelBuildingListener> getModelBuildingListeners()
public ModelBuildingListener getModelBuildingListener()
{
if ( modelBuildingListeners == null )
{
modelBuildingListeners = new ArrayList<ModelBuildingListener>();
}
return modelBuildingListeners;
return modelBuildingListener;
}
public ModelBuildingRequest setModelBuildingListeners( List<? extends ModelBuildingListener> modelBuildingListeners )
public ModelBuildingRequest setModelBuildingListener( ModelBuildingListener modelBuildingListener )
{
if ( modelBuildingListeners != null )
{
this.modelBuildingListeners = new ArrayList<ModelBuildingListener>( modelBuildingListeners );
}
else
{
this.modelBuildingListeners = null;
}
this.modelBuildingListener = modelBuildingListener;
return this;
}

View File

@ -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<ModelBuildingListener> 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<? extends ModelBuildingListener> modelBuildingListeners );
ModelBuildingRequest setModelBuildingListener( ModelBuildingListener modelBuildingListener );
/**
* Gets the model cache to use for reuse of previously built models.