You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by be...@apache.org on 2009/08/18 11:36:46 UTC

svn commit: r805332 - in /maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/building: DefaultModelBuilder.java ModelBuildingEventCatapult.java

Author: bentmann
Date: Tue Aug 18 09:36:45 2009
New Revision: 805332

URL: http://svn.apache.org/viewvc?rev=805332&view=rev
Log:
o Refactored code

Added:
    maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelBuildingEventCatapult.java   (with props)
Modified:
    maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java

Modified: maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java?rev=805332&r1=805331&r2=805332&view=diff
==============================================================================
--- maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java (original)
+++ maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java Tue Aug 18 09:36:45 2009
@@ -217,7 +217,7 @@
 
         pluginManagementInjector.injectBasicManagement( resultModel, request, problems );
 
-        fireBuildExtensionsAssembled( resultModel, request, problems );
+        fireEvent( resultModel, request, problems, ModelBuildingEventCatapult.BUILD_EXTENSIONS_ASSEMBLED );
 
         if ( request.isProcessPlugins() )
         {
@@ -663,19 +663,20 @@
         return null;
     }
 
-    private void fireBuildExtensionsAssembled( Model model, ModelBuildingRequest request, ModelProblemCollector problems )
+    private void fireEvent( Model model, ModelBuildingRequest request, ModelProblemCollector problems,
+                            ModelBuildingEventCatapult catapult )
         throws ModelBuildingException
     {
-        if ( request.getModelBuildingListeners().isEmpty() )
-        {
-            return;
-        }
-
-        ModelBuildingEvent event = new DefaultModelBuildingEvent( model, request, problems );
+        List<ModelBuildingListener> listeners = request.getModelBuildingListeners();
 
-        for ( ModelBuildingListener listener : request.getModelBuildingListeners() )
+        if ( !listeners.isEmpty() )
         {
-            listener.buildExtensionsAssembled( event );
+            ModelBuildingEvent event = new DefaultModelBuildingEvent( model, request, problems );
+
+            for ( ModelBuildingListener listener : listeners )
+            {
+                catapult.fire( listener, event );
+            }
         }
     }
 

Added: maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelBuildingEventCatapult.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelBuildingEventCatapult.java?rev=805332&view=auto
==============================================================================
--- maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelBuildingEventCatapult.java (added)
+++ maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelBuildingEventCatapult.java Tue Aug 18 09:36:45 2009
@@ -0,0 +1,47 @@
+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.
+ */
+
+/**
+ * Assists in firing events from a generic method by abstracting from the actual callback method to be called on the
+ * listener.
+ * 
+ * @author Benjamin Bentmann
+ */
+interface ModelBuildingEventCatapult
+{
+
+    /**
+     * Notifies the specified listener of the given event.
+     * 
+     * @param listener The listener to notify, must not be {@code null}.
+     * @param event The event to fire, must not be {@code null}.
+     */
+    void fire( ModelBuildingListener listener, ModelBuildingEvent event );
+
+    static final ModelBuildingEventCatapult BUILD_EXTENSIONS_ASSEMBLED = new ModelBuildingEventCatapult()
+    {
+        public void fire( ModelBuildingListener listener, ModelBuildingEvent event )
+        {
+            listener.buildExtensionsAssembled( event );
+        }
+    };
+
+}

Propchange: maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelBuildingEventCatapult.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelBuildingEventCatapult.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision