Search in sources :

Example 1 with SchedulerEntryImpl

use of com.liferay.portal.kernel.scheduler.SchedulerEntryImpl in project liferay-imex by jpdacunha.

the class FilesystemTriggerListener method activate.

@Modified
@Activate
protected void activate(Map<String, Object> properties) {
    _log.info("Registering scheduler entry for [" + this.getClass().getSimpleName() + "] ...");
    Class<?> clazz = getClass();
    String className = clazz.getName();
    ImexProperties imexProperties = new ImexProperties();
    configurationService.loadTriggerAndCoreConfiguration(this.getClass(), imexProperties);
    Properties rawProps = imexProperties.getProperties();
    String cronExpression = GetterUtil.getString(rawProps.get(ImExFileSystemTriggerPropsKeys.TRIGGER_CHECK_PERIOD_CONR));
    if (Validator.isNotNull(cronExpression)) {
        Trigger trigger = _triggerFactory.createTrigger(className, className, new Date(), null, cronExpression);
        SchedulerEntry schedulerEntry = new SchedulerEntryImpl(className, trigger);
        _schedulerEngineHelper.register(this, schedulerEntry, DestinationNames.SCHEDULER_DISPATCH);
    } else {
        _log.error("Unable to start job : no cron expression is properly configured");
    }
    _log.info("Done.");
}
Also used : Trigger(com.liferay.portal.kernel.scheduler.Trigger) SchedulerEntryImpl(com.liferay.portal.kernel.scheduler.SchedulerEntryImpl) SchedulerEntry(com.liferay.portal.kernel.scheduler.SchedulerEntry) ImexProperties(com.liferay.imex.core.api.configuration.model.ImexProperties) ImexProperties(com.liferay.imex.core.api.configuration.model.ImexProperties) Properties(java.util.Properties) Date(java.util.Date) Modified(org.osgi.service.component.annotations.Modified) Activate(org.osgi.service.component.annotations.Activate)

Aggregations

ImexProperties (com.liferay.imex.core.api.configuration.model.ImexProperties)1 SchedulerEntry (com.liferay.portal.kernel.scheduler.SchedulerEntry)1 SchedulerEntryImpl (com.liferay.portal.kernel.scheduler.SchedulerEntryImpl)1 Trigger (com.liferay.portal.kernel.scheduler.Trigger)1 Date (java.util.Date)1 Properties (java.util.Properties)1 Activate (org.osgi.service.component.annotations.Activate)1 Modified (org.osgi.service.component.annotations.Modified)1