actually adding the files to the initial commit
[vid.git] / vid / src / main / java / org / openecomp / vid / scheduler / Register.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * VID
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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  * ============LICENSE_END=========================================================
19  */
20
21 package org.openecomp.vid.scheduler;
22
23 import java.util.ArrayList;
24 import java.util.List;
25
26 import org.quartz.Trigger;
27 import org.springframework.beans.factory.annotation.Autowired;
28 import org.springframework.context.annotation.DependsOn;
29 import org.springframework.stereotype.Component;
30
31 import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
32 import org.openecomp.portalsdk.core.scheduler.Registerable;
33 import org.openecomp.portalsdk.core.util.SystemProperties;
34
35
36 @Component
37 @DependsOn({"logRegistry", "myLoginsFeedRegistry", "systemProperties"})
38 public class Register implements Registerable {
39
40         EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(Register.class);
41
42
43         private List<Trigger> scheduleTriggers = new ArrayList<Trigger>();
44         Trigger trigger[] = new Trigger[1];
45
46         
47         @Autowired
48         private LogRegistry logRegistry;
49         
50         @Autowired
51         private MyLoginsFeedRegistry myLoginsFeedRegistry;
52         
53         @Override
54         public Trigger[] getTriggers() {
55                 return getScheduleTriggers().toArray(trigger);
56         }
57
58         @Override
59         public void registerTriggers() {
60                 // if the property value is not available; the cron will not be added and can be ignored. its safe to ignore the exceptions
61                 try {
62                         if(SystemProperties.getProperty(SystemProperties.LOG_CRON) != null)
63                                 getScheduleTriggers().add(logRegistry.getTrigger());
64                         
65                 } catch(IllegalStateException ies) {
66                         logger.info(EELFLoggerDelegate.errorLogger, ("Log Cron not available"));
67                 }
68                         
69                 try {
70                         if(SystemProperties.getProperty(SystemProperties.MYLOGINS_FEED_CRON) != null)
71                                 getScheduleTriggers().add(myLoginsFeedRegistry.getTrigger());
72                         
73                 } catch(IllegalStateException ies) {
74                         logger.info(EELFLoggerDelegate.errorLogger, ("MyLogins Cron not available"));
75                 }
76                 
77         }
78         
79         
80         public List<Trigger> getScheduleTriggers() {
81                 return scheduleTriggers;
82         }
83
84         public void setScheduleTriggers(List<Trigger> scheduleTriggers) {
85                 this.scheduleTriggers = scheduleTriggers;
86         }
87         
88         
89
90         
91         
92
93 }