1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.common.util.execute;
17
18 import java.util.Date;
19 import java.util.List;
20
21 import org.kuali.common.util.CollectionUtils;
22 import org.kuali.common.util.FormatUtils;
23 import org.slf4j.Logger;
24 import org.slf4j.LoggerFactory;
25
26
27
28
29 public class ExecutablesExecutable implements Executable {
30
31 private static final Logger logger = LoggerFactory.getLogger(ExecutablesExecutable.class);
32
33 List<Executable> executables;
34 boolean skip;
35 boolean timed;
36
37 @Override
38 public void execute() {
39 if (skip) {
40 logger.info("Skipping execution of {} executables", CollectionUtils.toEmptyList(executables).size());
41 return;
42 }
43 long start = System.currentTimeMillis();
44 for (Executable executable : executables) {
45 executable.execute();
46 }
47 long stop = System.currentTimeMillis();
48 if (timed) {
49 String elapsed = FormatUtils.getTime(stop - start);
50 logger.info("------------------------------------------------------------------------");
51 logger.info("Total Time: {}", elapsed);
52 logger.info("Finished at: {}", new Date(stop));
53 logger.info("------------------------------------------------------------------------");
54 }
55 }
56
57 public List<Executable> getExecutables() {
58 return executables;
59 }
60
61 public void setExecutables(List<Executable> executables) {
62 this.executables = executables;
63 }
64
65 public boolean isSkip() {
66 return skip;
67 }
68
69 public void setSkip(boolean skip) {
70 this.skip = skip;
71 }
72
73 public boolean isTimed() {
74 return timed;
75 }
76
77 public void setTimed(boolean timed) {
78 this.timed = timed;
79 }
80
81 }