1 package org.apache.maven.continuum.scheduler;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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
32
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
48
49
50 JobDetail jobDetail = context.getJobDetail();
51
52
53
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 }