package foundation.schedule;
|
|
import foundation.dao.preload.Bucket;
|
import foundation.json.IJSONProvider;
|
import foundation.json.IJSONWriter;
|
|
public class ScheduleBucket extends Bucket<ScheduleBatch> implements IJSONProvider {
|
|
private static ScheduleBucket instance;
|
|
public static synchronized ScheduleBucket getInstance() {
|
if (instance == null) {
|
instance = new ScheduleBucket();
|
}
|
|
return instance;
|
}
|
|
public synchronized void loadOneJob(String id, ScheduleJob job) {
|
String batchId = job.getBatchId();
|
ScheduleBatch batch = get(batchId);
|
|
if (batch == null) {
|
return;
|
}
|
|
batch.loadOneJob(job);
|
}
|
|
public static void clear() {
|
instance = null;
|
}
|
|
@Override
|
public void writeJSON(IJSONWriter writer) {
|
writer.beginArray();
|
|
for (ScheduleBatch batch: this) {
|
batch.writeJSON(writer);
|
}
|
|
writer.endArray();
|
}
|
|
}
|