Fix java check style issue
[msb/java-sdk.git] / example / src / main / java / org / onap / msb / sdk / example / server / ExampleApp.java
1 /*******************************************************************************
2  * Copyright 2017 ZTE, Inc. and others.
3  * 
4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5  * in compliance with the License. You may obtain a copy of the License at
6  * 
7  * http://www.apache.org/licenses/LICENSE-2.0
8  * 
9  * Unless required by applicable law or agreed to in writing, software distributed under the License
10  * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11  * or implied. See the License for the specific language governing permissions and limitations under
12  * the License.
13  ******************************************************************************/
14 package org.onap.msb.sdk.example.server;
15
16 import org.onap.msb.sdk.example.server.resources.AnimalResource;
17 import org.onap.msb.sdk.httpclient.msb.MSBServiceClient;
18
19 import io.dropwizard.Application;
20 import io.dropwizard.setup.Environment;
21
22
23 public class ExampleApp extends Application<Config> {
24
25     private static final String CONFIGURATION_FILE = "example.yml";
26
27     public static void main(String[] args) throws Exception {
28
29         String configFile = null;
30         if (args.length > 1) {
31             configFile = args[0];
32         } else {
33             configFile = ExampleApp.class.getClassLoader().getResource(CONFIGURATION_FILE).getFile();
34         }
35         args = new String[] {"server", configFile};
36         new ExampleApp().run(args);
37     }
38
39     @Override
40     public void run(Config configuration, Environment environment) throws Exception {
41         // For real use case, MSB discovery IP and Port should come from configuration file instead
42         // of hard code here
43         String msb_discovery_ip = "127.0.0.1";
44         int msb_discovery_port = 10081;
45
46         environment.jersey().register(new AnimalResource());
47
48         MSBServiceClient msbClient = new MSBServiceClient(msb_discovery_ip, msb_discovery_port);
49
50         MsbHelper helper = new MsbHelper(msbClient);
51         helper.registerMsb();
52
53     }
54
55 }