continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eveni...@apache.org
Subject svn commit: r331829 - in /maven/continuum/trunk: continuum-api/src/main/java/org/apache/maven/continuum/build/settings/ continuum-core/src/main/java/org/apache/maven/continuum/ continuum-core/src/main/java/org/apache/maven/continuum/build/settings/ con...
Date Tue, 08 Nov 2005 15:19:06 GMT
Author: evenisse
Date: Tue Nov  8 07:18:04 2005
New Revision: 331829

URL: http://svn.apache.org/viewcvs?rev=331829&view=rev
Log:
[CONTINUUM-428] fix schedule deletion

Modified:
    maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/build/settings/SchedulesActivator.java
    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/build/settings/DefaultSchedulesActivator.java
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/scheduler/ContinuumBuildJob.java
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/scheduler/ContinuumScheduler.java
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/scheduler/DefaultContinuumScheduler.java
    maven/continuum/trunk/continuum-web/src/main/resources/templates/screens/DeleteSchedule.vm

Modified: maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/build/settings/SchedulesActivator.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/build/settings/SchedulesActivator.java?rev=331829&r1=331828&r2=331829&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/build/settings/SchedulesActivator.java
(original)
+++ maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/build/settings/SchedulesActivator.java
Tue Nov  8 07:18:04 2005
@@ -45,4 +45,12 @@
      */
     void activateSchedule( Schedule schedule, Continuum continuum )
         throws SchedulesActivationException;
+
+    /**
+     * Unactivate schedule by looking at the scheduling information contained within.
+     *
+     * @throws SchedulesActivationException
+     */
+    void unactivateSchedule( Schedule schedule, Continuum continuum )
+        throws SchedulesActivationException;
 }

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=331829&r1=331828&r2=331829&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
Tue Nov  8 07:18:04 2005
@@ -1054,7 +1054,32 @@
     public void updateSchedule( Schedule schedule )
         throws ContinuumException
     {
+        updateSchedule( schedule, true );
+    }
+
+    private void updateSchedule( Schedule schedule, boolean updateScheduler )
+        throws ContinuumException
+    {
         storeSchedule( schedule );
+
+        if ( updateScheduler )
+        {
+            try
+            {
+                if ( schedule.isActive() )
+                {
+                    schedulesActivator.activateSchedule( schedule, this );
+                }
+                else
+                {
+                    schedulesActivator.unactivateSchedule( schedule, this );
+                }
+            }
+            catch ( SchedulesActivationException e )
+            {
+                getLogger().error( "Can't unactivate schedule. You need to restart Continuum.",
e );
+            }
+        }
     }
 
     public void updateSchedule( int scheduleId, Map configuration )
@@ -1070,9 +1095,18 @@
 
         schedule.setDelay( new Integer( (String) configuration.get( "schedule.delay" ) ).intValue()
);
 
+        boolean isActive = schedule.isActive();
+
         schedule.setActive( new Boolean( (String) configuration.get( "schedule.active" )
).booleanValue() );
 
-        storeSchedule( schedule );
+        if ( schedule.isActive() == isActive )
+        {
+            updateSchedule( schedule, false );
+        }
+        else
+        {
+            updateSchedule( schedule, true );
+        }
     }
 
     public void removeSchedule( int scheduleId )
@@ -1080,12 +1114,15 @@
     {
         Schedule schedule = getSchedule( scheduleId );
 
-        removeSchedule( schedule );
-    }
+        try
+        {
+            schedulesActivator.unactivateSchedule( schedule, this );
+        }
+        catch ( SchedulesActivationException e )
+        {
+            getLogger().error( "Can't unactivate schedule. You need to restart Continuum.",
e );
+        }
 
-    private void removeSchedule( Schedule schedule )
-        throws ContinuumException
-    {
         store.removeSchedule( schedule );
     }
 

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/build/settings/DefaultSchedulesActivator.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/build/settings/DefaultSchedulesActivator.java?rev=331829&r1=331828&r2=331829&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/build/settings/DefaultSchedulesActivator.java
(original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/build/settings/DefaultSchedulesActivator.java
Tue Nov  8 07:18:04 2005
@@ -88,6 +88,14 @@
         schedule( schedule, continuum );
     }
 
+    public void unactivateSchedule( Schedule schedule, Continuum continuum )
+        throws SchedulesActivationException
+    {
+        getLogger().info( "Unactivating schedule " + schedule.getName() );
+
+        unschedule( schedule, continuum );
+    }
+
     protected void schedule( Schedule schedule, Continuum continuum )
         throws SchedulesActivationException
     {
@@ -144,6 +152,26 @@
         catch ( ContinuumSchedulerException e )
         {
             throw new SchedulesActivationException( "Cannot schedule build job.", e );
+        }
+    }
+
+    protected void unschedule( Schedule schedule, Continuum continuum )
+        throws SchedulesActivationException
+    {
+        try
+        {
+            if ( schedule.isActive() )
+            {
+                getLogger().info( "Stopping active schedule \"" + schedule.getName() + "\"."
);
+
+                scheduler.interruptSchedule( schedule.getName(), Scheduler.DEFAULT_GROUP
);
+            }
+
+            scheduler.unscheduleJob( schedule.getName(), Scheduler.DEFAULT_GROUP );
+        }
+        catch ( ContinuumSchedulerException e )
+        {
+            throw new SchedulesActivationException( "Cannot unschedule build job \"" + schedule.getName()
+ "\".", e );
         }
     }
 }

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/scheduler/ContinuumBuildJob.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/scheduler/ContinuumBuildJob.java?rev=331829&r1=331828&r2=331829&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/scheduler/ContinuumBuildJob.java
(original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/scheduler/ContinuumBuildJob.java
Tue Nov  8 07:18:04 2005
@@ -20,19 +20,27 @@
 import org.apache.maven.continuum.ContinuumException;
 import org.apache.maven.continuum.model.project.Schedule;
 import org.codehaus.plexus.logging.Logger;
-import org.quartz.Job;
+import org.quartz.InterruptableJob;
 import org.quartz.JobDetail;
 import org.quartz.JobExecutionContext;
+import org.quartz.UnableToInterruptJobException;
 
 /**
  * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
  * @version $Id$
  */
 public class ContinuumBuildJob
-    implements Job
+    implements InterruptableJob
 {
+    private boolean interrupted;
+
     public void execute( JobExecutionContext context )
     {
+        if ( interrupted )
+        {
+            return;
+        }
+
         // ----------------------------------------------------------------------
         // Get the job detail
         // ----------------------------------------------------------------------
@@ -72,33 +80,11 @@
         catch( InterruptedException e )
         {
         }
+    }
 
-        /*
-
-        Continuum continuum = (Continuum) jobDetail.getJobDataMap().get( ContinuumSchedulerConstants.CONTINUUM
);
-
-        ContinuumBuildSettings buildSettings = (ContinuumBuildSettings) jobDetail.getJobDataMap().get(
ContinuumSchedulerConstants.BUILD_SETTINGS );
-
-        // ----------------------------------------------------------------------
-        // Lookup all the project groups that belong to these build settings
-        // ----------------------------------------------------------------------
-
-        Set projectGroups = buildSettings.getProjectGroups();
-
-        for ( Iterator iterator = projectGroups.iterator(); iterator.hasNext(); )
-        {
-            ContinuumProjectGroup projectGroup = (ContinuumProjectGroup) iterator.next();
-
-            try
-            {
-                continuum.buildProjectGroup( projectGroup, buildSettings );
-            }
-            catch ( ContinuumException e )
-            {
-                logger.error( "Error building project group.", e );
-            }
-        }
-
-        */
+    public void interrupt()
+        throws UnableToInterruptJobException
+    {
+        interrupted = true;
     }
 }

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/scheduler/ContinuumScheduler.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/scheduler/ContinuumScheduler.java?rev=331829&r1=331828&r2=331829&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/scheduler/ContinuumScheduler.java
(original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/scheduler/ContinuumScheduler.java
Tue Nov  8 07:18:04 2005
@@ -32,4 +32,9 @@
 
     void addGlobalTriggerListener( TriggerListener listener );
 
+    void unscheduleJob( String jobName, String groupName )
+        throws ContinuumSchedulerException;
+
+    boolean interruptSchedule( String jobName, String groupName )
+        throws ContinuumSchedulerException;
 }

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/scheduler/DefaultContinuumScheduler.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/scheduler/DefaultContinuumScheduler.java?rev=331829&r1=331828&r2=331829&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/scheduler/DefaultContinuumScheduler.java
(original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/scheduler/DefaultContinuumScheduler.java
Tue Nov  8 07:18:04 2005
@@ -106,6 +106,35 @@
         }
     }
 
+    public void unscheduleJob( String jobName, String groupName )
+        throws ContinuumSchedulerException
+    {
+        try
+        {
+            if ( jobExists( jobName, groupName ) )
+            {
+                scheduler.deleteJob( jobName, groupName );
+            }
+        }
+        catch ( SchedulerException e )
+        {
+            throw new ContinuumSchedulerException( "Error unscheduling job.", e );
+        }
+    }
+
+    public boolean interruptSchedule( String jobName, String groupName )
+        throws ContinuumSchedulerException
+    {
+        try
+        {
+            return scheduler.interrupt( jobName, groupName );
+        }
+        catch ( Exception e )
+        {
+            throw new ContinuumSchedulerException( "Can't interrup job \"" + jobName + "\".",
e );
+        }
+    }
+
     // ----------------------------------------------------------------------
     //
     // ----------------------------------------------------------------------

Modified: maven/continuum/trunk/continuum-web/src/main/resources/templates/screens/DeleteSchedule.vm
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-web/src/main/resources/templates/screens/DeleteSchedule.vm?rev=331829&r1=331828&r2=331829&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-web/src/main/resources/templates/screens/DeleteSchedule.vm
(original)
+++ maven/continuum/trunk/continuum-web/src/main/resources/templates/screens/DeleteSchedule.vm
Tue Nov  8 07:18:04 2005
@@ -1,4 +1,4 @@
-$page.setTitle( "Delete Project" )
+$page.setTitle( $i18n.getString( $form.delete.titleKey ) )
 
 <div class="app">
   <div id="axial" class="h3">



Mime
View raw message