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