2 * ================================================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ================================================================================
20 package org.openecomp.portalapp.scheduler;
22 import java.util.ArrayList;
23 import java.util.List;
25 import org.openecomp.portalapp.portal.utils.EcompPortalUtils;
26 import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
27 import org.openecomp.portalsdk.core.scheduler.Registerable;
28 import org.openecomp.portalsdk.core.util.SystemProperties;
29 import org.quartz.Trigger;
30 import org.springframework.beans.factory.annotation.Autowired;
31 import org.springframework.context.annotation.DependsOn;
32 import org.springframework.stereotype.Component;
35 @DependsOn({"logRegistry", "sessionMgtRegistry", "systemProperties"})
36 public class Register implements Registerable {
38 EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(Register.class);
40 private List<Trigger> scheduleTriggers = new ArrayList<Trigger>();
41 Trigger trigger[] = new Trigger[0];
44 private LogRegistry logRegistry;
47 private SessionMgtRegistry sessionMgtRegistry;
50 public Trigger[] getTriggers() {
51 return getScheduleTriggers().toArray(trigger);
55 public void registerTriggers() {
56 // if the property value is not available; the cron will not be added
57 // and can be ignored. its safe to ignore the exceptions
59 if (SystemProperties.getProperty(SystemProperties.LOG_CRON) != null)
60 getScheduleTriggers().add(logRegistry.getTrigger());
62 } catch (IllegalStateException ies) {
63 logger.error(EELFLoggerDelegate.errorLogger, EcompPortalUtils.getStackTrace(ies));
64 logger.info(EELFLoggerDelegate.debugLogger, ("Log Cron not available"));
68 if(SystemProperties.getProperty(SystemProperties.SESSIONTIMEOUT_FEED_CRON) != null)
69 getScheduleTriggers().add(sessionMgtRegistry.getTrigger());
71 } catch(IllegalStateException ies) {
72 logger.error(EELFLoggerDelegate.errorLogger, EcompPortalUtils.getStackTrace(ies));
73 logger.info(EELFLoggerDelegate.debugLogger, ("Session Cron not available"));
78 public List<Trigger> getScheduleTriggers() {
79 return scheduleTriggers;
82 public void setScheduleTriggers(List<Trigger> scheduleTriggers) {
83 this.scheduleTriggers = scheduleTriggers;