Change the groupid from openo to onap
[holmes/rule-management.git] / rulemgt / src / main / java / org / onap / holmes / rulemgt / RuleActiveApp.java
1 /**
2  * Copyright 2017 ZTE Corporation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 package org.onap.holmes.rulemgt;
18
19 import io.dropwizard.setup.Environment;
20 import java.io.IOException;
21 import lombok.extern.slf4j.Slf4j;
22 import org.onap.holmes.common.dropwizard.ioc.bundle.IOCApplication;
23 import org.onap.holmes.common.api.entity.ServiceRegisterEntity;
24 import org.onap.holmes.common.config.MicroServiceConfig;
25 import org.onap.holmes.common.utils.MSBRegisterUtil;
26
27 @Slf4j
28 public class RuleActiveApp extends IOCApplication< RuleAppConfig > {
29
30     public static void main( String[] args ) throws Exception {
31        new RuleActiveApp().run( args );
32     }
33         
34     @Override
35     public String getName() {
36         return "Holmes Rule Management ActiveApp APP ";
37     }
38
39     @Override
40     public void run(RuleAppConfig configuration, Environment environment) throws Exception {
41         super.run(configuration, environment);
42
43         try {
44             new MSBRegisterUtil().register(initServiceEntity());
45         } catch (IOException e) {
46             log.warn("Micro service registry httpclient close failure",e);
47         }
48
49     }
50
51     private ServiceRegisterEntity initServiceEntity() {
52         ServiceRegisterEntity serviceRegisterEntity = new ServiceRegisterEntity();
53         serviceRegisterEntity.setServiceName("holmes-rule-mgmt");
54         serviceRegisterEntity.setProtocol("REST");
55         serviceRegisterEntity.setVersion("v1");
56         serviceRegisterEntity.setUrl("/onapapi/holmes-rule-mgmt/v1");
57         serviceRegisterEntity.setSingleNode(MicroServiceConfig.getServiceIp(), "9101", 0);
58         serviceRegisterEntity.setVisualRange("1|0");
59         return serviceRegisterEntity;
60     }
61 }