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.uebhandler;
22 import java.util.concurrent.ConcurrentLinkedQueue;
24 import javax.annotation.PostConstruct;
26 import org.openecomp.portalsdk.core.logging.format.AlarmSeverityEnum;
27 import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
28 import org.openecomp.portalsdk.core.onboarding.crossapi.PortalApiConstants;
29 import org.openecomp.portalsdk.core.onboarding.crossapi.PortalApiProperties;
30 import org.openecomp.portalsdk.core.onboarding.ueb.UebManager;
31 import org.openecomp.portalsdk.core.onboarding.ueb.UebMsg;
32 import org.springframework.beans.factory.annotation.Autowired;
33 import org.springframework.context.annotation.Configuration;
36 // Adding this class for the sole purpose of insuring that the MainUebHandler really
37 // honors @Async and kicks off a thread. For more info google @Async and read about
38 // @Async only working if called from different class.
41 public class InitUebHandler {
43 EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(InitUebHandler.class);
47 MainUebHandler mainUebHandler;
49 public InitUebHandler() {
54 public void initUeb() {
57 String enableListenerThread = PortalApiProperties.getProperty(PortalApiConstants.UEB_LISTENERS_ENABLE);
58 if (enableListenerThread.equalsIgnoreCase("true")) {
59 ConcurrentLinkedQueue<UebMsg> inboxQueue = new ConcurrentLinkedQueue<UebMsg>();
60 UebManager.getInstance().initListener(inboxQueue);
61 mainUebHandler.runHandler(inboxQueue);
62 logger.info(EELFLoggerDelegate.debugLogger, ("Returned from initiating mainUebHandler..."));
65 logger.info(EELFLoggerDelegate.debugLogger, ("Not starting UEB listening thread because ueb_listeners_enable is not set to true in the properties file."));
69 logger.error(EELFLoggerDelegate.debugLogger, ("Not starting UEB listening thread because property could not be read " + PortalApiConstants.UEB_LISTENERS_ENABLE),AlarmSeverityEnum.MAJOR);