1 package org.apache.maven.continuum.scheduler;
2
3 /*
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
19 * under the License.
20 */
21
22 import org.apache.maven.continuum.Continuum;
23 import org.apache.maven.continuum.ContinuumException;
24 import org.apache.maven.continuum.model.project.Schedule;
25 import org.codehaus.plexus.scheduler.AbstractJob;
26 import org.quartz.JobDetail;
27 import org.quartz.JobExecutionContext;
28 import org.slf4j.Logger;
29
30 /**
31 * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
32 * @version $Id: ContinuumBuildJob.java 1372260 2012-08-13 04:29:09Z brett $
33 */
34 public class ContinuumBuildJob
35 extends AbstractJob
36 {
37 public static final String BUILD_GROUP = "BUILD_GROUP";
38
39 public void execute( JobExecutionContext context )
40 {
41 if ( isInterrupted() )
42 {
43 return;
44 }
45
46 // ----------------------------------------------------------------------
47 // Get the job detail
48 // ----------------------------------------------------------------------
49
50 JobDetail jobDetail = context.getJobDetail();
51
52 // ----------------------------------------------------------------------
53 // Get data map out of the job detail
54 // ----------------------------------------------------------------------
55
56 Logger logger = (Logger) jobDetail.getJobDataMap().get( AbstractJob.LOGGER );
57
58 String jobName = jobDetail.getName();
59
60 logger.info( ">>>>>>>>>>>>>>>>>>>>> Executing build job (" + jobName + ")..." );
61
62 Continuum continuum = (Continuum) jobDetail.getJobDataMap().get( ContinuumSchedulerConstants.CONTINUUM );
63
64 Schedule schedule = (Schedule) jobDetail.getJobDataMap().get( ContinuumSchedulerConstants.SCHEDULE );
65
66 try
67 {
68 continuum.buildProjects( schedule );
69 }
70 catch ( ContinuumException e )
71 {
72 logger.error( "Error building projects for job" + jobName + ".", e );
73 }
74
75 try
76 {
77 if ( schedule.getDelay() > 0 )
78 {
79 Thread.sleep( schedule.getDelay() * 1000 );
80 }
81 }
82 catch ( InterruptedException e )
83 {
84 }
85 }
86 }