Skip to content

Commit

Permalink
Merge pull request #1222 from bcode2/quartz-2.4-refactor_remove-depre…
Browse files Browse the repository at this point in the history
…cated-contructor-and-use-the-builder

refactor: remove some deprecations
  • Loading branch information
jhouserizer authored Oct 25, 2024
2 parents 12729ff + 9bb7c5e commit f76729e
Show file tree
Hide file tree
Showing 5 changed files with 123 additions and 252 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3518,14 +3518,10 @@ protected void clusterRecover(Connection conn, List<SchedulerStateRecord> failed
// handle jobs marked for recovery that were not fully
// executed..
if (jobExists(conn, jKey)) {
@SuppressWarnings("deprecation")
SimpleTriggerImpl rcvryTrig = new SimpleTriggerImpl(
"recover_"
+ rec.getSchedulerInstanceId()
+ "_"
+ recoverIds++,
Scheduler.DEFAULT_RECOVERY_GROUP,
new Date(ftRec.getScheduleTimestamp()));
SimpleTriggerImpl rcvryTrig = new SimpleTriggerImpl();
rcvryTrig.setName("recover_" + rec.getSchedulerInstanceId() + "_" + recoverIds++);
rcvryTrig.setGroup(Scheduler.DEFAULT_RECOVERY_GROUP);
rcvryTrig.setStartTime(new Date(ftRec.getScheduleTimestamp()));
rcvryTrig.setJobName(jKey.getName());
rcvryTrig.setJobGroup(jKey.getGroup());
rcvryTrig.setMisfireInstruction(SimpleTrigger.MISFIRE_INSTRUCTION_IGNORE_MISFIRE_POLICY);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -482,10 +482,11 @@ public List<OperableTrigger> selectTriggersForRecoveringJobs(Connection conn)
long firedTime = rs.getLong(COL_FIRED_TIME);
long scheduledTime = rs.getLong(COL_SCHED_TIME);
int priority = rs.getInt(COL_PRIORITY);
@SuppressWarnings("deprecation")
SimpleTriggerImpl rcvryTrig = new SimpleTriggerImpl("recover_"
+ instanceId + "_" + dumId++,
Scheduler.DEFAULT_RECOVERY_GROUP, new Date(scheduledTime));

SimpleTriggerImpl rcvryTrig = new SimpleTriggerImpl();
rcvryTrig.setName("recover_" + instanceId + "_" + dumId++);
rcvryTrig.setGroup(Scheduler.DEFAULT_RECOVERY_GROUP);
rcvryTrig.setStartTime(new Date(scheduledTime));
rcvryTrig.setJobName(jobName);
rcvryTrig.setJobGroup(jobGroup);
rcvryTrig.setPriority(priority);
Expand Down
187 changes: 1 addition & 186 deletions quartz/src/main/java/org/quartz/impl/triggers/AbstractTrigger.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@

package org.quartz.impl.triggers;

import java.util.Date;

import org.quartz.Calendar;
import org.quartz.CronTrigger;
import org.quartz.JobDataMap;
Expand All @@ -34,7 +32,6 @@
import org.quartz.Trigger;
import org.quartz.TriggerBuilder;
import org.quartz.TriggerKey;
import org.quartz.TriggerUtils;
import org.quartz.spi.OperableTrigger;


Expand Down Expand Up @@ -87,7 +84,7 @@ public abstract class AbstractTrigger<T extends Trigger> implements OperableTrig
private JobDataMap jobDataMap;

@SuppressWarnings("unused")
private final boolean volatility = false; // still here for serialization backward compatibility
private static final boolean VOLATILITY = false; // still here for serialization backward compatibility

private String calendarName = null;

Expand Down Expand Up @@ -182,13 +179,6 @@ public AbstractTrigger(String name, String group, String jobName, String jobGrou
setJobGroup(jobGroup);
}

/*
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*
* Interface.
*
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/

/**
* <p>
Expand Down Expand Up @@ -469,43 +459,7 @@ public void setPriority(int priority) {
this.priority = priority;
}

/**
* <p>
* This method should not be used by the Quartz client.
* </p>
*
* <p>
* Called when the <code>{@link Scheduler}</code> has decided to 'fire'
* the trigger (execute the associated <code>Job</code>), in order to
* give the <code>Trigger</code> a chance to update itself for its next
* triggering (if any).
* </p>
*
* @see #executionComplete(JobExecutionContext, JobExecutionException)
*/
public abstract void triggered(Calendar calendar);

/**
* <p>
* This method should not be used by the Quartz client.
* </p>
*
* <p>
* Called by the scheduler at the time a <code>Trigger</code> is first
* added to the scheduler, in order to have the <code>Trigger</code>
* compute its first fire time, based on any associated calendar.
* </p>
*
* <p>
* After this method has been called, <code>getNextFireTime()</code>
* should return a valid answer.
* </p>
*
* @return the first time at which the <code>Trigger</code> will be fired
* by the scheduler, which is also the same value <code>getNextFireTime()</code>
* will return (until after the first firing of the <code>Trigger</code>).
*/
public abstract Date computeFirstFireTime(Calendar calendar);

/**
* <p>
Expand Down Expand Up @@ -550,109 +504,7 @@ public CompletedExecutionInstruction executionComplete(JobExecutionContext conte

return CompletedExecutionInstruction.NOOP;
}

/**
* <p>
* Used by the <code>{@link Scheduler}</code> to determine whether or not
* it is possible for this <code>Trigger</code> to fire again.
* </p>
*
* <p>
* If the returned value is <code>false</code> then the <code>Scheduler</code>
* may remove the <code>Trigger</code> from the <code>{@link org.quartz.spi.JobStore}</code>.
* </p>
*/
public abstract boolean mayFireAgain();

/**
* <p>
* Get the time at which the <code>Trigger</code> should occur.
* </p>
*/
public abstract Date getStartTime();

/**
* <p>
* The time at which the trigger's scheduling should start. May or may not
* be the first actual fire time of the trigger, depending upon the type of
* trigger and the settings of the other properties of the trigger. However
* the first actual first time will not be before this date.
* </p>
* <p>
* Setting a value in the past may cause a new trigger to compute a first
* fire time that is in the past, which may cause an immediate misfire
* of the trigger.
* </p>
*/
public abstract void setStartTime(Date startTime);

/**
* <p>
* Set the time at which the <code>Trigger</code> should quit repeating -
* regardless of any remaining repeats (based on the trigger's particular
* repeat settings).
* </p>
*
* @see TriggerUtils#computeEndTimeToAllowParticularNumberOfFirings(org.quartz.spi.OperableTrigger, org.quartz.Calendar, int)
*/
public abstract void setEndTime(Date endTime);

/**
* <p>
* Get the time at which the <code>Trigger</code> should quit repeating -
* regardless of any remaining repeats (based on the trigger's particular
* repeat settings).
* </p>
*
* @see #getFinalFireTime()
*/
public abstract Date getEndTime();

/**
* <p>
* Returns the next time at which the <code>Trigger</code> is scheduled to fire. If
* the trigger will not fire again, <code>null</code> will be returned. Note that
* the time returned can possibly be in the past, if the time that was computed
* for the trigger to next fire has already arrived, but the scheduler has not yet
* been able to fire the trigger (which would likely be due to lack of resources
* e.g. threads).
* </p>
*
* <p>The value returned is not guaranteed to be valid until after the <code>Trigger</code>
* has been added to the scheduler.
* </p>
*
* @see TriggerUtils#computeFireTimesBetween(org.quartz.spi.OperableTrigger, org.quartz.Calendar, java.util.Date, java.util.Date)
*/
public abstract Date getNextFireTime();

/**
* <p>
* Returns the previous time at which the <code>Trigger</code> fired.
* If the trigger has not yet fired, <code>null</code> will be returned.
*/
public abstract Date getPreviousFireTime();

/**
* <p>
* Returns the next time at which the <code>Trigger</code> will fire,
* after the given time. If the trigger will not fire after the given time,
* <code>null</code> will be returned.
* </p>
*/
public abstract Date getFireTimeAfter(Date afterTime);

/**
* <p>
* Returns the last time at which the <code>Trigger</code> will fire, if
* the Trigger will repeat indefinitely, null will be returned.
* </p>
*
* <p>
* Note that the return time *may* be in the past.
* </p>
*/
public abstract Date getFinalFireTime();

/**
* <p>
Expand Down Expand Up @@ -704,43 +556,6 @@ public int getMisfireInstruction() {
return misfireInstruction;
}

/**
* <p>
* This method should not be used by the Quartz client.
* </p>
*
* <p>
* To be implemented by the concrete classes that extend this class.
* </p>
*
* <p>
* The implementation should update the <code>Trigger</code>'s state
* based on the MISFIRE_INSTRUCTION_XXX that was selected when the <code>Trigger</code>
* was created.
* </p>
*/
public abstract void updateAfterMisfire(Calendar cal);

/**
* <p>
* This method should not be used by the Quartz client.
* </p>
*
* <p>
* To be implemented by the concrete class.
* </p>
*
* <p>
* The implementation should update the <code>Trigger</code>'s state
* based on the given new version of the associated <code>Calendar</code>
* (the state should be updated so that it's next fire time is appropriate
* given the Calendar's new settings).
* </p>
*
* @param cal the modifying calendar
*/
public abstract void updateWithNewCalendar(Calendar cal, long misfireThreshold);

/**
* <p>
* Validates whether the properties of the <code>JobDetail</code> are
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public class SimpleTriggerImpl extends AbstractTrigger<SimpleTrigger> implements

private int timesTriggered = 0;

private final boolean complete = false;
private static final boolean COMPLETE = false;

/*
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -313,7 +313,7 @@ public void setStartTime(Date startTime) {
}

Date eTime = getEndTime();
if (eTime != null && startTime != null && eTime.before(startTime)) {
if (eTime != null && eTime.before(startTime)) {
throw new IllegalArgumentException(
"End time cannot be before start time");
}
Expand All @@ -324,7 +324,7 @@ public void setStartTime(Date startTime) {
/**
* <p>
* Get the time at which the <code>SimpleTrigger</code> should quit
* repeating - even if repeastCount isn't yet satisfied.
* repeating - even if repeatCount isn't yet satisfied.
* </p>
*
* @see #getFinalFireTime()
Expand Down Expand Up @@ -432,11 +432,7 @@ protected boolean validateMisfireInstruction(int misfireInstruction) {
return false;
}

if (misfireInstruction > MISFIRE_INSTRUCTION_RESCHEDULE_NEXT_WITH_EXISTING_COUNT) {
return false;
}

return true;
return misfireInstruction <= MISFIRE_INSTRUCTION_RESCHEDULE_NEXT_WITH_EXISTING_COUNT;
}

/**
Expand Down Expand Up @@ -476,7 +472,6 @@ public void updateAfterMisfire(Calendar cal) {
} else if (getRepeatCount() == REPEAT_INDEFINITELY) {
instr = MISFIRE_INSTRUCTION_RESCHEDULE_NEXT_WITH_REMAINING_COUNT;
} else {
// if (getRepeatCount() > 0)
instr = MISFIRE_INSTRUCTION_RESCHEDULE_NOW_WITH_EXISTING_REPEAT_COUNT;
}
} else if (instr == MISFIRE_INSTRUCTION_FIRE_NOW && getRepeatCount() != 0) {
Expand Down Expand Up @@ -738,7 +733,7 @@ public void setPreviousFireTime(Date previousFireTime) {
*/
@Override
public Date getFireTimeAfter(Date afterTime) {
if (complete) {
if (COMPLETE) {
return null;
}

Expand Down
Loading

0 comments on commit f76729e

Please sign in to comment.