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=========================================================
21 package org.onap.aai.schemaservice;
24 import java.util.UUID;
26 import javax.annotation.PostConstruct;
27 import javax.annotation.PreDestroy;
29 import org.onap.aai.aailog.logs.AaiDebugLog;
30 import org.onap.aai.exceptions.AAIException;
31 import org.onap.aai.schemaservice.config.PropertyPasswordConfiguration;
32 import org.slf4j.Logger;
33 import org.slf4j.LoggerFactory;
35 import org.springframework.beans.factory.annotation.Autowired;
36 import org.springframework.boot.SpringApplication;
37 import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
38 import org.springframework.boot.autoconfigure.SpringBootApplication;
39 import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
40 import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration;
41 import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
42 import org.springframework.context.annotation.ComponentScan;
43 import org.springframework.core.env.Environment;
44 import org.springframework.web.context.request.RequestContextListener;
46 @SpringBootApplication
47 // Component Scan provides a way to look for spring beans
48 // It only searches beans in the following packages
49 // Any method annotated with @Bean annotation or any class
50 // with @Component, @Configuration, @Service will be picked up
51 @EnableAutoConfiguration(
52 exclude = {DataSourceAutoConfiguration.class,
53 DataSourceTransactionManagerAutoConfiguration.class, HibernateJpaAutoConfiguration.class})
54 @ComponentScan(basePackages = {"org.onap.aai.schemaservice", "org.onap.aai.aaf"})
55 public class SchemaServiceApp {
57 private static final Logger logger = LoggerFactory.getLogger(SchemaServiceApp.class.getName());
59 private static final String APP_NAME = "aai-schema-service";
60 private static AaiDebugLog debugLog = new AaiDebugLog();
66 private Environment env;
68 public static void main(String[] args) throws AAIException {
72 SpringApplication app = new SpringApplication(SchemaServiceApp.class);
73 app.setLogStartupInfo(false);
74 app.setRegisterShutdownHook(true);
75 app.addInitializers(new PropertyPasswordConfiguration());
77 Environment env = app.run(args).getEnvironment();
79 logger.debug("Application '{}' is running on {}!",
80 env.getProperty("spring.application.name"), env.getProperty("server.port"));
82 logger.debug("SchemaService MicroService Started");
84 System.out.println("SchemaService Microservice Started");
88 public static void setDefaultProps() {
90 if (System.getProperty("file.separator") == null) {
91 System.setProperty("file.separator", "/");
94 String currentDirectory = System.getProperty("user.dir");
96 if (System.getProperty("AJSC_HOME") == null) {
97 System.setProperty("AJSC_HOME", ".");
100 if (currentDirectory.contains(APP_NAME)) {
101 if (System.getProperty("BUNDLECONFIG_DIR") == null) {
102 System.setProperty("BUNDLECONFIG_DIR", "src/main/resources");
105 if (System.getProperty("BUNDLECONFIG_DIR") == null) {
106 System.setProperty("BUNDLECONFIG_DIR", "aai-schema-service/src/main/resources");
112 private void init() throws AAIException {
113 System.setProperty("org.onap.aai.serverStarted", "false");
116 logger.debug("SchemaService initialization started...");
118 // Setting this property to allow for encoded slash (/) in the path parameter
119 // This is only needed for tomcat keeping this as temporary
120 System.setProperty("org.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH", "true");
122 if (env.acceptsProfiles(Profiles.TWO_WAY_SSL)
123 && env.acceptsProfiles(Profiles.ONE_WAY_SSL)) {
124 logger.warn("You have seriously misconfigured your application");
130 public void cleanup() {
132 logger.debug("SchemaService shutting down");