Initialize the App and Config Class 71/9071/1
authorGuangrong Fu <fu.guangrong@zte.com.cn>
Tue, 29 Aug 2017 11:27:16 +0000 (19:27 +0800)
committerGuangrong Fu <fu.guangrong@zte.com.cn>
Tue, 29 Aug 2017 11:27:16 +0000 (19:27 +0800)
Create DmaapDsaActiveApp.java
Create DmaapDsaConfig.java

Change-Id: Idbc3c1c8306e97ad0d4eb0941d498df591a1f3eb
Issue-ID: HOLMES-29
Signed-off-by: Guangrong Fu <fu.guangrong@zte.com.cn>
dmaap-dsa/src/main/java/org/onap/holmes/dsa/dmaap/DmaapDsaActiveApp.java [new file with mode: 0644]
dmaap-dsa/src/main/java/org/onap/holmes/dsa/dmaap/DmaapDsaConfig.java [new file with mode: 0644]

diff --git a/dmaap-dsa/src/main/java/org/onap/holmes/dsa/dmaap/DmaapDsaActiveApp.java b/dmaap-dsa/src/main/java/org/onap/holmes/dsa/dmaap/DmaapDsaActiveApp.java
new file mode 100644 (file)
index 0000000..50e7fc4
--- /dev/null
@@ -0,0 +1,54 @@
+/*\r
+ * Copyright 2017 ZTE Corporation.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.onap.holmes.dsa.dmaap;\r
+\r
+import io.dropwizard.setup.Environment;\r
+import java.io.IOException;\r
+import lombok.extern.slf4j.Slf4j;\r
+import org.onap.holmes.common.api.entity.ServiceRegisterEntity;\r
+import org.onap.holmes.common.config.MicroServiceConfig;\r
+import org.onap.holmes.common.dropwizard.ioc.bundle.IOCApplication;\r
+import org.onap.holmes.common.utils.MSBRegisterUtil;\r
+\r
+@Slf4j\r
+public class DmaapDsaActiveApp  extends IOCApplication<DmaapDsaConfig> {\r
+    public static void main(String[] args) throws Exception {\r
+        new DmaapDsaActiveApp().run(args);\r
+    }\r
+\r
+    @Override\r
+    public void run(DmaapDsaConfig configuration, Environment environment) throws Exception {\r
+        super.run(configuration, environment);\r
+\r
+        try {\r
+            new MSBRegisterUtil().register(initServiceEntity());\r
+        } catch (IOException e) {\r
+            log.warn("Micro service registry httpclient close failure", e);\r
+        }\r
+    }\r
+\r
+    private ServiceRegisterEntity initServiceEntity() {\r
+        ServiceRegisterEntity serviceRegisterEntity = new ServiceRegisterEntity();\r
+        serviceRegisterEntity.setServiceName("holmes-dmaap-dsa");\r
+        serviceRegisterEntity.setProtocol("REST");\r
+        serviceRegisterEntity.setVersion("v1");\r
+        serviceRegisterEntity.setUrl("/onapapi/holmes-dmaap-dsa/v1/");\r
+        serviceRegisterEntity.setSingleNode(MicroServiceConfig.getServiceIp(), "9103", 0);\r
+        serviceRegisterEntity.setVisualRange("1|0");\r
+        return serviceRegisterEntity;\r
+    }\r
+}\r
diff --git a/dmaap-dsa/src/main/java/org/onap/holmes/dsa/dmaap/DmaapDsaConfig.java b/dmaap-dsa/src/main/java/org/onap/holmes/dsa/dmaap/DmaapDsaConfig.java
new file mode 100644 (file)
index 0000000..615bc04
--- /dev/null
@@ -0,0 +1,55 @@
+/*\r
+ * Copyright 2017 ZTE Corporation.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.onap.holmes.dsa.dmaap;\r
+\r
+import com.fasterxml.jackson.annotation.JsonProperty;\r
+import io.dropwizard.Configuration;\r
+import javax.validation.Valid;\r
+import javax.validation.constraints.NotNull;\r
+import org.hibernate.validator.constraints.NotEmpty;\r
+import org.onap.holmes.common.config.MQConfig;\r
+\r
+public class DmaapDsaConfig extends Configuration {\r
+\r
+    @NotEmpty\r
+    private String defaultName = "ONAP Holmes DMaaP DSA";\r
+\r
+    @NotEmpty\r
+    private String apidescription = "Holmes data Source adapter API";\r
+\r
+    @JsonProperty\r
+    @NotNull\r
+    @Valid\r
+    private MQConfig mqConfig;\r
+\r
+\r
+    public MQConfig getMqConfig() {\r
+        return mqConfig;\r
+    }\r
+\r
+    public void setMqConfig(MQConfig mqConfig) {\r
+        this.mqConfig = mqConfig;\r
+    }\r
+\r
+    public String getApidescription() {\r
+        return apidescription;\r
+    }\r
+\r
+    public void setApidescription(String apidescription) {\r
+        this.apidescription = apidescription;\r
+    }\r
+}\r