summaryrefslogtreecommitdiffstats
path: root/rulemgt/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'rulemgt/src/main/java')
-rw-r--r--rulemgt/src/main/java/org/openo/holmes/rulemgt/RuleActiveApp.java29
-rw-r--r--rulemgt/src/main/java/org/openo/holmes/rulemgt/resources/RuleMgtResources.java22
2 files changed, 29 insertions, 22 deletions
diff --git a/rulemgt/src/main/java/org/openo/holmes/rulemgt/RuleActiveApp.java b/rulemgt/src/main/java/org/openo/holmes/rulemgt/RuleActiveApp.java
index c7eaf15..96a1f00 100644
--- a/rulemgt/src/main/java/org/openo/holmes/rulemgt/RuleActiveApp.java
+++ b/rulemgt/src/main/java/org/openo/holmes/rulemgt/RuleActiveApp.java
@@ -16,8 +16,15 @@
package org.openo.holmes.rulemgt;
+import io.dropwizard.setup.Environment;
+import java.io.IOException;
+import lombok.extern.slf4j.Slf4j;
import org.openo.dropwizard.ioc.bundle.IOCApplication;
+import org.openo.holmes.common.api.entity.ServiceRegisterEntity;
+import org.openo.holmes.common.config.MicroServiceConfig;
+import org.openo.holmes.common.utils.MSBRegisterUtil;
+@Slf4j
public class RuleActiveApp extends IOCApplication < RuleAppConfig > {
public static void main( String[] args ) throws Exception {
@@ -29,4 +36,26 @@ public class RuleActiveApp extends IOCApplication < RuleAppConfig > {
return "Holmes Rule Management ActiveApp APP ";
}
+ @Override
+ public void run(RuleAppConfig configuration, Environment environment) throws Exception {
+ super.run(configuration, environment);
+
+ try {
+ new MSBRegisterUtil().register(initServiceEntity());
+ } catch (IOException e) {
+ log.warn("Micro service registry httpclient close failure",e);
+ }
+
+ }
+
+ private ServiceRegisterEntity initServiceEntity() {
+ ServiceRegisterEntity serviceRegisterEntity = new ServiceRegisterEntity();
+ serviceRegisterEntity.setServiceName("holmes-rule-mgmt");
+ serviceRegisterEntity.setProtocol("REST");
+ serviceRegisterEntity.setVersion("v1");
+ serviceRegisterEntity.setUrl("/openoapi/holmes-rule-mgmt/v1");
+ serviceRegisterEntity.setSingleNode(MicroServiceConfig.getServiceIp(), "9101", 0);
+ serviceRegisterEntity.setVisualRange("1|0");
+ return serviceRegisterEntity;
+ }
}
diff --git a/rulemgt/src/main/java/org/openo/holmes/rulemgt/resources/RuleMgtResources.java b/rulemgt/src/main/java/org/openo/holmes/rulemgt/resources/RuleMgtResources.java
index 2c2c88d..f3256b2 100644
--- a/rulemgt/src/main/java/org/openo/holmes/rulemgt/resources/RuleMgtResources.java
+++ b/rulemgt/src/main/java/org/openo/holmes/rulemgt/resources/RuleMgtResources.java
@@ -64,19 +64,8 @@ import org.openo.holmes.rulemgt.wrapper.RuleMgtWrapper;
public class RuleMgtResources {
@Inject
- private MSBRegisterUtil msbRegisterUtil;
- @Inject
private RuleMgtWrapper ruleMgtWrapper;
- @PostConstruct
- public void init() {
- try {
- msbRegisterUtil.register(initServiceEntity());
- } catch (IOException e) {
- log.warn("Micro service registry httpclient close failure",e);
- }
- }
-
@PUT
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Save the alarm+ rule to the database, and deployed to the engine when the enable to open.", response = RuleAddAndUpdateResponse.class)
@@ -176,15 +165,4 @@ public class RuleMgtResources {
I18nProxy.RULE_MANAGEMENT_DATA_FORMAT_ERROR));
}
}
-
- private ServiceRegisterEntity initServiceEntity() {
- ServiceRegisterEntity serviceRegisterEntity = new ServiceRegisterEntity();
- serviceRegisterEntity.setServiceName("holmes-rule-mgmt");
- serviceRegisterEntity.setProtocol("REST");
- serviceRegisterEntity.setVersion("v1");
- serviceRegisterEntity.setUrl("/openoapi/holmes-rule-mgmt/v1");
- serviceRegisterEntity.setSingleNode(MicroServiceConfig.getServiceIp(), "9101", 0);
- serviceRegisterEntity.setVisualRange("1");
- return serviceRegisterEntity;
- }
}