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.portalapp.portal.logging.aop.EPMetricsLog;
27 import org.openecomp.portalapp.portal.utils.EcompPortalUtils;
28 import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
29 import org.openecomp.portalsdk.core.onboarding.crossapi.PortalApiConstants;
30 import org.openecomp.portalsdk.core.onboarding.crossapi.PortalApiProperties;
31 import org.openecomp.portalsdk.core.onboarding.ueb.UebManager;
32 import org.openecomp.portalsdk.core.onboarding.ueb.UebMsg;
33 import org.springframework.beans.factory.annotation.Autowired;
34 import org.springframework.context.annotation.Configuration;
35 import org.springframework.context.annotation.EnableAspectJAutoProxy;
38 // Adding this class for the sole purpose of insuring that the MainUebHandler really
39 // honors @Async and kicks off a thread. For more info google @Async and read about
40 // @Async only working if called from different class.
43 //@EnableAspectJAutoProxy
45 public class InitUebHandler {
46 EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(InitUebHandler.class);
49 MainUebHandler mainUebHandler;
51 public InitUebHandler() {
56 public void initUeb() {
59 String enableListenerThread = PortalApiProperties.getProperty(PortalApiConstants.UEB_LISTENERS_ENABLE);
60 if (enableListenerThread.equalsIgnoreCase("true")) {
61 ConcurrentLinkedQueue<UebMsg> inboxQueue = new ConcurrentLinkedQueue<UebMsg>();
62 UebManager.getInstance().initListener(inboxQueue);
63 mainUebHandler.runHandler(inboxQueue);
64 logger.info(EELFLoggerDelegate.errorLogger, "Returned from initiating mainUebHandler...");
67 logger.info(EELFLoggerDelegate.errorLogger, "Not starting UEB listening thread because ueb_listeners_enable is not set to true in the properties file.");
71 logger.error(EELFLoggerDelegate.errorLogger, EcompPortalUtils.getStackTrace(e));
72 logger.info(EELFLoggerDelegate.errorLogger, "Not starting UEB listening thread because property could not be read " + PortalApiConstants.UEB_LISTENERS_ENABLE + e.getMessage());