2 * ============LICENSE_START========================================================================
\r
3 * ONAP : tr-069-adapter
\r
4 * =================================================================================================
\r
5 * Copyright (C) 2020 CommScope Inc Intellectual Property.
\r
6 * =================================================================================================
\r
7 * This tr-069-adapter software file is distributed by CommScope Inc under the Apache License,
\r
8 * Version 2.0 (the "License"); you may not use this file except in compliance with the License. You
\r
9 * may obtain a copy of the License at
\r
11 * http://www.apache.org/licenses/LICENSE-2.0
\r
13 * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
\r
14 * either express or implied. See the License for the specific language governing permissions and
\r
15 * limitations under the License.
\r
16 * ===============LICENSE_END=======================================================================
\r
20 package org.commscope.tr069adapter.common.scheduler;
\r
22 import static org.commscope.tr069adapter.common.scheduler.impl.QuartzSchedulerConstants.JOB_APPENDER;
\r
24 import java.io.Serializable;
\r
25 import java.util.HashMap;
\r
26 import java.util.Map;
\r
27 import java.util.Set;
\r
29 public class ExecutionContext implements Serializable {
\r
34 private static final long serialVersionUID = 8182423848241219082L;
\r
37 * String representing the bean id which by which is job is configured in the spring container.
\r
39 private String subSystemName;
\r
41 private String jobName;
\r
43 private String jobId;
\r
45 private String jobGroup;
\r
48 * Constructor for getting the execution context object. Need to pass a string which represents
\r
49 * the bean id that is configured in spring container.
\r
51 * @param subSystemName - String object which is bean id of the job that is to be executed.
\r
53 public ExecutionContext(String subSystemName, String jobName) {
\r
54 if (null == subSystemName || "".equals(subSystemName))
\r
55 throw new InstantiationError("Subsystem name Can not be null or empty");
\r
56 this.subSystemName = subSystemName;
\r
57 if (null == jobName || "".equals(jobName))
\r
58 throw new InstantiationError("Job name Can not be null or empty");
\r
59 this.jobName = jobName;
\r
63 * Constructor for getting the execution context object. Need to pass a string which represents
\r
64 * the bean id that is configured in spring container.
\r
66 * @param subSystemName - String object which is bean id of the job that is to be executed.
\r
68 public ExecutionContext(String jobId, String subSystemName, String jobName) {
\r
69 if (null == subSystemName || "".equals(subSystemName))
\r
70 throw new InstantiationError("Subsystem name Can not be null or empty");
\r
71 this.subSystemName = subSystemName;
\r
72 if (null == jobName || "".equals(jobName))
\r
73 throw new InstantiationError("Job name Can not be null or empty");
\r
74 this.jobName = jobName;
\r
78 public String getJobName() {
\r
82 public String getSubSystemName() {
\r
83 return subSystemName;
\r
86 private transient Map<String, Object> context = new HashMap<>();
\r
89 * Can be used to get some job related data, at the time of job execution.
\r
94 public Object getJobData(String key) {
\r
95 return context.get(key);
\r
99 * Can be used add some job related data at the time of scheduling the job. Note: This data can be
\r
100 * retrieved later at the time of execution by the Job implementation.
\r
105 public void addJobData(String key, Object value) {
\r
106 context.put(key, value);
\r
110 * This method can be used to get the all the job data parameter names which can be used to
\r
111 * iterate through the all job data parameters.
\r
113 * @return - String set.
\r
115 public Set<String> getJobDatakeySet() {
\r
116 return context.keySet();
\r
119 public String getJobId() {
\r
120 int index = jobId.lastIndexOf(JOB_APPENDER);
\r
122 jobId = jobId.substring(0, index);
\r
124 return jobId; // remove appender
\r
127 public String getJobGroup() {
\r
131 public void setJobGroup(String jobGroup) {
\r
132 this.jobGroup = jobGroup;
\r