01: /*******************************************************************************
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing,
13: * software distributed under the License is distributed on an
14: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15: * KIND, either express or implied. See the License for the
16: * specific language governing permissions and limitations
17: * under the License.
18: *******************************************************************************/package org.ofbiz.service.job;
19:
20: /**
21: * Abstract Service Job - Invokes a service
22: */
23: public abstract class AbstractJob implements Job {
24:
25: public static final String module = AbstractJob.class.getName();
26:
27: protected long runtime = -1;
28: protected long sequence = 0;
29: private String jobId;
30: private String jobName;
31: private boolean queued = false;
32:
33: protected AbstractJob(String jobId, String jobName) {
34: this .jobId = jobId;
35: this .jobName = jobName;
36: }
37:
38: /**
39: * Returns the time to run in milliseconds.
40: */
41: public long getRuntime() {
42: return runtime;
43: }
44:
45: /**
46: * Returns true if this job is still valid.
47: */
48: public boolean isValid() {
49: if (runtime > 0)
50: return true;
51: return false;
52: }
53:
54: /**
55: * Returns the ID of this Job.
56: */
57: public String getJobId() {
58: return this .jobId;
59: }
60:
61: /**
62: * Returns the name of this Job.
63: */
64: public String getJobName() {
65: return this .jobName;
66: }
67:
68: /**
69: * Flags this job as 'is-queued'
70: */
71: public void queue() throws InvalidJobException {
72: this .queued = true;
73: }
74:
75: /**
76: * Executes the Job.
77: */
78: public abstract void exec() throws InvalidJobException;
79: }
|