Skip to content
Browse files

Minor cleanup, slowly moving everything to direction of

JDBC store conventions.
  • Loading branch information...
1 parent 1f8f1a1 commit 6e5648bd8879023eb7f968a2bb14a41a4fb3055e @ifesdjeen ifesdjeen committed Jun 10, 2012
View
33 src/main/java/com/novemberain/quartz/mongodb/Constants.java
@@ -0,0 +1,33 @@
+package com.novemberain.quartz.mongodb;
+
+public interface Constants {
+
+ public static final String JOB_DESCRIPTION = "jobDescription";
+ public static final String JOB_CLASS = "jobClass";
+ public static final String TRIGGER_CALENDAR_NAME = "calendarName";
+ public static final String TRIGGER_DESCRIPTION = "description";
+ public static final String TRIGGER_END_TIME = "endTime";
+ public static final String TRIGGER_FINAL_FIRE_TIME = "finalFireTime";
+ public static final String TRIGGER_FIRE_INSTANCE_ID = "fireInstanceId";
+ public static final String TRIGGER_MISFIRE_INSTRUCTION = "misfireInstruction";
+ public static final String TRIGGER_NEXT_FIRE_TIME = "nextFireTime";
+ public static final String TRIGGER_PREVIOUS_FIRE_TIME = "previousFireTime";
+ public static final String TRIGGER_PRIORITY = "priority";
+ public static final String TRIGGER_START_TIME = "startTime";
+ public static final String TRIGGER_JOB_ID = "jobId";
+ public static final String TRIGGER_CLASS = "class";
+ public static final String TRIGGER_STATE = "state";
+ public static final String CALENDAR_NAME = "name";
+ public static final String CALENDAR_SERIALIZED_OBJECT = "serializedObject";
+ public static final String LOCK_INSTANCE_ID = "instanceId";
+ public static final String LOCK_TIME = "time";
+
+ public static final String STATE_WAITING = "waiting";
+ public static final String STATE_DELETED = "deleted";
+ public static final String STATE_COMPLETE = "complete";
+ public static final String STATE_PAUSED = "paused";
+ public static final String STATE_PAUSED_BLOCKED = "pausedBlocked";
+ public static final String STATE_BLOCKED = "blocked";
+ public static final String STATE_ERROR = "error";
+
+}
View
38 src/main/java/com/novemberain/quartz/mongodb/MongoDBJobStore.java
@@ -27,39 +27,12 @@
import java.net.UnknownHostException;
import java.util.*;
+import com.novemberain.quartz.mongodb.Constants;
import static com.novemberain.quartz.mongodb.Keys.*;
-public class MongoDBJobStore implements JobStore {
+public class MongoDBJobStore implements JobStore, Constants {
protected final Logger log = LoggerFactory.getLogger(getClass());
- private static final String JOB_DESCRIPTION = "jobDescription";
- private static final String JOB_CLASS = "jobClass";
- private static final String TRIGGER_CALENDAR_NAME = "calendarName";
- private static final String TRIGGER_DESCRIPTION = "description";
- private static final String TRIGGER_END_TIME = "endTime";
- private static final String TRIGGER_FINAL_FIRE_TIME = "finalFireTime";
- private static final String TRIGGER_FIRE_INSTANCE_ID = "fireInstanceId";
- private static final String TRIGGER_MISFIRE_INSTRUCTION = "misfireInstruction";
- private static final String TRIGGER_NEXT_FIRE_TIME = "nextFireTime";
- private static final String TRIGGER_PREVIOUS_FIRE_TIME = "previousFireTime";
- private static final String TRIGGER_PRIORITY = "priority";
- private static final String TRIGGER_START_TIME = "startTime";
- private static final String TRIGGER_JOB_ID = "jobId";
- private static final String TRIGGER_CLASS = "class";
- private static final String TRIGGER_STATE = "state";
- private static final String CALENDAR_NAME = "name";
- private static final String CALENDAR_SERIALIZED_OBJECT = "serializedObject";
- private static final String LOCK_INSTANCE_ID = "instanceId";
- private static final String LOCK_TIME = "time";
-
- public static final String STATE_WAITING = "waiting";
- public static final String STATE_DELETED = "deleted";
- public static final String STATE_COMPLETE = "complete";
- public static final String STATE_PAUSED = "paused";
- public static final String STATE_PAUSED_BLOCKED = "pausedBlocked";
- public static final String STATE_BLOCKED = "blocked";
- public static final String STATE_ERROR = "error";
-
public static final DBObject KEY_AND_GROUP_FIELDS = BasicDBObjectBuilder.start().
append(KEY_GROUP, 1).
append(KEY_NAME, 1).
@@ -83,7 +56,7 @@
protected long misfireThreshold = 5000l;
private long triggerTimeoutMillis = 10 * 60 * 1000L;
- private List<TriggerPersistenceHelper> persistenceHelpers = new ArrayList<TriggerPersistenceHelper>();
+ private List<TriggerPersistenceHelper> persistenceHelpers;
private QueryHelper queryHelper;
public void initialize(ClassLoadHelper loadHelper, SchedulerSignaler signaler) throws SchedulerConfigException {
@@ -131,6 +104,9 @@ public boolean isClustered() {
return true;
}
+ /**
+ * Job and Trigger storage Methods
+ */
public void storeJobAndTrigger(JobDetail newJob, OperableTrigger newTrigger) throws ObjectAlreadyExistsException,
JobPersistenceException {
ObjectId jobId = storeJobInMongo(newJob, false);
@@ -944,6 +920,8 @@ protected DBObject findTriggerDocumentByKey(TriggerKey key) {
}
private void initializeHelpers() {
+ this.persistenceHelpers = new ArrayList<TriggerPersistenceHelper>();
+
persistenceHelpers.add(new SimpleTriggerPersistenceHelper());
persistenceHelpers.add(new CalendarIntervalTriggerPersistenceHelper());
persistenceHelpers.add(new CronTriggerPersistenceHelper());

0 comments on commit 6e5648b

Please sign in to comment.
Something went wrong with that request. Please try again.