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 public ExecutablesExecutable() {
34 this(null);
35 }
36
37 public ExecutablesExecutable(List<Executable> executables) {
38 super();
39 this.executables = executables;
40 }
41
42 List<Executable> executables;
43 boolean skip;
44 boolean timed;
45
46 @Override
47 public void execute() {
48 if (skip) {
49 logger.info("Skipping execution of {} executables", CollectionUtils.toEmptyList(executables).size());
50 return;
51 }
52 long start = System.currentTimeMillis();
53 for (Executable executable : executables) {
54 executable.execute();
55 }
56 long stop = System.currentTimeMillis();
57 if (timed) {
58 String elapsed = FormatUtils.getTime(stop - start);
59 logger.info("------------------------------------------------------------------------");
60 logger.info("Total Time: {}", elapsed);
61 logger.info("Finished at: {}", new Date(stop));
62 logger.info("------------------------------------------------------------------------");
63 }
64 }
65
66 public List<Executable> getExecutables() {
67 return executables;
68 }
69
70 public void setExecutables(List<Executable> executables) {
71 this.executables = executables;
72 }
73
74 public boolean isSkip() {
75 return skip;
76 }
77
78 public void setSkip(boolean skip) {
79 this.skip = skip;
80 }
81
82 public boolean isTimed() {
83 return timed;
84 }
85
86 public void setTimed(boolean timed) {
87 this.timed = timed;
88 }
89
90 }