本文整理汇总了Java中it.sauronsoftware.cron4j.SchedulingPattern类的典型用法代码示例。如果您正苦于以下问题:Java SchedulingPattern类的具体用法?Java SchedulingPattern怎么用?Java SchedulingPattern使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SchedulingPattern类属于it.sauronsoftware.cron4j包,在下文中一共展示了SchedulingPattern类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: beforeSave
import it.sauronsoftware.cron4j.SchedulingPattern; //导入依赖的package包/类
/**
* Before Save
* @param newRecord new
* @return true
*/
@Override
protected boolean beforeSave(boolean newRecord)
{
// Set Schedule Type & Frequencies
if (SCHEDULETYPE_Frequency.equals(getScheduleType()))
{
if (getFrequencyType() == null)
setFrequencyType(FREQUENCYTYPE_Day);
if (getFrequency() < 1)
setFrequency(1);
setCronPattern(null);
}
else if (SCHEDULETYPE_CronSchedulingPattern.equals(getScheduleType()))
{
String pattern = getCronPattern();
if (pattern != null && pattern.trim().length() > 0)
{
if (!SchedulingPattern.validate(pattern))
{
throw new AdempiereException("@[email protected]");
}
}
}
return true;
}
示例2: getTasks
import it.sauronsoftware.cron4j.SchedulingPattern; //导入依赖的package包/类
@Override
public TaskTable getTasks()
{
TaskTable res = new TaskTable();
DbConn cnx = null;
try
{
cnx = Helpers.getNewDbSession();
for (ScheduledJob sj : ScheduledJob.select(cnx, "sj_select_all"))
{
res.add(new SchedulingPattern(sj.getCronExpression()), new JqmTask(sj));
}
// Also check delayed jobs
cnx.runUpdate("ji_update_delayed");
cnx.commit();
}
finally
{
Helpers.closeQuietly(cnx);
}
return res;
}
示例3: validateCronExp
import it.sauronsoftware.cron4j.SchedulingPattern; //导入依赖的package包/类
@RequestMapping(value = "exp.do",method= RequestMethod.POST)
@ResponseBody
public boolean validateCronExp(Integer cronType, String cronExp) {
boolean pass = false;
if (cronType == 0) pass = SchedulingPattern.validate(cronExp);
if (cronType == 1) pass = CronExpression.isValidExpression(cronExp);
return pass;
}
示例4: newScheduler
import it.sauronsoftware.cron4j.SchedulingPattern; //导入依赖的package包/类
@Override
public Scheduler newScheduler(Config config, ZoneId timeZone)
{
String desc = config.getOptional("_command", String.class).or(() -> config.get("at", String.class));
String[] fragments = desc.split(",", 2);
if (fragments.length != 2) {
throw new ConfigException("weekly>: scheduler requires day,hh:mm:ss format: " + desc);
}
String day = fragments[0].trim();
String time = fragments[1].trim();
// cron4j incorrectly parses negative day of week as positive.
try {
int dayNumber = Integer.parseInt(day);
if (dayNumber < 0) {
throw new ConfigException("weekly>: invalid day: " + day);
}
} catch (NumberFormatException ignore) {
// Not an integer, validate using SchedulingPattern.validate.
}
long dailyDelay = parseAt("weekly>", time);
String cronPattern = "0 0 * * " + day;
boolean valid = SchedulingPattern.validate(cronPattern);
if (!valid) {
throw new ConfigException("weekly>: scheduler requires day,hh:mm:ss format: " + desc);
}
return new CronScheduler(cronPattern, timeZone, dailyDelay);
}
示例5: CronScheduler
import it.sauronsoftware.cron4j.SchedulingPattern; //导入依赖的package包/类
CronScheduler(String cronPattern, ZoneId timeZone, long delaySeconds)
{
this.pattern = new SchedulingPattern(cronPattern) {
// workaround for a bug of cron4j:
// https://gist.github.com/frsyuki/618c4e6c1f5f876e4ee74b9da2fd37c0
@Override
public boolean match(long millis)
{
return match(TimeZone.getTimeZone(timeZone), millis);
}
};
this.timeZone = timeZone;
this.delaySeconds = delaySeconds;
}
示例6: afterSetup
import it.sauronsoftware.cron4j.SchedulingPattern; //导入依赖的package包/类
@Override
public void afterSetup(Map<String, String> options) {
intervalCronSyntax = optionString(options, OPTIONS_INTERVAL_CRON_SYNTAX, DEFAULT_INTERVAL_CRON_SYNTAX);
alertMessagePrefix = optionString(options, OPTIONS_ALERT_PREFIX, DEFAULT_ALERT_PREFIX);
connectTimeout = optionInteger(options, OPTIONS_CONNECT_TIMEOUT, DEFAULT_CONNECT_TIMEOUT);
socketTimeout = optionInteger(options, OPTIONS_SOCKET_TIMEOUT, DEFAULT_SOCKET_TIMEOUT);
userAgent = optionString(options, OPTIONS_USER_AGENT, DEFAULT_USER_AGENT);
customHeaderName = optionString(options, OPTIONS_CUSTOM_HEADER_NAME, DEFAULT_CUSTOM_HEADER_NAME);
customHeaderValue = optionString(options, OPTIONS_CUSTOM_HEADER_VALUE, DEFAULT_CUSTOM_HEADER_VALUE);
new SchedulingPattern(intervalCronSyntax); // just check cron syntax is valid without exception
jobs = Collections.synchronizedList(new ArrayList<>());
try {
List<HealthCheckJob> oldJobs = new ArrayList<>();
for (String storedData : getAll().values()) {
oldJobs.add(OBJECT_MAPPER.readValue(storedData, HealthCheckJob.class));
}
clear();
for (HealthCheckJob job : oldJobs) {
if (job.getActiveStatus() == ActiveStatus.ACTIVE) {
job = scheduleJob(job);
}
store(job.getScheduledId(), OBJECT_MAPPER.writeValueAsString(job));
jobs.add(job);
}
} catch (JabotBrainException | IOException e) {
log.error("Failed to load jobs: " + e.getMessage(), e);
}
scheduler.start();
}
示例7: getTasks
import it.sauronsoftware.cron4j.SchedulingPattern; //导入依赖的package包/类
public TaskTable getTasks() {
SchedulingPattern pattern = new SchedulingPattern("* * * * *");
Task task = new MyTask();
TaskTable ret = new TaskTable();
ret.add(pattern, task);
return ret;
}
示例8: getNextScheduledTime
import it.sauronsoftware.cron4j.SchedulingPattern; //导入依赖的package包/类
public static Date getNextScheduledTime(String cronExp, String timeZone){
Date nextScheduledTime = null;
if (cronExp!=null && SchedulingPattern.validate(cronExp)) {
Predictor predictor = new Predictor(cronExp);
predictor.setTimeZone(TimeZone.getTimeZone(timeZone));
nextScheduledTime = predictor.nextMatchingDate();
}
return nextScheduledTime;
}