001
014
015 package com.liferay.portal.kernel.scheduler.config;
016
017 import com.liferay.portal.kernel.log.Log;
018 import com.liferay.portal.kernel.log.LogFactoryUtil;
019 import com.liferay.portal.kernel.scheduler.SchedulerEngineHelperUtil;
020 import com.liferay.portal.kernel.scheduler.SchedulerEntry;
021 import com.liferay.portal.kernel.util.BasePortalLifecycle;
022 import com.liferay.portal.kernel.util.PortalLifecycle;
023
024
028 public class DefaultSchedulingConfigurator
029 extends AbstractSchedulingConfigurator {
030
031 @Override
032 public void configure() {
033 if (schedulerEntries.isEmpty()) {
034 return;
035 }
036
037 SchedulingConfiguratorLifecycle schedulingConfiguratorLifecycle =
038 new SchedulingConfiguratorLifecycle();
039
040 schedulingConfiguratorLifecycle.registerPortalLifecycle(
041 PortalLifecycle.METHOD_INIT);
042 }
043
044 private static Log _log = LogFactoryUtil.getLog(
045 DefaultSchedulingConfigurator.class);
046
047 private class SchedulingConfiguratorLifecycle extends BasePortalLifecycle {
048
049 @Override
050 protected void doPortalDestroy() throws Exception {
051 }
052
053 @Override
054 protected void doPortalInit() throws Exception {
055 for (SchedulerEntry schedulerEntry : schedulerEntries) {
056 try {
057 SchedulerEngineHelperUtil.schedule(
058 schedulerEntry, storageType, null, exceptionsMaxSize);
059 }
060 catch (Exception e) {
061 _log.error("Unable to schedule " + schedulerEntry, e);
062 }
063 }
064 }
065
066 }
067
068 }