2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017-2018 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=========================================================
22 import com.att.eelf.configuration.EELFLogger;
23 import com.att.eelf.configuration.EELFManager;
24 import org.onap.aai.config.PropertyPasswordConfiguration;
25 import org.onap.aai.dbmap.AAIGraph;
26 import org.onap.aai.exceptions.AAIException;
27 import org.onap.aai.introspection.ModelInjestor;
28 import org.onap.aai.logging.LoggingContext;
29 import org.onap.aai.util.AAIConfig;
30 import org.springframework.beans.factory.annotation.Autowired;
31 import org.springframework.boot.SpringApplication;
32 import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
33 import org.springframework.boot.autoconfigure.SpringBootApplication;
34 import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
35 import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration;
36 import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
37 import org.springframework.context.annotation.ComponentScan;
38 import org.springframework.core.env.Environment;
40 import javax.annotation.PostConstruct;
41 import javax.annotation.PreDestroy;
42 import java.util.UUID;
44 @SpringBootApplication
45 // Component Scan provides a way to look for spring beans
46 // It only searches beans in the following packages
47 // Any method annotated with @Bean annotation or any class
48 // with @Component, @Configuration, @Service will be picked up
49 @ComponentScan(basePackages = {
50 "org.onap.aai.config",
56 @EnableAutoConfiguration(exclude = {
57 DataSourceAutoConfiguration.class,
58 DataSourceTransactionManagerAutoConfiguration.class,
59 HibernateJpaAutoConfiguration.class
61 public class TraversalApp {
63 private static final EELFLogger logger = EELFManager.getInstance().getLogger(TraversalApp.class.getName());
65 private static final String APP_NAME = "aai-traversal";
68 private Environment env;
71 private void init() throws AAIException {
72 System.setProperty("org.onap.aai.serverStarted", "false");
75 LoggingContext.save();
76 LoggingContext.component("init");
77 LoggingContext.partnerName("NA");
78 LoggingContext.targetEntity(APP_NAME);
79 LoggingContext.requestId(UUID.randomUUID().toString());
80 LoggingContext.serviceName(APP_NAME);
81 LoggingContext.targetServiceName("contextInitialized");
83 logger.info("AAI Server initialization started...");
85 // Setting this property to allow for encoded slash (/) in the path parameter
86 // This is only needed for tomcat keeping this as temporary
87 System.setProperty("org.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH", "true");
89 logger.info("Starting AAIGraph connections and the ModelInjestor");
91 if(env.acceptsProfiles(Profiles.TWO_WAY_SSL) && env.acceptsProfiles(Profiles.ONE_WAY_SSL)){
92 logger.warn("You have seriously misconfigured your application");
96 ModelInjestor.getInstance();
97 AAIGraph.getInstance();
101 public void cleanup(){
102 logger.info("Shutting down both realtime and cached connections");
103 AAIGraph.getInstance().graphShutdown();
106 public static void main(String[] args) {
109 SpringApplication app = new SpringApplication(TraversalApp.class);
110 app.setRegisterShutdownHook(true);
111 app.addInitializers(new PropertyPasswordConfiguration());
112 Environment env = app.run(args).getEnvironment();
115 "Application '{}' is running on {}!" ,
116 env.getProperty("spring.application.name"),
117 env.getProperty("server.port")
120 logger.info("Traversal MicroService Started");
121 logger.error("Traversal MicroService Started");
122 logger.debug("Traversal MicroService Started");
123 System.out.println("Traversal Microservice Started");
126 public static void setDefaultProps(){
128 if (System.getProperty("file.separator") == null) {
129 System.setProperty("file.separator", "/");
132 String currentDirectory = System.getProperty("user.dir");
134 if (System.getProperty("AJSC_HOME") == null) {
135 System.setProperty("AJSC_HOME", ".");
138 if(currentDirectory.contains(APP_NAME)){
139 if (System.getProperty("BUNDLECONFIG_DIR") == null) {
140 System.setProperty("BUNDLECONFIG_DIR", "src/main/resources");
143 if (System.getProperty("BUNDLECONFIG_DIR") == null) {
144 System.setProperty("BUNDLECONFIG_DIR", "aai-traversal/src/main/resources");