2 * ============LICENSE_START==========================================
4 * ===================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
8 * Modifications Copyright © 2018 IBM.
9 * ===================================================================
11 * Unless otherwise specified, all software contained herein is licensed
12 * under the Apache License, Version 2.0 (the "License");
13 * you may not use this software except in compliance with the License.
14 * You may obtain a copy of the License at
16 * http://www.apache.org/licenses/LICENSE-2.0
18 * Unless required by applicable law or agreed to in writing, software
19 * distributed under the License is distributed on an "AS IS" BASIS,
20 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 * See the License for the specific language governing permissions and
22 * limitations under the License.
24 * Unless otherwise specified, all documentation contained herein is licensed
25 * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
26 * you may not use this documentation except in compliance with the License.
27 * You may obtain a copy of the License at
29 * https://creativecommons.org/licenses/by/4.0/
31 * Unless required by applicable law or agreed to in writing, documentation
32 * distributed under the License is distributed on an "AS IS" BASIS,
33 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
34 * See the License for the specific language governing permissions and
35 * limitations under the License.
37 * ============LICENSE_END============================================
41 package org.onap.portalapp.config;
43 import org.springframework.beans.BeansException;
44 import org.springframework.context.ApplicationContext;
45 import org.springframework.context.ApplicationContextAware;
46 import org.springframework.context.annotation.Bean;
47 import org.springframework.context.annotation.Configuration;
49 import javax.annotation.PostConstruct;
50 import java.util.Timer;
51 import java.util.TimerTask;
54 public class NotificationCleanupConfig implements ApplicationContextAware {
56 // Once every 10 minutes should be adequate
57 private static final int CLEANUP_PERIOD_MINUTES = 10;
59 private static ApplicationContext applicationContext;
63 public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
64 NotificationCleanupConfig.applicationContext = applicationContext;
67 static ApplicationContext getApplicationContext() {
68 return applicationContext;
73 public void startSchedular() {
74 TimerTask task = new NotificationCleanup();
75 Timer timer = new Timer();
76 timer.schedule(task, 1000, (long) CLEANUP_PERIOD_MINUTES * 60 * 1000);
80 public NotificationCleanupConfig getConfig() {
81 return new NotificationCleanupConfig();