2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 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
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 * ============LICENSE_END=========================================================
20 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22 package org.onap.aai.util;
24 import java.io.IOException;
26 import javax.servlet.ServletContextEvent;
27 import javax.servlet.ServletContextListener;
29 //import org.apache.activemq.broker.BrokerService;
31 import org.onap.aai.dbmap.AAIGraph;
32 import org.onap.aai.exceptions.AAIException;
33 import org.onap.aai.introspection.ModelInjestor;
34 import org.onap.aai.logging.ErrorLogHelper;
35 import com.att.eelf.configuration.EELFLogger;
36 import com.att.eelf.configuration.EELFManager;
38 public class AAIAppServletContextListener implements ServletContextListener {
40 private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(AAIAppServletContextListener.class.getName());
42 //private BrokerService broker = new BrokerService();
47 * @param arg0 the ServletContextEvent
49 public void contextDestroyed(ServletContextEvent arg0) {
50 LOGGER.info("AAIGraph shutting down");
51 AAIGraph.getInstance().graphShutdown();
52 LOGGER.info("AAIGraph shutdown");
56 //} catch (Exception e) {
57 //// TODO Auto-generated catch block
58 //e.printStackTrace();
65 * @param arg0 the ServletContextEvent
67 public void contextInitialized(ServletContextEvent arg0) {
68 System.setProperty("org.onap.aai.serverStarted", "false");
69 LOGGER.info("***AAI Server initialization started...");
72 LOGGER.info("Loading aaiconfig.properties");
75 LOGGER.info("Loading error.properties");
76 ErrorLogHelper.loadProperties();
78 LOGGER.info("Loading graph database");
80 AAIGraph.getInstance();
81 ModelInjestor.getInstance();
83 // Jsm internal broker for aai events
84 //broker = new BrokerService();
85 //broker.addConnector("tcp://localhost:61446");
86 //broker.setPersistent(false);
87 //broker.setUseJmx(false);
88 //broker.setSchedulerSupport(false);
91 LOGGER.info("AAI Server initialization succcessful.");
92 System.setProperty("org.onap.aai.serverStarted", "true");
94 } catch (AAIException e) {
95 ErrorLogHelper.logException(e);
96 throw new RuntimeException("AAIException caught while initializing AAI server", e);
97 } catch (IOException e) {
98 ErrorLogHelper.logError("AAI_4000", e.getMessage());
99 throw new RuntimeException("IOException caught while initializing AAI server", e);
100 } catch (Exception e) {
101 LOGGER.error("Unknown failure while initializing AAI Server", e);
102 throw new RuntimeException("Unknown failure while initializing AAI server", e);
105 LOGGER.info("Graph-Query MicroService Started");
106 LOGGER.error("Graph-Query MicroService Started");
107 LOGGER.debug("Graph-Query MicroService Started");