f44ba3940fa59205f00c22aa95d9f18136e57a43
[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     
42     String MSB_IP="10.96.33.44";
43     int MSB_Port=30080;
44     
45     environment.jersey().register(new AnimalResource());
46
47     MSBServiceClient msbClient = new MSBServiceClient(MSB_IP, MSB_Port);
48
49     MsbHelper helper = new MsbHelper(msbClient);
50     helper.registerMsb();
51
52   }
53
54 }