Search in sources :

Example 1 with CronScheduleBuilder

use of org.apache.openejb.quartz.CronScheduleBuilder in project tomee by apache.

the class JobSpec method validate.

// -- ActivationSpec methods
@SuppressWarnings("unchecked")
@Override
public void validate() throws InvalidPropertyException {
    if (invalidProperty != null) {
        throw invalidProperty;
    }
    final int i = hashCode();
    detail = JobBuilder.newJob(QuartzResourceAdapter.JobEndpoint.class).withIdentity("Job" + i, Scheduler.DEFAULT_GROUP).withDescription(description).requestRecovery(recoverable).storeDurably(durable).build();
    final TriggerBuilder tb = TriggerBuilder.newTrigger().forJob(detail).withIdentity("Trigger" + i, Scheduler.DEFAULT_GROUP).withDescription(description);
    if (startTime != null) {
        tb.startAt(parse(startTime));
    }
    if (endTime != null) {
        tb.endAt(parse(endTime));
    }
    if (calendarName != null) {
        tb.modifiedByCalendar(calendarName);
    }
    final CronScheduleBuilder csb = CronScheduleBuilder.cronSchedule(getCronExpression());
    if (timeZone != null) {
        csb.inTimeZone(TimeZone.getTimeZone(timeZone));
    }
    trigger = tb.withSchedule(csb).build();
    try {
        ((CronTriggerImpl) trigger).validate();
    } catch (final SchedulerException e) {
        throw new InvalidPropertyException(e);
    }
}
Also used : CronScheduleBuilder(org.apache.openejb.quartz.CronScheduleBuilder) SchedulerException(org.apache.openejb.quartz.SchedulerException) InvalidPropertyException(javax.resource.spi.InvalidPropertyException) CronTriggerImpl(org.apache.openejb.quartz.impl.triggers.CronTriggerImpl) TriggerBuilder(org.apache.openejb.quartz.TriggerBuilder) MessageEndpoint(javax.resource.spi.endpoint.MessageEndpoint)

Aggregations

InvalidPropertyException (javax.resource.spi.InvalidPropertyException)1 MessageEndpoint (javax.resource.spi.endpoint.MessageEndpoint)1 CronScheduleBuilder (org.apache.openejb.quartz.CronScheduleBuilder)1 SchedulerException (org.apache.openejb.quartz.SchedulerException)1 TriggerBuilder (org.apache.openejb.quartz.TriggerBuilder)1 CronTriggerImpl (org.apache.openejb.quartz.impl.triggers.CronTriggerImpl)1