Browse Source

polishing

3.0.x
Juergen Hoeller 16 years ago
parent
commit
b90fa49ebc
  1. 23
      org.springframework.context/src/main/java/org/springframework/scheduling/support/CronTrigger.java

23
org.springframework.context/src/main/java/org/springframework/scheduling/support/CronTrigger.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2009 the original author or authors.
* Copyright 2002-2010 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -34,25 +34,27 @@ public class CronTrigger implements Trigger { @@ -34,25 +34,27 @@ public class CronTrigger implements Trigger {
private final CronSequenceGenerator sequenceGenerator;
/**
* Build a {@link CronTrigger} from the pattern provided.
* Build a {@link CronTrigger} from the pattern provided in the default time zone.
* @param cronExpression a space-separated list of time fields,
* following cron expression conventions
* @param timeZone a time zone in which the trigger times will be generated
*/
public CronTrigger(String cronExpression, TimeZone timeZone) {
this.sequenceGenerator = new CronSequenceGenerator(cronExpression, timeZone);
public CronTrigger(String cronExpression) {
this(cronExpression, TimeZone.getDefault());
}
/**
* Build a {@link CronTrigger} from the pattern provided in the default time zone.
* Build a {@link CronTrigger} from the pattern provided.
* @param cronExpression a space-separated list of time fields,
* following cron expression conventions
* @param timeZone a time zone in which the trigger times will be generated
*/
public CronTrigger(String cronExpression) {
this(cronExpression, TimeZone.getDefault());
public CronTrigger(String cronExpression, TimeZone timeZone) {
this.sequenceGenerator = new CronSequenceGenerator(cronExpression, timeZone);
}
public Date nextExecutionTime(TriggerContext triggerContext) {
Date date = triggerContext.lastCompletionTime();
if (date == null) {
@ -61,10 +63,11 @@ public class CronTrigger implements Trigger { @@ -61,10 +63,11 @@ public class CronTrigger implements Trigger {
return this.sequenceGenerator.next(date);
}
@Override
public boolean equals(Object obj) {
return (this == obj || (obj instanceof CronTrigger && this.sequenceGenerator
.equals(((CronTrigger) obj).sequenceGenerator)));
return (this == obj || (obj instanceof CronTrigger &&
this.sequenceGenerator.equals(((CronTrigger) obj).sequenceGenerator)));
}
@Override

Loading…
Cancel
Save