2 * ============LICENSE_START==========================================
4 * ===================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ===================================================================
8 * Unless otherwise specified, all software contained herein is licensed
9 * under the Apache License, Version 2.0 (the "License");
10 * you may not use this software except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
21 * Unless otherwise specified, all documentation contained herein is licensed
22 * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
23 * you may not use this documentation except in compliance with the License.
24 * You may obtain a copy of the License at
26 * https://creativecommons.org/licenses/by/4.0/
28 * Unless required by applicable law or agreed to in writing, documentation
29 * distributed under the License is distributed on an "AS IS" BASIS,
30 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
31 * See the License for the specific language governing permissions and
32 * limitations under the License.
34 * ============LICENSE_END============================================
38 package org.onap.portalapp.scheduler;
40 import java.text.ParseException;
41 import java.util.HashMap;
44 import org.onap.portalapp.portal.listener.UserSessionListener;
45 import org.onap.portalapp.service.sessionmgt.TimeoutHandler;
46 import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
47 import org.onap.portalsdk.core.scheduler.CronRegistry;
48 import org.onap.portalsdk.core.util.SystemProperties;
49 import org.springframework.beans.BeansException;
50 import org.springframework.beans.factory.annotation.Autowired;
51 import org.springframework.context.ApplicationContext;
52 import org.springframework.context.ApplicationContextAware;
53 import org.springframework.context.annotation.DependsOn;
54 import org.springframework.scheduling.quartz.CronTriggerFactoryBean;
55 import org.springframework.scheduling.quartz.JobDetailFactoryBean;
56 import org.springframework.stereotype.Component;
59 * Extra depends-on annotation tells Spring that the system properties object
60 * will be used in the constructor.
63 // @DependsOn({ "manageService", "epAppService", "systemProperties" })
64 @DependsOn({ "systemProperties" })
65 public class SessionMgtRegistry extends CronRegistry implements ApplicationContextAware {
67 private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(SessionMgtRegistry.class);
69 private static final String groupName = "AppGroup";
70 private static final String jobName = "PortalSessionTimeoutFeedJob";
71 private static final String triggerName = "PortalSessionTimeoutFeedTrigger";
73 // Not strictly necessary, but preparing for the day
74 // when the getProperty method is not static.
76 private SystemProperties systemProperties;
78 private ApplicationContext applicationContext;
80 public JobDetailFactoryBean jobDetailFactoryBean() {
81 Map<String, Object> map = new HashMap<String, Object>();
82 return jobDetailFactoryBean(groupName, jobName, TimeoutHandler.class, map);
85 @SuppressWarnings("static-access")
86 public CronTriggerFactoryBean cronTriggerFactoryBean() throws ParseException {
87 String property = "* * * * * ? 2099";
89 property = systemProperties.getProperty(SystemProperties.SESSIONTIMEOUT_FEED_CRON);
90 } catch (Exception e) {
91 logger.error(EELFLoggerDelegate.errorLogger,
92 "Failed to retrieve " + SystemProperties.SESSIONTIMEOUT_FEED_CRON + ", defaulting to " + property,
95 return cronTriggerFactoryBean(groupName, triggerName, property);
99 public void setApplicationContext(ApplicationContext _applicationContext) throws BeansException {
100 applicationContext = _applicationContext;
101 TimeoutHandler.setApplicationContext(applicationContext);
102 UserSessionListener.setApplicationContext(_applicationContext);