当前位置: 首页>>代码示例>>Java>>正文


Java SchedulingPattern类代码示例

本文整理汇总了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;
}
 
开发者ID:metasfresh,项目名称:metasfresh,代码行数:31,代码来源:MScheduler.java

示例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;
}
 
开发者ID:enioka,项目名称:jqm,代码行数:27,代码来源:CronScheduler.java

示例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;
}
 
开发者ID:wolfboys,项目名称:opencron,代码行数:9,代码来源:VerifyController.java

示例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);
}
 
开发者ID:treasure-data,项目名称:digdag,代码行数:34,代码来源:WeeklySchedulerFactory.java

示例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;
}
 
开发者ID:treasure-data,项目名称:digdag,代码行数:15,代码来源:CronScheduler.java

示例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();
}
 
开发者ID:krrrr38,项目名称:jabot,代码行数:32,代码来源:HealthCheckHandler.java

示例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;
}
 
开发者ID:donsez,项目名称:tagl,代码行数:8,代码来源:MyTaskCollector.java

示例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;		
}
 
开发者ID:smrjan,项目名称:job4j,代码行数:10,代码来源:CronUtil.java


注:本文中的it.sauronsoftware.cron4j.SchedulingPattern类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。