1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package ch.syabru.nagios.broker.impl;
17
18 import java.util.Calendar;
19 import java.util.Date;
20
21 import org.apache.commons.lang.Validate;
22
23 import ch.syabru.nagios.broker.ExternalCommand;
24 import ch.syabru.nagios.broker.ExternalCommandFactory;
25
26
27
28
29
30
31
32 public class ScheduleForcedServiceCheckCommandFactory
33 implements ExternalCommandFactory
34 {
35 private String hostName;
36 private String serviceDescription;
37 private Date checkTime;
38 private int delaySeconds;
39
40
41
42
43
44
45
46
47 public ScheduleForcedServiceCheckCommandFactory(String hostName,
48 String serviceDescription, Date checkTime, int delaySeconds)
49 {
50 Validate.notNull(hostName, "hostName must not be null");
51 Validate.notNull(serviceDescription,
52 "serviceDescription must not be null");
53 this.hostName = hostName;
54 this.serviceDescription = serviceDescription;
55 this.checkTime = checkTime;
56 this.delaySeconds = delaySeconds;
57 }
58
59 @Override
60 public ExternalCommand createCommand() {
61 Calendar checkTimeCal = Calendar.getInstance();
62 if (checkTime != null)
63 checkTimeCal.setTime(checkTime);
64 checkTimeCal.add(Calendar.SECOND, delaySeconds);
65 return new ScheduleForcedServiceCheckCommand(
66 hostName, serviceDescription, checkTimeCal.getTime());
67 }
68
69 }