From continuum-commits-return-1249-apmail-maven-continuum-commits-archive=maven.apache.org@maven.apache.org Tue Nov 08 15:22:58 2005 Return-Path: Delivered-To: apmail-maven-continuum-commits-archive@www.apache.org Received: (qmail 29737 invoked from network); 8 Nov 2005 15:22:37 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 8 Nov 2005 15:22:37 -0000 Received: (qmail 40076 invoked by uid 500); 8 Nov 2005 15:22:22 -0000 Delivered-To: apmail-maven-continuum-commits-archive@maven.apache.org Received: (qmail 40000 invoked by uid 500); 8 Nov 2005 15:22:21 -0000 Mailing-List: contact continuum-commits-help@maven.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: continuum-dev@maven.apache.org Delivered-To: mailing list continuum-commits@maven.apache.org Received: (qmail 39965 invoked by uid 99); 8 Nov 2005 15:22:21 -0000 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.29) with SMTP; Tue, 08 Nov 2005 07:22:21 -0800 Received: (qmail 28829 invoked by uid 65534); 8 Nov 2005 15:21:51 -0000 Message-ID: <20051108152151.28700.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: continuum-commits@maven.apache.org From: evenisse@apache.org X-Mailer: svnmailer-1.0.5 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N 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 Jason van Zyl * @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 ) )