diff options
author | Guangrong Fu <fu.guangrong@zte.com.cn> | 2021-12-28 10:14:42 +0800 |
---|---|---|
committer | Guangrong Fu <fu.guangrong@zte.com.cn> | 2022-08-11 20:18:53 +0800 |
commit | a796bda2f8e2db093ce9f528f6e5960e4aa1b22c (patch) | |
tree | 04642b9f3be109a5ccc051e4876851aa0b4fa3f3 /rulemgt/src/main/java/org/onap/holmes/rulemgt/Initializer.java | |
parent | 71ad58788ebfd666f6922fd9c16f77a9a4e39e27 (diff) |
Migrate from DW to Springboot
Issue-ID: HOLMES-511
Signed-off-by: Guangrong Fu <fu.guangrong@zte.com.cn>
Change-Id: I1be0775a4fc8b754218cd584a5de7af96b2ee0e2
Diffstat (limited to 'rulemgt/src/main/java/org/onap/holmes/rulemgt/Initializer.java')
-rw-r--r-- | rulemgt/src/main/java/org/onap/holmes/rulemgt/Initializer.java | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/rulemgt/src/main/java/org/onap/holmes/rulemgt/Initializer.java b/rulemgt/src/main/java/org/onap/holmes/rulemgt/Initializer.java index 799f455..fc3e798 100644 --- a/rulemgt/src/main/java/org/onap/holmes/rulemgt/Initializer.java +++ b/rulemgt/src/main/java/org/onap/holmes/rulemgt/Initializer.java @@ -1,5 +1,5 @@ /** - * Copyright 2017-2018 ZTE Corporation. + * Copyright 2017-2022 ZTE Corporation. * <p> * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,7 +16,6 @@ package org.onap.holmes.rulemgt; -import org.jvnet.hk2.annotations.Service; import org.onap.holmes.common.config.MicroServiceConfig; import org.onap.holmes.common.exception.CorrelationException; import org.onap.holmes.common.utils.CommonUtils; @@ -25,31 +24,32 @@ import org.onap.msb.sdk.discovery.entity.MicroServiceInfo; import org.onap.msb.sdk.discovery.entity.Node; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.ApplicationArguments; +import org.springframework.boot.ApplicationRunner; +import org.springframework.stereotype.Component; -import javax.annotation.PostConstruct; -import javax.inject.Inject; import java.util.HashSet; import java.util.Set; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; -import static org.onap.holmes.common.config.MicroServiceConfig.POD_IP; import static org.onap.holmes.common.utils.CommonUtils.getEnv; import static org.onap.holmes.common.utils.CommonUtils.isIpAddress; -@Service -public class Initializer { +@Component +public class Initializer implements ApplicationRunner { private static final Logger logger = LoggerFactory.getLogger(Initializer.class); private volatile static boolean readyForMsbReg = false; private MsbRegister msbRegister; - @Inject + @Autowired public Initializer(MsbRegister msbRegister) { this.msbRegister = msbRegister; } - @PostConstruct - private void init() { + @Override + public void run(ApplicationArguments args) { Executors.newSingleThreadExecutor().execute(() -> { waitUntilReady(); try { @@ -93,7 +93,7 @@ public class Initializer { msinfo.setEnable_ssl(CommonUtils.isHttpsEnabled()); Set<Node> nodes = new HashSet<>(); Node node = new Node(); - node.setIp(isIpAddress(serviceIpAndPort[0]) ? serviceIpAndPort[0] : getEnv(POD_IP)); + node.setIp(isIpAddress(serviceIpAndPort[0]) ? serviceIpAndPort[0] : getEnv("HOLMES_RULE_MGMT_SERVICE_HOST")); node.setPort("9101"); /* Following codes will cause an unregistration from MSB (due to MSB malfunction), comment them for now String msbAddrTemplate = (CommonUtils.isHttpsEnabled() ? "https" : "http") |