Skip to content

Commit

Permalink
Quartz 2.0 migration work
Browse files Browse the repository at this point in the history
  • Loading branch information
lahma committed Nov 28, 2010
1 parent fc7abee commit 03daf17
Show file tree
Hide file tree
Showing 14 changed files with 321 additions and 376 deletions.
12 changes: 6 additions & 6 deletions src/Quartz/ITrigger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ namespace Quartz
/// </p>
/// </remarks>
/// <seealso cref="TriggerBuilder" />
/// <seealso cref="CalendarIntervalTrigger" />
/// <seealso cref="SimpleTrigger" />
/// <seealso cref="CronTrigger" />
/// <seealso cref="ICalendarIntervalTrigger" />
/// <seealso cref="ISimpleTrigger" />
/// <seealso cref="ICronTrigger" />
/// <seealso cref="NthIncludedDayTrigger" />
/// <seealso cref="TriggerUtils" />
/// <seealso cref="JobDataMap" />
Expand All @@ -66,14 +66,14 @@ public interface ITrigger : ICloneable, IComparable<ITrigger>
/// <code>Trigger</code> identical to this one.
/// </summary>
/// <returns></returns>
TriggerBuilder<T> GetTriggerBuilder<T>() where T : ITrigger;
ITriggerBuilder<T> GetTriggerBuilder<T>() where T : ITrigger;

/// <summary>
/// Get a <see cref="ScheduleBuilder" /> that is configured to produce a
/// schedule identical to this trigger's schedule.
/// </summary>
/// <returns></returns>
ScheduleBuilder<T> GetScheduleBuilder<T>() where T : ITrigger;
IScheduleBuilder GetScheduleBuilder<T>() where T : ITrigger;

/// <summary>
/// Get or set the description given to the <see cref="Trigger" /> instance by
Expand Down Expand Up @@ -185,7 +185,7 @@ public interface ITrigger : ICloneable, IComparable<ITrigger>
/// Returns the previous time at which the <see cref="Trigger" /> fired.
/// If the trigger has not yet fired, <see langword="null" /> will be returned.
/// </summary>
DateTimeOffset? GetPreviousFireTimeUtc();
DateTimeOffset? PreviousFireTimeUtc { get; }

/// <summary>
/// Returns the next time at which the <see cref="Trigger" /> will fire,
Expand Down
4 changes: 2 additions & 2 deletions src/Quartz/Impl/AdoJobStore/JobStoreSupport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2521,7 +2521,7 @@ protected virtual TriggerFiredBundle TriggerFired(ConnectionAndTransactionHolder
throw new JobPersistenceException("Couldn't insert fired trigger: " + e.Message, e);
}

DateTimeOffset? prevFireTime = trigger.GetPreviousFireTimeUtc();
DateTimeOffset? prevFireTime = trigger.PreviousFireTimeUtc;

// call triggered - to update the trigger's next-fire-time state...
trigger.Triggered(cal);
Expand Down Expand Up @@ -2561,7 +2561,7 @@ protected virtual TriggerFiredBundle TriggerFired(ConnectionAndTransactionHolder
cal,
trigger.Key.Group.Equals(SchedulerConstants.DefaultRecoveryGroup),
SystemTime.UtcNow(),
trigger.GetPreviousFireTimeUtc(),
trigger.PreviousFireTimeUtc,
prevFireTime,
trigger.GetNextFireTimeUtc());
}
Expand Down
414 changes: 190 additions & 224 deletions src/Quartz/Impl/AdoJobStore/StdAdoConstants.cs

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions src/Quartz/Impl/AdoJobStore/StdAdoDelegate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -885,9 +885,9 @@ public virtual int InsertTrigger(ConnectionAndTransactionHolder conn, IOperableT
AddCommandParameter(cmd, "triggerNextFireTime", null);
}
long prevFireTime = -1;
if (trigger.GetPreviousFireTimeUtc().HasValue)
if (trigger.PreviousFireTimeUtc.HasValue)
{
prevFireTime = trigger.GetPreviousFireTimeUtc().Value.Ticks;
prevFireTime = trigger.PreviousFireTimeUtc.Value.Ticks;
}
AddCommandParameter(cmd, "triggerPreviousFireTime", Convert.ToDecimal(prevFireTime));
AddCommandParameter(cmd, "triggerState", state);
Expand Down Expand Up @@ -1002,9 +1002,9 @@ public virtual int UpdateTrigger(ConnectionAndTransactionHolder conn, IOperableT
AddCommandParameter(cmd, "triggerNextFireTime", Convert.ToDecimal(nextFireTime));
long prevFireTime = -1;

if (trigger.GetPreviousFireTimeUtc().HasValue)
if (trigger.PreviousFireTimeUtc.HasValue)
{
prevFireTime = trigger.GetPreviousFireTimeUtc().Value.Ticks;
prevFireTime = trigger.PreviousFireTimeUtc.Value.Ticks;
}
AddCommandParameter(cmd, "triggerPreviousFireTime", Convert.ToDecimal(prevFireTime));
AddCommandParameter(cmd, "triggerState", state);
Expand Down Expand Up @@ -1574,8 +1574,8 @@ public virtual IOperableTrigger SelectTrigger(ConnectionAndTransactionHolder con
trigger = (IOperableTrigger) tb.Build();

trigger.MisfireInstruction = misFireInstr;
trigger.SetNextFireTimeUtc(nft);
trigger.SetPreviousFireTimeUtc(pft);
trigger.NextFireTimeUtc = nft;
trigger.PreviousFireTimeUtc = pft;

setTriggerStateProperties(trigger, triggerProps);
}
Expand Down
37 changes: 18 additions & 19 deletions src/Quartz/Impl/Triggers/AbstractTrigger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ namespace Quartz.Impl.Triggers
/// <author>Sharada Jambula</author>
/// <author>Marko Lahma (.NET)</author>
[Serializable]
public abstract class AbstractTrigger<T> : IOperableTrigger where T : ITrigger
public abstract class AbstractTrigger : IOperableTrigger
{
private string name;
private string group = SchedulerConstants.DefaultGroup;
Expand All @@ -69,7 +69,7 @@ public abstract class AbstractTrigger<T> : IOperableTrigger where T : ITrigger

private DateTimeOffset? endTimeUtc;
private DateTimeOffset startTimeUtc;
private int priority = DefaultPriority;
private int priority = TriggerConstants.DefaultPriority;
[NonSerialized]
private TriggerKey key;

Expand Down Expand Up @@ -227,7 +227,7 @@ public virtual string FullJobName
get { return jobGroup + "." + jobName; }
}

public abstract IScheduleBuilder GetScheduleBuilder();
public abstract IScheduleBuilder GetScheduleBuilder<T>() where T : ITrigger;

/// <summary>
/// Get or set the description given to the <see cref="ITrigger" /> instance by
Expand Down Expand Up @@ -323,7 +323,12 @@ public virtual string FireInstanceId
}

public abstract DateTimeOffset? NextFireTimeUtc { set; }
public abstract DateTimeOffset? PreviousFireTimeUtc { set; }

/// <summary>
/// Returns the previous time at which the <see cref="ITrigger" /> fired.
/// If the trigger has not yet fired, <see langword="null" /> will be returned.
/// </summary>
public abstract DateTimeOffset? PreviousFireTimeUtc { set; get; }

/// <summary>
/// Gets and sets the date/time on which the trigger must stop firing. This
Expand Down Expand Up @@ -581,14 +586,8 @@ public virtual SchedulerInstruction ExecutionComplete(IJobExecutionContext conte
/// <seealso cref="TriggerUtils.ComputeFireTimesBetween(Trigger, ICalendar , DateTimeOffset, DateTimeOffset)" />
/// <returns></returns>
public abstract DateTimeOffset? GetNextFireTimeUtc();

/// <summary>
/// Returns the previous time at which the <see cref="ITrigger" /> fired.
/// If the trigger has not yet fired, <see langword="null" /> will be returned.
/// </summary>
public abstract DateTimeOffset? GetPreviousFireTimeUtc();

/// <summary>
/// <summary>
/// Returns the next time at which the <see cref="ITrigger" /> will fire,
/// after the given time. If the trigger will not fire after the given time,
/// <see langword="null" /> will be returned.
Expand Down Expand Up @@ -736,10 +735,10 @@ public virtual int CompareTo(ITrigger other)
/// </returns>
public override bool Equals(object obj)
{
return Equals(obj as AbstractTrigger<T>);
return Equals(obj as AbstractTrigger);
}

public virtual bool Equals(AbstractTrigger<T> trigger)
public virtual bool Equals(AbstractTrigger trigger)
{
if (trigger == null)
{
Expand Down Expand Up @@ -768,10 +767,10 @@ public override int GetHashCode()
/// </returns>
public virtual object Clone()
{
AbstractTrigger<T> copy;
AbstractTrigger copy;
try
{
copy = (AbstractTrigger<T>)MemberwiseClone();
copy = (AbstractTrigger)MemberwiseClone();

// Shallow copy the jobDataMap. Note that this means that if a user
// modifies a value object in this map from the cloned Trigger
Expand All @@ -789,9 +788,9 @@ public virtual object Clone()
}


public ITriggerBuilder GetTriggerBuilder()
public ITriggerBuilder<T> GetTriggerBuilder<T>() where T : ITrigger
{
TriggerBuilder<T> b = TriggerBuilder<T>.NewTrigger()
TriggerBuilder<ITrigger> b = TriggerBuilder<T>.NewTrigger()
.ForJob(JobKey)
.ModifiedByCalendar(CalendarName)
.UsingJobData(JobDataMap)
Expand All @@ -800,8 +799,8 @@ public ITriggerBuilder GetTriggerBuilder()
.WithIdentity(Key)
.WithPriority(Priority)
.StartAt(StartTimeUtc)
.WithSchedule(GetScheduleBuilder());
return b;
.WithSchedule(GetScheduleBuilder<T>());
return (ITriggerBuilder<T>) b;
}
}
}
Expand Down
24 changes: 5 additions & 19 deletions src/Quartz/Impl/Triggers/CalendarIntervalTriggerImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ namespace Quartz.Impl.Triggers
/// <since>1.2</since>
/// <author>James House</author>
/// <author>Marko Lahma (.NET)</author>
public class CalendarIntervalTriggerImpl : AbstractTrigger<ICalendarIntervalTrigger>, ICalendarIntervalTrigger
public class CalendarIntervalTriggerImpl : AbstractTrigger, ICalendarIntervalTrigger
{
private const int YearToGiveupSchedulingAt = 2299;

Expand Down Expand Up @@ -507,9 +507,10 @@ public override SchedulerInstruction ExecutionComplete(IJobExecutionContext cont
/// Returns the previous time at which the <see cref="DateIntervalTrigger" /> fired.
/// If the trigger has not yet fired, <see langword="null" /> will be returned.
/// </summary>
public override DateTimeOffset? GetPreviousFireTimeUtc()
public override DateTimeOffset? PreviousFireTimeUtc
{
return previousFireTime;
get { return previousFireTime; }
set { previousFireTime = value; }
}

/**
Expand All @@ -527,21 +528,6 @@ public override DateTimeOffset? NextFireTimeUtc
set { this.nextFireTime = value; }
}

/**
* <p>
* Set the previous time at which the <code>DateIntervalTrigger</code> fired.
* </p>
*
* <p>
* <b>This method should not be invoked by client code.</b>
* </p>
*/

public override DateTimeOffset? PreviousFireTimeUtc
{
set { this.previousFireTime = value; }
}

/// <summary>
/// Returns the next time at which the <see cref="DateIntervalTrigger" /> will fire,
/// after the given time. If the trigger will not fire after the given time,
Expand Down Expand Up @@ -816,7 +802,7 @@ public override void Validate()
*
* @see #getTriggerBuilder()
*/
public override ScheduleBuilder<ICalendarIntervalTrigger> GetScheduleBuilder()
public override IScheduleBuilder GetScheduleBuilder()
{

CalendarIntervalScheduleBuilder cb = CalendarIntervalScheduleBuilder.CalendarIntervalSchedule()
Expand Down
22 changes: 11 additions & 11 deletions src/Quartz/Impl/Triggers/CronTriggerImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ namespace Quartz.Impl.Triggers
/// <author>Contributions from Mads Henderson</author>
/// <author>Marko Lahma (.NET)</author>
[Serializable]
public class CronTriggerImpl : AbstractTrigger<ICronTrigger>, ICronTrigger
public class CronTriggerImpl : AbstractTrigger, ICronTrigger
{
protected internal const int YearToGiveupSchedulingAt = 2299;
private CronExpression cronEx;
Expand Down Expand Up @@ -485,18 +485,18 @@ public override DateTimeOffset? EndTimeUtc
return nextFireTimeUtc;
}

/// <summary>
/// Returns the previous time at which the <see cref="Trigger" /> fired.
/// If the trigger has not yet fired, <see langword="null" /> will be returned.
/// </summary>
/// <returns></returns>
public override DateTimeOffset? GetPreviousFireTimeUtc()
{
return previousFireTimeUtc;
}
/// <summary>
/// Returns the previous time at which the <see cref="Trigger" /> fired.
/// If the trigger has not yet fired, <see langword="null" /> will be returned.
/// </summary>
/// <value></value>
public override DateTimeOffset? PreviousFireTimeUtc
{
get { return previousFireTimeUtc; }
}


/// <summary>
/// <summary>
/// Sets the next fire time.
/// <p>
/// <b>This method should not be invoked by client code.</b>
Expand Down
Loading

0 comments on commit 03daf17

Please sign in to comment.