continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tryg...@apache.org
Subject svn commit: r224364 - in /maven/continuum/trunk/continuum-core/src: main/java/org/apache/maven/continuum/ main/java/org/apache/maven/continuum/core/ test/java/org/apache/maven/continuum/
Date Fri, 22 Jul 2005 16:46:20 GMT
Author: trygvis
Date: Fri Jul 22 09:46:13 2005
New Revision: 224364

URL: http://svn.apache.org/viewcvs?rev=224364&view=rev
Log:
o Cleaning up action execution.

Modified:
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/DefaultContinuumCore.java
    maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/DefaultContinuumTest.java

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java?rev=224364&r1=224363&r2=224364&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
(original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
Fri Jul 22 09:46:13 2005
@@ -51,6 +51,8 @@
 import org.apache.maven.continuum.initialization.ContinuumInitializationException;
 
 import org.codehaus.plexus.action.ActionManager;
+import org.codehaus.plexus.action.Action;
+import org.codehaus.plexus.action.ActionNotFoundException;
 import org.codehaus.plexus.logging.AbstractLogEnabled;
 import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
 import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
@@ -154,14 +156,7 @@
 
         context.put( AddProjectToCheckOutQueueAction.KEY_PROJECT_ID, id );
 
-        try
-        {
-            actionManager.lookup( "add-project-to-checkout-queue" ).execute( context );
-        }
-        catch ( Exception e )
-        {
-            throw new ContinuumException( "Error while adding the project to the check out
queue.", e );
-        }
+        executeAction( "add-project-to-checkout-queue", context );
     }
 
     public ContinuumProject getProject( String projectId )
@@ -393,28 +388,21 @@
     private String executeAddProjectFromScmActivity( ContinuumProject project )
         throws ContinuumException
     {
-        try
-        {
-            Map context = new HashMap();
+        Map context = new HashMap();
 
-            // ----------------------------------------------------------------------
-            //
-            // ----------------------------------------------------------------------
+        // ----------------------------------------------------------------------
+        //
+        // ----------------------------------------------------------------------
 
-            context.put( AbstractContinuumAction.KEY_UNVALIDATED_PROJECT, project );
+        context.put( AbstractContinuumAction.KEY_UNVALIDATED_PROJECT, project );
 
-            actionManager.lookup( "validate-project" ).execute( context );
+        executeAction( "validate-project", context );
 
-            actionManager.lookup( "store-project" ).execute( context );
+        executeAction( "store-project", context );
 
-            actionManager.lookup( "add-project-to-checkout-queue" ).execute( context );
+        executeAction( "add-project-to-checkout-queue", context );
 
-            return (String) context.get( StoreProjectAction.KEY_PROJECT_ID );
-        }
-        catch ( Exception e )
-        {
-            throw new ContinuumException( "Error adding project.", e );
-        }
+        return (String) context.get( StoreProjectAction.KEY_PROJECT_ID );
     }
 
     private ContinuumProjectBuildingResult executeAddProjectsFromMetadataActivity( String
metadataUrl,
@@ -430,52 +418,43 @@
 
         context.put( CreateProjectsFromMetadata.KEY_WORKING_DIRECTORY, core.getWorkingDirectory()
);
 
-        ContinuumProjectBuildingResult result;
-
-        try
-        {
-            // ----------------------------------------------------------------------
-            // During the execution of the this action we may find that the metadata
-            // isn't good enough for the following reasons:
-            //
-            // 1) No scm element (repository element for m1)
-            // 2) Invalid scm element (repository element for m1)
-            // 3) No ciManagement (m2)
-            // 4) Invalid ciManagement element (m2)
-            // ----------------------------------------------------------------------
+        // ----------------------------------------------------------------------
+        // During the execution of the this action we may find that the metadata
+        // isn't good enough for the following reasons:
+        //
+        // 1) No scm element (repository element for m1)
+        // 2) Invalid scm element (repository element for m1)
+        // 3) No ciManagement (m2)
+        // 4) Invalid ciManagement element (m2)
+        // ----------------------------------------------------------------------
 
-            actionManager.lookup( "create-projects-from-metadata" ).execute( context );
+        executeAction( "create-projects-from-metadata", context );
 
-            result = (ContinuumProjectBuildingResult)
-                context.get( CreateProjectsFromMetadata.KEY_PROJECT_BUILDING_RESULT );
+        ContinuumProjectBuildingResult result = (ContinuumProjectBuildingResult)
+            context.get( CreateProjectsFromMetadata.KEY_PROJECT_BUILDING_RESULT );
 
-            if ( result.getWarnings().size() > 0 )
-            {
-                return result;
-            }
+        if ( result.getWarnings().size() > 0 )
+        {
+            return result;
+        }
 
-            List projects = result.getProjects();
+        List projects = result.getProjects();
 
-            for ( Iterator i = projects.iterator(); i.hasNext(); )
-            {
-                ContinuumProject project = (ContinuumProject) i.next();
+        for ( Iterator i = projects.iterator(); i.hasNext(); )
+        {
+            ContinuumProject project = (ContinuumProject) i.next();
 
-                project.setExecutorId( buildExecutorId );
+            project.setExecutorId( buildExecutorId );
 
-                context.put( AbstractContinuumAction.KEY_UNVALIDATED_PROJECT, project );
+            context.put( AbstractContinuumAction.KEY_UNVALIDATED_PROJECT, project );
 
-                actionManager.lookup( "validate-project" ).execute( context );
+            executeAction( "validate-project", context );
 
-                actionManager.lookup( "store-project" ).execute( context );
+            executeAction( "store-project", context );
 
-                project.setId( (String) context.get( StoreProjectAction.KEY_PROJECT_ID )
);
+            project.setId( (String) context.get( StoreProjectAction.KEY_PROJECT_ID ) );
 
-                actionManager.lookup( "add-project-to-checkout-queue" ).execute( context
);
-            }
-        }
-        catch ( Exception e )
-        {
-            throw new ContinuumException( "Error adding projects from metadata '" + metadataUrl
+ "'.", e );
+            executeAction( "add-project-to-checkout-queue", context );
         }
 
         return result;
@@ -754,6 +733,29 @@
         schedule.setActive( true );
 
         schedule.setCronExpression( ContinuumSchedulerConstants.DEFAULT_CRON_EXPRESSION );
+    }
+
+    // ----------------------------------------------------------------------
+    // Workflow
+    // ----------------------------------------------------------------------
+
+    private void executeAction( String actionName, Map context )
+        throws ContinuumException
+    {
+        try
+        {
+            Action action = actionManager.lookup( actionName );
+
+            action.execute( context );
+        }
+        catch ( ActionNotFoundException e )
+        {
+            throw new ContinuumException( "Error while executing the action '" + actionName
+ "'.", e );
+        }
+        catch ( Exception e )
+        {
+            throw new ContinuumException( "Error while executing the action '" + actionName
+ "'.", e );
+        }
     }
 
     // ----------------------------------------------------------------------

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/DefaultContinuumCore.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/DefaultContinuumCore.java?rev=224364&r1=224363&r2=224364&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/DefaultContinuumCore.java
(original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/DefaultContinuumCore.java
Fri Jul 22 09:46:13 2005
@@ -469,7 +469,7 @@
 
             String name = "META-INF/maven/org.apache.maven.continuum/continuum-core/pom.properties";
 
-            InputStream resourceAsStream = this.getClass().getClassLoader().getResourceAsStream(
name );
+            InputStream resourceAsStream = getClass().getClassLoader().getResourceAsStream(
name );
 
             if ( resourceAsStream == null )
             {
@@ -486,4 +486,3 @@
         }
     }
 }
-

Modified: maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/DefaultContinuumTest.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/DefaultContinuumTest.java?rev=224364&r1=224363&r2=224364&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/DefaultContinuumTest.java
(original)
+++ maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/DefaultContinuumTest.java
Fri Jul 22 09:46:13 2005
@@ -16,15 +16,13 @@
  * limitations under the License.
  */
 
-import java.util.List;
-
 import org.apache.maven.continuum.project.MavenTwoProject;
 import org.apache.maven.continuum.project.builder.ContinuumProjectBuildingResult;
-import org.apache.maven.continuum.store.ContinuumStore;
-
 import org.codehaus.plexus.PlexusTestCase;
 import org.codehaus.plexus.taskqueue.TaskQueue;
 import org.codehaus.plexus.taskqueue.execution.TaskQueueExecutor;
+
+import java.util.List;
 
 /**
  * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>



Mime
View raw message