3 import com.att.eelf.configuration.EELFLogger;
4 import com.att.eelf.configuration.EELFManager;
5 import org.onap.aai.config.PropertyPasswordConfiguration;
6 import org.onap.aai.dbmap.AAIGraph;
7 import org.onap.aai.exceptions.AAIException;
8 import org.onap.aai.introspection.ModelInjestor;
9 import org.onap.aai.logging.LoggingContext;
10 import org.onap.aai.util.AAIConfig;
11 import org.springframework.beans.factory.annotation.Autowired;
12 import org.springframework.boot.SpringApplication;
13 import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
14 import org.springframework.boot.autoconfigure.SpringBootApplication;
15 import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
16 import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration;
17 import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
18 import org.springframework.context.annotation.ComponentScan;
19 import org.springframework.core.env.Environment;
21 import javax.annotation.PostConstruct;
22 import javax.annotation.PreDestroy;
23 import java.util.UUID;
25 @SpringBootApplication
26 // Component Scan provides a way to look for spring beans
27 // It only searches beans in the following packages
28 // Any method annotated with @Bean annotation or any class
29 // with @Component, @Configuration, @Service will be picked up
30 @ComponentScan(basePackages = {
31 "org.onap.aai.config",
37 @EnableAutoConfiguration(exclude = {
38 DataSourceAutoConfiguration.class,
39 DataSourceTransactionManagerAutoConfiguration.class,
40 HibernateJpaAutoConfiguration.class
42 public class TraversalApp {
44 private static final EELFLogger logger = EELFManager.getInstance().getLogger(TraversalApp.class.getName());
46 private static final String APP_NAME = "aai-traversal";
49 private Environment env;
52 private void init() throws AAIException {
53 System.setProperty("org.onap.aai.serverStarted", "false");
56 LoggingContext.save();
57 LoggingContext.component("init");
58 LoggingContext.partnerName("NA");
59 LoggingContext.targetEntity(APP_NAME);
60 LoggingContext.requestId(UUID.randomUUID().toString());
61 LoggingContext.serviceName(APP_NAME);
62 LoggingContext.targetServiceName("contextInitialized");
64 logger.info("AAI Server initialization started...");
66 // Setting this property to allow for encoded slash (/) in the path parameter
67 // This is only needed for tomcat keeping this as temporary
68 System.setProperty("org.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH", "true");
70 logger.info("Starting AAIGraph connections and the ModelInjestor");
72 if(env.acceptsProfiles(Profiles.TWO_WAY_SSL) && env.acceptsProfiles(Profiles.ONE_WAY_SSL)){
73 logger.warn("You have seriously misconfigured your application");
77 ModelInjestor.getInstance();
78 AAIGraph.getInstance();
82 public void cleanup(){
83 logger.info("Shutting down both realtime and cached connections");
84 AAIGraph.getInstance().graphShutdown();
87 public static void main(String[] args) {
90 SpringApplication app = new SpringApplication(TraversalApp.class);
91 app.setRegisterShutdownHook(true);
92 app.addInitializers(new PropertyPasswordConfiguration());
93 Environment env = app.run(args).getEnvironment();
96 "Application '{}' is running on {}!" ,
97 env.getProperty("spring.application.name"),
98 env.getProperty("server.port")
101 logger.info("Traversal MicroService Started");
102 logger.error("Traversal MicroService Started");
103 logger.debug("Traversal MicroService Started");
104 System.out.println("Traversal Microservice Started");
107 public static void setDefaultProps(){
109 if (System.getProperty("file.separator") == null) {
110 System.setProperty("file.separator", "/");
113 String currentDirectory = System.getProperty("user.dir");
115 if (System.getProperty("AJSC_HOME") == null) {
116 System.setProperty("AJSC_HOME", ".");
119 if(currentDirectory.contains(APP_NAME)){
120 if (System.getProperty("BUNDLECONFIG_DIR") == null) {
121 System.setProperty("BUNDLECONFIG_DIR", "src/main/resources");
124 if (System.getProperty("BUNDLECONFIG_DIR") == null) {
125 System.setProperty("BUNDLECONFIG_DIR", "aai-traversal/src/main/resources");