1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.kpme.core.batch;
17
18 import org.apache.log4j.Logger;
19 import org.kuali.kpme.core.KPMEConstants;
20 import org.kuali.kpme.core.util.HrConstants;
21 import org.kuali.rice.core.api.config.property.ConfigContext;
22 import org.kuali.rice.kim.api.identity.principal.Principal;
23 import org.kuali.rice.kim.api.services.KimApiServiceLocator;
24 import org.quartz.*;
25
26 import java.net.InetAddress;
27 import java.net.UnknownHostException;
28 import java.util.Iterator;
29
30 public abstract class BatchJob implements StatefulJob {
31 private static final Logger LOG = Logger.getLogger(BatchJob.class);
32 private transient Thread workerThread;
33
34
35 protected String jobDataMapToString(JobDataMap jobDataMap) {
36 StringBuilder buf = new StringBuilder();
37 buf.append("{");
38 Iterator keys = jobDataMap.keySet().iterator();
39 boolean hasNext = keys.hasNext();
40 while (hasNext) {
41 String key = (String) keys.next();
42 Object value = jobDataMap.get(key);
43 buf.append(key).append("=");
44 if (value == jobDataMap) {
45 buf.append("(this map)");
46 }
47 else {
48 buf.append(value);
49 }
50 hasNext = keys.hasNext();
51 if (hasNext) {
52 buf.append(", ");
53 }
54 }
55 buf.append("}");
56 return buf.toString();
57 }
58
59 protected String getMachineName() {
60 try {
61 return InetAddress.getLocalHost().getHostName();
62 }
63 catch (UnknownHostException e) {
64 return "Unknown";
65 }
66 }
67
68 protected String getBatchUserPrincipalId() {
69 return BatchJobUtil.getBatchUserPrincipalId();
70 }
71
72 protected String getBatchUserPrincipalName() {
73 return BatchJobUtil.getBatchUserPrincipalName();
74 }
75
76 }