Change the Way to Invoke HTTP Requests
author6092002067 <wu.youbo@zte.com.cn>
Mon, 13 Mar 2017 08:54:55 +0000 (16:54 +0800)
committer6092002067 <wu.youbo@zte.com.cn>
Mon, 13 Mar 2017 08:54:55 +0000 (16:54 +0800)
Issue-ID: HOLMES-50

Change-Id: Ib2998d3ac61977ecd1e7a21bb8bd71699d929990
Signed-off-by: youbowu <wu.youbo@zte.com.cn>
rulemgt/src/main/java/org/openo/holmes/rulemgt/bolt/enginebolt/EngineService.java

index ac381d1..e792fbf 100644 (file)
@@ -26,6 +26,7 @@ import javax.ws.rs.core.Response;
 import lombok.extern.slf4j.Slf4j;\r
 import org.glassfish.jersey.client.ClientConfig;\r
 import org.jvnet.hk2.annotations.Service;\r
+import org.openo.holmes.common.config.MicroServiceConfig;\r
 import org.openo.holmes.rulemgt.bean.request.CorrelationCheckRule4Engine;\r
 import org.openo.holmes.rulemgt.bean.request.CorrelationDeployRule4Engine;\r
 import org.openo.holmes.rulemgt.constant.RuleMgtConstant;\r
@@ -34,11 +35,10 @@ import org.openo.holmes.rulemgt.constant.RuleMgtConstant;
 @Service\r
 public class EngineService {\r
 \r
-    String url = "http://10.250.0.3:9102";\r
-\r
     protected Response delete(String packageName) throws IOException {\r
         Client client = createClient();\r
-        WebTarget webTarget = client.target(url + RuleMgtConstant.ENGINE_PATH + "/" + packageName);\r
+        WebTarget webTarget = client\r
+                .target(MicroServiceConfig.getMsbServerAddr() + RuleMgtConstant.ENGINE_PATH + "/" + packageName);\r
         return webTarget.request(MediaType.APPLICATION_JSON).delete();\r
     }\r
 \r
@@ -52,7 +52,7 @@ public class EngineService {
         Client client = createClient();\r
         ObjectMapper mapper = new ObjectMapper();\r
         String content = mapper.writeValueAsString(correlationCheckRule4Engine);\r
-        WebTarget webTarget = client.target(url + RuleMgtConstant.ENGINE_PATH);\r
+        WebTarget webTarget = client.target(MicroServiceConfig.getMsbServerAddr() + RuleMgtConstant.ENGINE_PATH);\r
         return webTarget.request(MediaType.APPLICATION_JSON).post(Entity.entity(content, MediaType.APPLICATION_JSON));\r
     }\r
 \r
@@ -60,7 +60,7 @@ public class EngineService {
         Client client = createClient();\r
         ObjectMapper mapper = new ObjectMapper();\r
         String content = mapper.writeValueAsString(correlationDeployRule4Engine);\r
-        WebTarget webTarget = client.target(url + RuleMgtConstant.ENGINE_PATH);\r
+        WebTarget webTarget = client.target(MicroServiceConfig.getMsbServerAddr() + RuleMgtConstant.ENGINE_PATH);\r
         return webTarget.request(MediaType.APPLICATION_JSON).put(Entity.entity(content, MediaType.APPLICATION_JSON));\r
     }\r
 }\r