Switched from Dropwizard to Springboot 97/130197/1
authorGuangrongFu <fu.guangrong@zte.com.cn>
Sat, 18 Dec 2021 07:07:55 +0000 (15:07 +0800)
committerGuangrong Fu <fu.guangrong@zte.com.cn>
Mon, 8 Aug 2022 07:34:43 +0000 (15:34 +0800)
Issue-ID: HOLMES-511

Signed-off-by: GuangrongFu <fu.guangrong@zte.com.cn>
Change-Id: If845dcc835ca4812d550b842fd861626265b4cf1

51 files changed:
holmes-actions/pom.xml
holmes-actions/src/main/java/org/onap/holmes/common/aai/AaiJsonParserUtil.java
holmes-actions/src/main/java/org/onap/holmes/common/aai/AaiQuery.java
holmes-actions/src/main/java/org/onap/holmes/common/aai/AaiQuery4Ccvpn2.java
holmes-actions/src/main/java/org/onap/holmes/common/aai/AaiQueryMdons.java
holmes-actions/src/main/java/org/onap/holmes/common/aai/AaiResponseUtil.java
holmes-actions/src/main/java/org/onap/holmes/common/aai/CorrelationUtil.java
holmes-actions/src/main/java/org/onap/holmes/common/api/entity/AlarmsCorrelation.java [deleted file]
holmes-actions/src/main/java/org/onap/holmes/common/config/GsonConfig.java [new file with mode: 0644]
holmes-actions/src/main/java/org/onap/holmes/common/config/MQConfig.java [deleted file]
holmes-actions/src/main/java/org/onap/holmes/common/constant/AlarmConst.java
holmes-actions/src/main/java/org/onap/holmes/common/database/DatabaseConfiguration.java [new file with mode: 0644]
holmes-actions/src/main/java/org/onap/holmes/common/database/DbDaoUtil.java [new file with mode: 0644]
holmes-actions/src/main/java/org/onap/holmes/common/dmaap/DmaapService.java
holmes-actions/src/main/java/org/onap/holmes/common/dmaap/Publisher.java
holmes-actions/src/main/java/org/onap/holmes/common/dmaap/store/ClosedLoopControlNameCache.java
holmes-actions/src/main/java/org/onap/holmes/common/dmaap/store/UniqueRequestIdCache.java
holmes-actions/src/main/java/org/onap/holmes/common/dropwizard/ioc/annotation/BaseService.java [deleted file]
holmes-actions/src/main/java/org/onap/holmes/common/dropwizard/ioc/annotation/Lazy.java [deleted file]
holmes-actions/src/main/java/org/onap/holmes/common/dropwizard/ioc/annotation/PostBaseService.java [deleted file]
holmes-actions/src/main/java/org/onap/holmes/common/dropwizard/ioc/annotation/PreBaseService.java [deleted file]
holmes-actions/src/main/java/org/onap/holmes/common/dropwizard/ioc/annotation/PreLoad.java [deleted file]
holmes-actions/src/main/java/org/onap/holmes/common/dropwizard/ioc/annotation/PreServiceLoad.java [deleted file]
holmes-actions/src/main/java/org/onap/holmes/common/dropwizard/ioc/bundle/AutoConfigBundle.java [deleted file]
holmes-actions/src/main/java/org/onap/holmes/common/dropwizard/ioc/bundle/AutoConfigBundleBuider.java [deleted file]
holmes-actions/src/main/java/org/onap/holmes/common/dropwizard/ioc/bundle/IOCApplication.java [deleted file]
holmes-actions/src/main/java/org/onap/holmes/common/dropwizard/ioc/bundle/ServiceLocatorManaged.java [deleted file]
holmes-actions/src/main/java/org/onap/holmes/common/dropwizard/ioc/utils/ServiceBinder.java [deleted file]
holmes-actions/src/main/java/org/onap/holmes/common/dropwizard/ioc/utils/ServiceLocatorHolder.java [deleted file]
holmes-actions/src/main/java/org/onap/holmes/common/engine/dao/EngineEntityDao.java
holmes-actions/src/main/java/org/onap/holmes/common/engine/dao/EngineEntityMapper.java
holmes-actions/src/main/java/org/onap/holmes/common/engine/service/EngineEntityService.java
holmes-actions/src/main/java/org/onap/holmes/common/engine/service/impl/EngineEntityServiceImpl.java
holmes-actions/src/main/java/org/onap/holmes/common/utils/AlarmInfoMapper.java
holmes-actions/src/main/java/org/onap/holmes/common/utils/CommonUtils.java
holmes-actions/src/main/java/org/onap/holmes/common/utils/CorrelationRuleMapper.java
holmes-actions/src/main/java/org/onap/holmes/common/utils/DbDaoUtil.java [deleted file]
holmes-actions/src/main/java/org/onap/holmes/common/utils/JerseyClient.java
holmes-actions/src/main/java/org/onap/holmes/common/utils/MsbRegister.java
holmes-actions/src/main/java/org/onap/holmes/common/utils/RestExceptionHandler.java [new file with mode: 0644]
holmes-actions/src/main/java/org/onap/holmes/common/utils/SpringContextUtil.java [new file with mode: 0644]
holmes-actions/src/main/java/org/onap/holmes/common/utils/transactionid/TransactionIdFilter.java
holmes-actions/src/test/java/org/onap/holmes/common/api/entity/AlarmsCorrelationTest.java [deleted file]
holmes-actions/src/test/java/org/onap/holmes/common/config/MQConfigTest.java [deleted file]
holmes-actions/src/test/java/org/onap/holmes/common/dropwizard/ioc/bundle/AutoConfigBundleTest.java [deleted file]
holmes-actions/src/test/java/org/onap/holmes/common/engine/dao/EngineEntityMapperTest.java
holmes-actions/src/test/java/org/onap/holmes/common/engine/service/impl/EngineEntityServiceImplTest.java
holmes-actions/src/test/java/org/onap/holmes/common/utils/AlarmInfoMapperTest.java
holmes-actions/src/test/java/org/onap/holmes/common/utils/CorrelationRuleMapperTest.java
holmes-actions/src/test/java/org/onap/holmes/common/utils/DbDaoUtilTest.java
pom.xml

index f5c884d..13555ba 100644 (file)
                 </exclusion>\r
             </exclusions>\r
         </dependency>\r
-        <dependency>\r
-            <groupId>io.dropwizard</groupId>\r
-            <artifactId>dropwizard-core</artifactId>\r
-            <scope>provided</scope>\r
-            <exclusions>\r
-                <exclusion>\r
-                    <groupId>com.fasterxml.jackson.core</groupId>\r
-                    <artifactId>jackson-core</artifactId>\r
-                </exclusion>\r
-                <exclusion>\r
-                    <groupId>com.fasterxml.jackson.core</groupId>\r
-                    <artifactId>jackson-databind</artifactId>\r
-                </exclusion>\r
-                <exclusion>\r
-                    <groupId>com.fasterxml.jackson.dataformat</groupId>\r
-                    <artifactId>jackson-dataformat-yaml</artifactId>\r
-                </exclusion>\r
-                <exclusion>\r
-                    <groupId>com.fasterxml.jackson.core</groupId>\r
-                    <artifactId>jackson-databind</artifactId>\r
-                </exclusion>\r
-            </exclusions>\r
-        </dependency>\r
         <dependency>\r
             <groupId>io.swagger</groupId>\r
             <artifactId>swagger-jersey2-jaxrs</artifactId>\r
@@ -90,7 +67,6 @@
         <dependency>\r
             <groupId>com.fasterxml.jackson.core</groupId>\r
             <artifactId>jackson-databind</artifactId>\r
-            <version>2.13.0</version>\r
         </dependency>\r
         <dependency>\r
             <groupId>org.projectlombok</groupId>\r
             <artifactId>powermock-module-junit4</artifactId>\r
             <scope>test</scope>\r
         </dependency>\r
-        <dependency>\r
-            <groupId>io.dropwizard</groupId>\r
-            <artifactId>dropwizard-jdbi</artifactId>\r
-            <scope>provided</scope>\r
-        </dependency>\r
         <dependency>\r
             <groupId>org.easymock</groupId>\r
             <artifactId>easymock</artifactId>\r
             <groupId>com.google.code.gson</groupId>\r
             <artifactId>gson</artifactId>\r
         </dependency>\r
+        <dependency>\r
+            <groupId>org.springframework</groupId>\r
+            <artifactId>spring-context</artifactId>\r
+        </dependency>\r
+        <dependency>\r
+            <groupId>org.springframework.boot</groupId>\r
+            <artifactId>spring-boot-autoconfigure</artifactId>\r
+        </dependency>\r
+        <dependency>\r
+            <groupId>org.springframework</groupId>\r
+            <artifactId>spring-web</artifactId>\r
+        </dependency>\r
+        <dependency>\r
+            <groupId>org.springframework</groupId>\r
+            <artifactId>spring-jdbc</artifactId>\r
+        </dependency>\r
+        <dependency>\r
+            <groupId>org.jdbi</groupId>\r
+            <artifactId>jdbi3-postgres</artifactId>\r
+        </dependency>\r
+        <dependency>\r
+            <groupId>org.jdbi</groupId>\r
+            <artifactId>jdbi3-sqlobject</artifactId>\r
+        </dependency>\r
+        <dependency>\r
+            <groupId>org.jdbi</groupId>\r
+            <artifactId>jdbi3-spring4</artifactId>\r
+        </dependency>\r
+        <dependency>\r
+            <groupId>javax.servlet</groupId>\r
+            <artifactId>javax.servlet-api</artifactId>\r
+        </dependency>\r
+        <dependency>\r
+            <groupId>org.postgresql</groupId>\r
+            <artifactId>postgresql</artifactId>\r
+            <version>42.2.13</version>\r
+            <scope>provided</scope>\r
+        </dependency>\r
+        <dependency>\r
+            <groupId>org.springframework</groupId>\r
+            <artifactId>spring-web</artifactId>\r
+            <version>5.3.13</version>\r
+        </dependency>\r
     </dependencies>\r
     <build>\r
         <resources>\r
             <plugin>\r
                 <groupId>org.apache.maven.plugins</groupId>\r
                 <artifactId>maven-compiler-plugin</artifactId>\r
-                <version>3.3</version>\r
+                <version>3.8.0</version>\r
                 <configuration>\r
-                    <source>1.8</source>\r
-                    <target>1.8</target>\r
+                    <source>8</source>\r
+                    <target>8</target>\r
+                    <release>11</release>\r
                 </configuration>\r
             </plugin>\r
         </plugins>\r
index ba66628..0a9e4f7 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * org.onap.holmes.common.aai
  * ================================================================================
- * Copyright (C) 2018-2020 Huawei. All rights reserved.
+ * Copyright (C) 2018-2021 Huawei, ZTE. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -24,18 +24,15 @@ import com.google.gson.JsonArray;
 import com.google.gson.JsonObject;
 import com.google.gson.JsonParser;
 import lombok.extern.slf4j.Slf4j;
-import org.jvnet.hk2.annotations.Service;
-import org.onap.holmes.common.aai.config.AaiConfig;
 import org.onap.holmes.common.config.MicroServiceConfig;
+import org.springframework.stereotype.Component;
 
-import javax.ws.rs.core.MultivaluedHashMap;
-import javax.ws.rs.core.MultivaluedMap;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
 
-@Service
 @Slf4j
+@Component
 public class AaiJsonParserUtil {
 
     public static String getPath(String urlTemplate, String paramName, String paramValue) {
index a73eb22..1bf79f2 100644 (file)
 package org.onap.holmes.common.aai;
 
 import lombok.extern.slf4j.Slf4j;
-import org.jvnet.hk2.annotations.Service;
 import org.onap.holmes.common.aai.config.AaiConfig;
 import org.onap.holmes.common.aai.entity.VmEntity;
 import org.onap.holmes.common.aai.entity.VnfEntity;
 import org.onap.holmes.common.exception.CorrelationException;
 import org.onap.holmes.common.utils.JerseyClient;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
 
-import javax.inject.Inject;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -30,7 +30,7 @@ import java.util.Map;
 @Slf4j
 public class AaiQuery {
 
-    @Inject
+    @Autowired
     private AaiResponseUtil aaiResponseUtil;
 
     public VnfEntity getAaiVnfData(String vnfId, String vnfName) throws CorrelationException {
index 41eb2c0..a9d9e53 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * org.onap.holmes.common.aai
  * ================================================================================
- * Copyright (C) 2018-2020 Huawei. All rights reserved.
+ * Copyright (C) 2018-2021 Huawei, ZTE. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -24,10 +24,9 @@ import com.google.gson.JsonArray;
 import com.google.gson.JsonObject;
 import com.google.gson.JsonParser;
 import lombok.extern.slf4j.Slf4j;
-import org.jvnet.hk2.annotations.Service;
 import org.onap.holmes.common.aai.config.AaiConfig;
-import org.onap.holmes.common.exception.CorrelationException;
 import org.onap.holmes.common.utils.JerseyClient;
+import org.springframework.stereotype.Service;
 
 import java.util.HashMap;
 import java.util.Map;
@@ -36,8 +35,8 @@ import java.util.regex.Pattern;
 
 import static org.onap.holmes.common.aai.AaiJsonParserUtil.*;
 
-@Service
 @Slf4j
+@Service
 public class AaiQuery4Ccvpn2 {
 
     private Map<String, Object> headers;
index c557003..f9e2e5d 100644 (file)
@@ -17,13 +17,13 @@ package org.onap.holmes.common.aai;
 import com.google.gson.JsonArray;
 import com.google.gson.JsonObject;
 import com.google.gson.JsonParser;
-import org.jvnet.hk2.annotations.Service;
 import org.onap.holmes.common.aai.config.AaiConfig;
 import org.onap.holmes.common.config.MicroServiceConfig;
 import org.onap.holmes.common.exception.CorrelationException;
 import org.onap.holmes.common.utils.JerseyClient;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
 
 import javax.ws.rs.client.Entity;
 import javax.ws.rs.core.MultivaluedHashMap;
index 5ad4984..896e694 100644 (file)
@@ -18,7 +18,6 @@ package org.onap.holmes.common.aai;
 import com.google.gson.JsonArray;
 import com.google.gson.JsonObject;
 import com.google.gson.JsonParser;
-import org.jvnet.hk2.annotations.Service;
 import org.onap.holmes.common.aai.entity.RelationshipList;
 import org.onap.holmes.common.aai.entity.RelationshipList.RelatedToProperty;
 import org.onap.holmes.common.aai.entity.RelationshipList.Relationship;
@@ -26,6 +25,7 @@ import org.onap.holmes.common.aai.entity.RelationshipList.RelationshipData;
 import org.onap.holmes.common.aai.entity.VmEntity;
 import org.onap.holmes.common.aai.entity.VmResourceLink;
 import org.onap.holmes.common.aai.entity.VnfEntity;
+import org.springframework.stereotype.Service;
 
 import java.util.ArrayList;
 import java.util.Collections;
index 6520552..51b4cf0 100644 (file)
@@ -1,5 +1,5 @@
 /**
- * Copyright 2017 ZTE Corporation.
+ * Copyright 2017-2021 ZTE Corporation.
  *
  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
  * in compliance with the License. You may obtain a copy of the License at
  */
 package org.onap.holmes.common.aai;
 
-import java.util.List;
-import java.util.Optional;
 import lombok.extern.slf4j.Slf4j;
 import org.onap.holmes.common.aai.entity.RelationshipList.Relationship;
 import org.onap.holmes.common.aai.entity.VmEntity;
-import org.onap.holmes.common.dropwizard.ioc.utils.ServiceLocatorHolder;
 import org.onap.holmes.common.exception.CorrelationException;
+import org.onap.holmes.common.utils.SpringContextUtil;
+
+import java.util.List;
+import java.util.Optional;
 
 @Slf4j
 public class CorrelationUtil {
@@ -33,7 +34,7 @@ public class CorrelationUtil {
 
     public static final CorrelationUtil getInstance() {
         if (aaiQuery == null) {
-            aaiQuery = ServiceLocatorHolder.getLocator().getService(AaiQuery.class);
+            aaiQuery = SpringContextUtil.getBean(AaiQuery.class);
         }
         return LazyHolder.INSTANCE;
     }
diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/api/entity/AlarmsCorrelation.java b/holmes-actions/src/main/java/org/onap/holmes/common/api/entity/AlarmsCorrelation.java
deleted file mode 100644 (file)
index e21f97d..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-/**\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
-package org.onap.holmes.common.api.entity;\r
-\r
-import com.google.gson.annotations.SerializedName;\r
-import java.util.Date;\r
-import lombok.Data;\r
-import lombok.Getter;\r
-import lombok.NoArgsConstructor;\r
-import lombok.Setter;\r
-\r
-@Getter\r
-@Setter\r
-@NoArgsConstructor\r
-public class AlarmsCorrelation {\r
-\r
-    @SerializedName(value = "ruleid")\r
-    private String ruleId;\r
-\r
-    @SerializedName(value = "ruleinfo")\r
-    private String ruleInfo;\r
-\r
-    @SerializedName(value = "resulttype")\r
-    private byte resultType;\r
-\r
-    @SerializedName(value = "createtime")\r
-    private Date createTime;\r
-\r
-    @SerializedName(value = "parentalarmid")\r
-    private long parentAlarmId;\r
-\r
-    @SerializedName(value = "childalarmid")\r
-    private long childAlarmId;\r
-\r
-    private long reserve1 = -1;\r
-\r
-    private long reserve2 = -1;\r
-\r
-    private long reserve3 = -1;\r
-\r
-    @Override\r
-    public String toString() {\r
-        StringBuilder sb = new StringBuilder("[");\r
-        sb.append("ruleId=").append(ruleId).append(",");\r
-        sb.append("ruleInfo=").append(ruleInfo).append(",");\r
-        sb.append("createTime=").append(createTime == null ? null : createTime.toString()).append(",");\r
-        sb.append("parentAlarmId=").append(parentAlarmId).append(",");\r
-        sb.append("childAlarmId=").append(childAlarmId).append(",");\r
-        sb.append("reserve1=").append(reserve1).append(",");\r
-        sb.append("reserve2=").append(reserve2).append(",");\r
-        sb.append("reserve3=").append(reserve3).append("]");\r
-        return sb.toString();\r
-    }\r
-}\r
diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/config/GsonConfig.java b/holmes-actions/src/main/java/org/onap/holmes/common/config/GsonConfig.java
new file mode 100644 (file)
index 0000000..58a8f35
--- /dev/null
@@ -0,0 +1,39 @@
+/**
+ * Copyright 2021 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.
+ * You may obtain a copy of the License at
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.holmes.common.config;
+
+import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.http.converter.HttpMessageConverter;
+import org.springframework.http.converter.json.GsonHttpMessageConverter;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+@Configuration
+public class GsonConfig {
+    @Bean
+    public HttpMessageConverters customConverters() {
+        Collection<HttpMessageConverter<?>> messageConverters = new ArrayList();
+
+        GsonHttpMessageConverter gsonHttpMessageConverter = new GsonHttpMessageConverter();
+        messageConverters.add(gsonHttpMessageConverter);
+
+        return new HttpMessageConverters(true, messageConverters);
+    }
+}
diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/config/MQConfig.java b/holmes-actions/src/main/java/org/onap/holmes/common/config/MQConfig.java
deleted file mode 100644 (file)
index 70ef0cb..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-/**\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.common.config;\r
-\r
-import lombok.Getter;\r
-import lombok.NoArgsConstructor;\r
-import lombok.Setter;\r
-\r
-@Getter\r
-@Setter\r
-@NoArgsConstructor\r
-public class MQConfig {\r
-\r
-    private String brokerIp;\r
-\r
-    private int brokerPort;\r
-\r
-    private String brokerUsername;\r
-\r
-    private String brokerPassword;\r
-}\r
index ba3d80e..0cdb66d 100644 (file)
 package org.onap.holmes.common.constant;\r
 \r
 public interface AlarmConst {\r
-\r
-    String MQ_TOPIC_NAME_ALARMS_CORRELATION = "topic://voss/fm/alarms_correlation";\r
-\r
-    String MQ_TOPIC_NAME_ALARM = "topic://voss/fm/alarm";\r
-\r
-    String NFVO_PATH = "/api/umc/v1/fm/curalarms/findAll";\r
-\r
-    int NFVO_STATUS_OK = 200;\r
-\r
     String I18N_EN = "en";\r
 \r
     String I18N_ZH = "zh";\r
@@ -33,10 +24,6 @@ public interface AlarmConst {
 \r
     String ADMIN = "admin";\r
 \r
-    int MICRO_SERVICE_STATUS_SUCCESS = 201;\r
-\r
-    int MICRO_SERVICE_PORT = 8086;\r
-\r
     String HTTP = "http://";\r
 \r
     String HTTPS = "https://";\r
diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/database/DatabaseConfiguration.java b/holmes-actions/src/main/java/org/onap/holmes/common/database/DatabaseConfiguration.java
new file mode 100644 (file)
index 0000000..101c350
--- /dev/null
@@ -0,0 +1,78 @@
+/**
+ * Copyright 2021 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.
+ * You may obtain a copy of the License at
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.holmes.common.database;
+
+import org.jdbi.v3.core.Jdbi;
+import org.jdbi.v3.core.mapper.RowMapper;
+import org.jdbi.v3.core.spi.JdbiPlugin;
+import org.jdbi.v3.postgres.PostgresPlugin;
+import org.jdbi.v3.sqlobject.SqlObjectPlugin;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy;
+
+import javax.sql.DataSource;
+import java.util.List;
+
+@Configuration
+public class DatabaseConfiguration {
+//
+//    @Value("${spring.datasource.url}")
+//    private String url;
+//
+//    @Value("${spring.datasource.username}")
+//    private String username;
+//
+//    @Value("${spring.datasource.password}")
+//    private String pwd;
+//
+//    @Value("${spring.datasource.dirver-class-name}")
+//    private String driverClass;
+//
+//    @Bean
+//    public DataSource driverManagerDataSource() {
+//        System.out.println("======================================: " + driverClass);
+//        DriverManagerDataSource ds = new DriverManagerDataSource();
+//        ds.setDriverClassName(driverClass);
+//        ds.setUrl(url);
+//        ds.setUsername(username);
+//        ds.setPassword(pwd);
+//        return ds;
+//    }
+
+//    @Bean
+//    public DataSourceTransactionManager dataSourceTransactionManager(DataSource dataSource) {
+//        DataSourceTransactionManager dataSourceTransactionManager = new DataSourceTransactionManager();
+//        dataSourceTransactionManager.setDataSource(dataSource);
+//        return dataSourceTransactionManager;
+//    }
+
+    @Bean
+    public Jdbi jdbi(DataSource dataSource) {
+        return Jdbi.create(dataSource)
+                .installPlugin(new SqlObjectPlugin())
+                .installPlugin(new PostgresPlugin());
+    }
+
+//    @Bean
+//    public Jdbi jdbi(DataSource ds, List<JdbiPlugin> jdbiPlugins, List<RowMapper<?>> rowMappers) {
+//        TransactionAwareDataSourceProxy proxy = new TransactionAwareDataSourceProxy(ds);
+//        Jdbi jdbi = Jdbi.create(proxy);
+//        jdbiPlugins.forEach(plugin -> jdbi.installPlugin(plugin));
+//        rowMappers.forEach(mapper -> jdbi.registerRowMapper(mapper));
+//        return jdbi;
+//    }
+}
diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/database/DbDaoUtil.java b/holmes-actions/src/main/java/org/onap/holmes/common/database/DbDaoUtil.java
new file mode 100644 (file)
index 0000000..2cbb538
--- /dev/null
@@ -0,0 +1,40 @@
+/**\r
+ * Copyright 2017-2021 ZTE Corporation.\r
+ * <p>\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
+ * <p>\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * <p>\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
+package org.onap.holmes.common.database;\r
+\r
+import org.jdbi.v3.core.Handle;\r
+import org.jdbi.v3.core.Jdbi;\r
+import org.springframework.beans.factory.annotation.Autowired;\r
+import org.springframework.stereotype.Service;\r
+\r
+@Service\r
+public class DbDaoUtil {\r
+    private Jdbi jdbi;\r
+\r
+    @Autowired\r
+    public DbDaoUtil(Jdbi jdbi) {\r
+        this.jdbi = jdbi;\r
+    }\r
+\r
+    public <T> T getJdbiDaoByOnDemand(Class<T> daoClazz) {\r
+        return jdbi.onDemand(daoClazz);\r
+    }\r
+\r
+    @Deprecated\r
+    public Handle getHandle() {\r
+        return jdbi.open();\r
+    }\r
+}\r
index e9eb003..de7d74f 100644 (file)
@@ -15,7 +15,6 @@
  */
 package org.onap.holmes.common.dmaap;
 
-import org.jvnet.hk2.annotations.Service;
 import org.onap.holmes.common.aai.AaiQuery;
 import org.onap.holmes.common.aai.entity.RelationshipList.Relationship;
 import org.onap.holmes.common.aai.entity.VmEntity;
@@ -30,8 +29,9 @@ import org.onap.holmes.common.exception.CorrelationException;
 import org.onap.holmes.common.utils.GsonUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
 
-import javax.inject.Inject;
 import java.util.Map.Entry;
 import java.util.Optional;
 import java.util.UUID;
@@ -45,17 +45,17 @@ public class DmaapService {
     private ClosedLoopControlNameCache closedLoopControlNameCache;
     private UniqueRequestIdCache uniqueRequestIdCache;
 
-    @Inject
+    @Autowired
     public void setAaiQuery(AaiQuery aaiQuery) {
         this.aaiQuery = aaiQuery;
     }
 
-    @Inject
+    @Autowired
     public void setClosedLoopControlNameCache(ClosedLoopControlNameCache closedLoopControlNameCache) {
         this.closedLoopControlNameCache = closedLoopControlNameCache;
     }
 
-    @Inject
+    @Autowired
     public void setUniqueRequestIdCache(UniqueRequestIdCache uniqueRequestIdCache) {
         this.uniqueRequestIdCache = uniqueRequestIdCache;
     }
index 23a04d6..b1c5595 100644 (file)
@@ -17,9 +17,9 @@ package org.onap.holmes.common.dmaap;
 \r
 import lombok.Getter;\r
 import lombok.Setter;\r
-import org.jvnet.hk2.annotations.Service;\r
 import org.onap.holmes.common.dmaap.entity.PolicyMsg;\r
 import org.onap.holmes.common.utils.JerseyClient;\r
+import org.springframework.stereotype.Service;\r
 \r
 import javax.ws.rs.client.Entity;\r
 import java.util.concurrent.TimeUnit;\r
index 8a692b2..2d9cf99 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2020 ZTE Corporation.
+ * Copyright 2020-2021 ZTE Corporation.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  */
 package org.onap.holmes.common.dmaap.store;
 
-import org.jvnet.hk2.annotations.Service;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
 
-import javax.inject.Singleton;
 import java.util.concurrent.ConcurrentHashMap;
 
-@Service
-@Singleton
+@Component
 public class ClosedLoopControlNameCache extends ConcurrentHashMap<String, String> {
 
     private static final Logger log = LoggerFactory.getLogger(ClosedLoopControlNameCache.class);
index 070159e..f4e2459 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2020 ZTE Corporation.
+ * Copyright 2020-2021 ZTE Corporation.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  */
 package org.onap.holmes.common.dmaap.store;
 
-import org.jvnet.hk2.annotations.Service;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
 
 import javax.inject.Singleton;
 import java.util.concurrent.ConcurrentHashMap;
 
-@Service
+@Component
 @Singleton
 public class UniqueRequestIdCache extends ConcurrentHashMap<String, String> {
 
diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/dropwizard/ioc/annotation/BaseService.java b/holmes-actions/src/main/java/org/onap/holmes/common/dropwizard/ioc/annotation/BaseService.java
deleted file mode 100644 (file)
index 9f0ae67..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
- * Copyright 2017 ZTE Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onap.holmes.common.dropwizard.ioc.annotation;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * basic services for identification
- * @author hu.rui
- *
- */
-@Target({ElementType.TYPE})
-@Retention(RetentionPolicy.RUNTIME)
-@Documented
-public @interface BaseService {
-
-}
diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/dropwizard/ioc/annotation/Lazy.java b/holmes-actions/src/main/java/org/onap/holmes/common/dropwizard/ioc/annotation/Lazy.java
deleted file mode 100644 (file)
index 4f7d046..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
- * Copyright 2017 ZTE Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onap.holmes.common.dropwizard.ioc.annotation;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * lazy loading of related services
- * @author hu.rui
- *
- */
-@Target({ElementType.TYPE})
-@Retention(RetentionPolicy.RUNTIME)
-@Documented
-public @interface Lazy {
-
-}
diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/dropwizard/ioc/annotation/PostBaseService.java b/holmes-actions/src/main/java/org/onap/holmes/common/dropwizard/ioc/annotation/PostBaseService.java
deleted file mode 100644 (file)
index 4787bec..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
- * Copyright 2017 ZTE Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onap.holmes.common.dropwizard.ioc.annotation;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * load on after basic services
- * @author hu.rui
- *
- */
-@Target({ElementType.TYPE})
-@Retention(RetentionPolicy.RUNTIME)
-@Documented
-public @interface PostBaseService {
-
-}
diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/dropwizard/ioc/annotation/PreBaseService.java b/holmes-actions/src/main/java/org/onap/holmes/common/dropwizard/ioc/annotation/PreBaseService.java
deleted file mode 100644 (file)
index 669bceb..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
- * Copyright 2017 ZTE Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onap.holmes.common.dropwizard.ioc.annotation;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * prior to basic service loading
- * @author hu.rui
- *
- */
-@Target({ElementType.TYPE})
-@Retention(RetentionPolicy.RUNTIME)
-@Documented
-public @interface PreBaseService {
-
-}
diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/dropwizard/ioc/annotation/PreLoad.java b/holmes-actions/src/main/java/org/onap/holmes/common/dropwizard/ioc/annotation/PreLoad.java
deleted file mode 100644 (file)
index dce3e58..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
- * Copyright 2017 ZTE Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onap.holmes.common.dropwizard.ioc.annotation;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * load before general service
- * @author hu.rui
- *
- */
-@Target({ElementType.TYPE})
-@Retention(RetentionPolicy.RUNTIME)
-@Documented
-public @interface PreLoad {
-
-}
diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/dropwizard/ioc/annotation/PreServiceLoad.java b/holmes-actions/src/main/java/org/onap/holmes/common/dropwizard/ioc/annotation/PreServiceLoad.java
deleted file mode 100644 (file)
index 815c1d7..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-/**
- * Copyright 2017 ZTE Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onap.holmes.common.dropwizard.ioc.annotation;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * 
- * load before general service,after PreLoad
- * @author hu.rui
- *
- */
-@Target({ElementType.TYPE})
-@Retention(RetentionPolicy.RUNTIME)
-@Documented
-public @interface PreServiceLoad {
-
-}
diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/dropwizard/ioc/bundle/AutoConfigBundle.java b/holmes-actions/src/main/java/org/onap/holmes/common/dropwizard/ioc/bundle/AutoConfigBundle.java
deleted file mode 100644 (file)
index fe9ee5a..0000000
+++ /dev/null
@@ -1,367 +0,0 @@
-/**
- * Copyright 2017 - 2021 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.
- * You may obtain a copy of the License at
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onap.holmes.common.dropwizard.ioc.bundle;
-
-import com.codahale.metrics.health.HealthCheck;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.google.common.collect.Lists;
-import io.dropwizard.Configuration;
-import io.dropwizard.ConfiguredBundle;
-import io.dropwizard.lifecycle.ServerLifecycleListener;
-import io.dropwizard.servlets.tasks.Task;
-import io.dropwizard.setup.Bootstrap;
-import io.dropwizard.setup.Environment;
-import org.eclipse.jetty.util.component.LifeCycle;
-import org.glassfish.hk2.api.ServiceLocator;
-import org.glassfish.hk2.api.ServiceLocatorFactory;
-import org.glassfish.hk2.utilities.ServiceLocatorUtilities;
-import org.glassfish.hk2.utilities.binding.AbstractBinder;
-import org.glassfish.jersey.servlet.ServletProperties;
-import org.jvnet.hk2.annotations.Service;
-import org.onap.holmes.common.dropwizard.ioc.annotation.*;
-import org.onap.holmes.common.dropwizard.ioc.utils.ServiceBinder;
-import org.onap.holmes.common.dropwizard.ioc.utils.ServiceLocatorHolder;
-import org.reflections.Reflections;
-import org.reflections.scanners.SubTypesScanner;
-import org.reflections.scanners.TypeAnnotationsScanner;
-import org.reflections.util.ClasspathHelper;
-import org.reflections.util.ConfigurationBuilder;
-import org.reflections.util.FilterBuilder;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.ws.rs.Path;
-import javax.ws.rs.ext.Provider;
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Field;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Set;
-import java.util.stream.Collectors;
-
-/**
- * complete the integration of hK2 container and dropwizard
- *
- * @author hu.rui
- */
-
-public class AutoConfigBundle<T extends Configuration> implements ConfiguredBundle<T> {
-
-    private static final Logger LOG = LoggerFactory.getLogger(AutoConfigBundle.class);
-
-    private ServiceLocator locator;
-    private Reflections reflections;
-    private Set<Class<?>> services;
-
-    private Bootstrap<?> bootstrap;
-
-
-    AutoConfigBundle(final String packageName) {
-        this(Lists.newArrayList(packageName));
-    }
-
-    AutoConfigBundle(List<String> packageNames) {
-        FilterBuilder filterBuilder = new FilterBuilder();
-
-        packageNames.stream().forEach(packageName -> filterBuilder.include(FilterBuilder.prefix(packageName)));
-        ConfigurationBuilder reflectionCfg = new ConfigurationBuilder();
-
-        packageNames.stream().forEach(packageName -> reflectionCfg.addUrls(ClasspathHelper.forPackage(packageName)));
-
-        reflectionCfg.filterInputsBy(filterBuilder).setScanners(new SubTypesScanner(),
-                new TypeAnnotationsScanner());
-        reflections = new Reflections(reflectionCfg);
-
-        locator = ServiceLocatorFactory.getInstance().create("dw-hk2");
-
-        ServiceLocatorHolder.setLocator(locator);
-
-    }
-
-    public static <T extends Configuration> AutoConfigBundleBuider<T> newBuilder() {
-        return new AutoConfigBundleBuider<T>();
-    }
-
-    @Override
-    public void initialize(final Bootstrap<?> bootstrap) {
-
-        this.bootstrap = bootstrap;
-        registerPreLoadService();
-
-        LOG.debug("Intialzing auto config bundle.");
-    }
-
-    private void registerPreLoadService() {
-        registerService(PreLoad.class);
-    }
-
-
-    @Override
-    public void run(final T configuration, final Environment environment) {
-
-        registerConfigurationProvider(configuration, environment);
-
-        registerEnvironment(environment);
-        registerObjectMapper(environment);
-
-        environment.getApplicationContext().getServletContext()
-                .setAttribute(ServletProperties.SERVICE_LOCATOR, locator);
-
-        registerService(PreBaseService.class);
-        registerService(BaseService.class);
-        registerService(PostBaseService.class);
-        this.registerService(PreServiceLoad.class);
-
-
-        registerServices();
-
-        registerLifecycle(environment);
-        registerServerLifecycleListeners(environment);
-        registerJettyLifeCycleListener(environment);
-        registerTasks(environment);
-        registerHealthChecks(environment);
-        registerProviders(environment);
-        registerResources(environment);
-
-        environment.lifecycle().manage(new ServiceLocatorManaged(locator));
-
-    }
-
-
-    private void registerProviders(Environment environment) {
-        reflections.getSubTypesOf(Provider.class).stream().filter(services::contains)
-                .forEach(providerKlass -> {
-                    try {
-                        environment.jersey().register(locator.getService(providerKlass));
-                    } catch (Exception e) {
-                        LOG.warn("", e);
-                    }
-
-                    LOG.info("Registering Dropwizard Provider, class name : {}", providerKlass.getName());
-
-                });
-
-    }
-
-    private void registerTasks(Environment environment) {
-        reflections.getSubTypesOf(Task.class).stream().filter(services::contains).forEach(taskKlass -> {
-            try {
-                environment.admin().addTask(locator.getService(taskKlass));
-            } catch (Exception e) {
-                LOG.warn("", e);
-            }
-            LOG.info("Registering Dropwizard Task, class name : {}", taskKlass.getName());
-        });
-
-    }
-
-    private void registerJettyLifeCycleListener(Environment environment) {
-        reflections.getSubTypesOf(LifeCycle.Listener.class).stream().filter(services::contains)
-                .forEach(lifecycleListenerKlass -> {
-                    try {
-                        environment.lifecycle()
-                                .addLifeCycleListener(locator.getService(lifecycleListenerKlass));
-                    } catch (Exception e) {
-                        LOG.warn("", e);
-                    }
-                    LOG.info("Registering Dropwizard lifecycleListener, class name : {}",
-                            lifecycleListenerKlass.getName());
-                });
-
-    }
-
-    private void registerServerLifecycleListeners(Environment environment) {
-
-        reflections.getSubTypesOf(ServerLifecycleListener.class).stream().filter(services::contains)
-                .forEach(serverLifecycleListenerKlass -> {
-                    try {
-                        environment.lifecycle()
-                                .addServerLifecycleListener(locator.getService(serverLifecycleListenerKlass));
-                    } catch (Exception e) {
-                        LOG.warn("", e);
-                    }
-                    LOG.info("Registering Dropwizard serverLifecycleListener, class name : {}",
-                            serverLifecycleListenerKlass.getName());
-                });
-
-    }
-
-    private void registerLifecycle(Environment environment) {
-        reflections.getSubTypesOf(LifeCycle.class).stream().filter(services::contains)
-                .forEach(lifeCycleKlass -> {
-                    try {
-                        environment.lifecycle().manage(locator.getService(lifeCycleKlass));
-                    } catch (Exception e) {
-                        LOG.warn("", e);
-                    }
-                    LOG.info("Registering Dropwizard LifeCycle, class name : {}", lifeCycleKlass.getName());
-                });
-    }
-
-    private void registerObjectMapper(Environment environment) {
-
-        final ObjectMapper objectMapper = environment.getObjectMapper();
-
-        ServiceLocatorUtilities.bind(locator, new AbstractBinder() {
-            @Override
-            protected void configure() {
-                bind(objectMapper).to(ObjectMapper.class);
-
-                LOG.info("Registering Dropwizard objectMapper, class name : {}",
-                        objectMapper.getClass().getName());
-            }
-        });
-
-    }
-
-    private void registerEnvironment(final Environment environment) {
-
-        ServiceLocatorUtilities.bind(locator, new AbstractBinder() {
-            @Override
-            protected void configure() {
-                bind(environment).to(Environment.class);
-
-                LOG.info("Registering Dropwizard environment, class name : {}",
-                        environment.getClass().getName());
-            }
-        });
-
-    }
-
-    private void registerConfigurationProvider(final T configuration, final Environment environment) {
-
-        ServiceLocatorUtilities.bind(locator, new AbstractBinder() {
-            @Override
-            protected void configure() {
-                bind(configuration);
-                LOG.info("Registering Dropwizard Configuration class name:{}",
-                        configuration.getClass().getName());
-                bind((Configuration) configuration).to(Configuration.class);
-                LOG.info("Registering Dropwizard Configuration class name:{}",
-                        Configuration.class.getName());
-            }
-        });
-
-        registerSubConfigure(configuration, environment);
-
-    }
-
-    private void registerSubConfigure(final T configuration, final Environment environment) {
-        final List<Field> subDeclaredFields =
-                Arrays.asList(configuration.getClass().getDeclaredFields());
-        List<Field> parentDeclaredFields = Arrays.asList(Configuration.class.getDeclaredFields());
-
-        List<Field> filtersubDeclaredFields = subDeclaredFields.stream()
-                .filter(subDeclaredField -> !subDeclaredField.getType().isPrimitive())
-                .filter(subDeclaredField -> !subDeclaredField.getType().equals(String.class))
-                .filter(subDeclaredField -> !parentDeclaredFields.contains(subDeclaredField))
-                .collect(Collectors.toList());
-
-        ServiceLocatorUtilities.bind(locator, new AbstractBinder() {
-            @Override
-            protected void configure() {
-                filtersubDeclaredFields.forEach(subField -> {
-                    subField.setAccessible(true);
-                    try {
-                        Object subConfig = subField.get(configuration);
-                        if (subConfig != null) {
-                            bind(subConfig);
-                            LOG.info("Registering Dropwizard Sub Configuration class name {}",
-                                    subConfig.getClass().getName());
-                        }
-
-                    } catch (Exception e) {
-                        LOG.error("bind sub config:{} fail", subField);
-                    }
-                });
-            }
-        });
-
-    }
-
-    private void registerServices() {
-        services = this.reflections.getTypesAnnotatedWith(Service.class, true);
-        if (!services.isEmpty()) {
-            ServiceLocatorUtilities.bind(locator, new ServiceBinder(services));
-            services.forEach(s -> LOG.info("Registering Dropwizard service, class name : {}", s.getName()));
-            recordTimeCost(services);
-        } else {
-            LOG.warn("Registering Dropwizard service is empty");
-        }
-
-    }
-
-
-    private void registerResources(final Environment environment) {
-        reflections.getTypesAnnotatedWith(Path.class).stream().forEach(resourceClass -> {
-
-            LOG.info("begin Registering Dropwizard resource, class name : {}", resourceClass.getName());
-            try {
-                Object resourceObject = locator.getService(resourceClass);
-                if (resourceObject != null) {
-                    environment.jersey().register(resourceObject);
-                    LOG.info("Registering Dropwizard resource, class name : {}", resourceClass.getName());
-                } else {
-                    LOG.warn(resourceClass.getName() + " not use Service annotation");
-                }
-            } catch (Exception e) {
-                LOG.error("", e);
-            }
-        });
-    }
-
-    private void registerHealthChecks(final Environment env) {
-        reflections.getSubTypesOf(HealthCheck.class).stream().filter(services::contains)
-                .forEach(healthCheckKlass -> {
-                    try {
-                        env.healthChecks().register(healthCheckKlass.getName(),
-                                locator.getService(healthCheckKlass));
-                    } catch (Exception e) {
-                        LOG.warn("", e);
-                    }
-                    LOG.info("Registering Dropwizard healthCheck, class name : {}",
-                            healthCheckKlass.getName());
-                });
-    }
-
-    private void registerService(Class<? extends Annotation> annotationClazz) {
-
-        Set<Class<?>> services = this.reflections.getTypesAnnotatedWith(annotationClazz, true);
-        if (!services.isEmpty()) {
-            ServiceLocatorUtilities.bind(locator, new ServiceBinder(services));
-            services.forEach(s -> LOG.info("{} Registering  service, class name : {}", annotationClazz.getName(),
-                    s.getName()));
-            recordTimeCost(services);
-        } else {
-            LOG.warn("Registering {} service is empty", annotationClazz.getName());
-        }
-    }
-
-    private void recordTimeCost(Set<Class<?>> services) {
-        services.stream().filter(serviceClazz -> (serviceClazz.getAnnotation(Lazy.class) == null))
-                .peek(serviceClazz -> LOG.info("active service, class name : {}", serviceClazz.getName()))
-                .forEach(serviceClazz -> {
-                    try {
-                        long startTime = System.currentTimeMillis();
-                        locator.getService(serviceClazz);
-                        LOG.info("active service, class name : {},cost time:{}", serviceClazz.getName(),
-                                (System.currentTimeMillis() - startTime));
-                    } catch (Exception e) {
-                        LOG.warn("", e);
-                    }
-                });
-    }
-}
diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/dropwizard/ioc/bundle/AutoConfigBundleBuider.java b/holmes-actions/src/main/java/org/onap/holmes/common/dropwizard/ioc/bundle/AutoConfigBundleBuider.java
deleted file mode 100644 (file)
index a439ff0..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/**
- * Copyright 2017 ZTE Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onap.holmes.common.dropwizard.ioc.bundle;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import io.dropwizard.Configuration;
-
-public class AutoConfigBundleBuider<T extends Configuration> {
-       
-       private static final String DEFAULT_PACKAGE_NAME="org.onap";
-       
-    private List<String> packageNames=new ArrayList<>();
-    
-    public AutoConfigBundleBuider(){
-       packageNames.add( DEFAULT_PACKAGE_NAME);
-    }
-    
-    public AutoConfigBundleBuider<T> addPackageName(String packageName) {
-        this.packageNames.add(packageName);
-        return this;
-    }
-
-    
-    public AutoConfigBundle<T> build() {
-        return new AutoConfigBundle<T>(packageNames);
-    }
-}
diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/dropwizard/ioc/bundle/IOCApplication.java b/holmes-actions/src/main/java/org/onap/holmes/common/dropwizard/ioc/bundle/IOCApplication.java
deleted file mode 100644 (file)
index 6025028..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/**
- * Copyright 2017 ZTE Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onap.holmes.common.dropwizard.ioc.bundle;
-
-import io.dropwizard.Application;
-import io.dropwizard.Configuration;
-import io.dropwizard.setup.Bootstrap;
-import io.dropwizard.setup.Environment;
-
-/**
- * complete IOC container startup
- * 
- * @author hu.rui2
- *
- */
-public abstract class IOCApplication<T extends Configuration> extends Application<T> {
-
-
-  @Override
-  public void initialize(Bootstrap<T> bootstrap) {
-    super.initialize(bootstrap);
-    bootstrap.addBundle(new AutoConfigBundleBuider().build());
-  }
-
-  @Override
-  public void run(T configuration, Environment environment) throws Exception {
-
-  }
-}
diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/dropwizard/ioc/bundle/ServiceLocatorManaged.java b/holmes-actions/src/main/java/org/onap/holmes/common/dropwizard/ioc/bundle/ServiceLocatorManaged.java
deleted file mode 100644 (file)
index d6c0563..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * Copyright 2017 ZTE Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onap.holmes.common.dropwizard.ioc.bundle;
-
-import org.glassfish.hk2.api.ServiceLocator;
-
-import io.dropwizard.lifecycle.Managed;
-
-/**
- * Life cycle management for IOC containers
- * @author hu.rui
- *
- */
-public class ServiceLocatorManaged implements Managed{
-       
-       
-       
-       private ServiceLocator locator;
-       
-       
-
-       public ServiceLocatorManaged(ServiceLocator locator) {
-               super();
-               this.locator = locator;
-       }
-
-       @Override
-       public void start() throws Exception {
-               
-               
-       }
-
-       @Override
-       public void stop() throws Exception {
-               locator.shutdown();
-       }
-
-}
diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/dropwizard/ioc/utils/ServiceBinder.java b/holmes-actions/src/main/java/org/onap/holmes/common/dropwizard/ioc/utils/ServiceBinder.java
deleted file mode 100644 (file)
index f5801c8..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-/**
- * Copyright 2017 ZTE Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onap.holmes.common.dropwizard.ioc.utils;
-
-import java.util.Set;
-
-import org.glassfish.hk2.utilities.binding.AbstractBinder;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * @author hu.rui
- *
- */
-public class ServiceBinder extends AbstractBinder {
-       
-       private static final Logger LOG = LoggerFactory.getLogger(ServiceBinder.class);
-       
-       final Set<Class<?>> klasses;
-
-       public ServiceBinder(Set<Class<?>> services) {
-               this.klasses = services;
-       }
-
-       @Override
-       protected void configure() {
-               for (Class<?> klass : this.klasses) {
-                       
-                       try{
-                               LOG.info("start active class:"+klass.getName());
-                               addActiveDescriptor(klass);
-                       }catch(Exception e){
-                               LOG.info("active class error:"+klass.getName(),e);
-                       }
-                       
-                       
-               }
-       }
-}
diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/dropwizard/ioc/utils/ServiceLocatorHolder.java b/holmes-actions/src/main/java/org/onap/holmes/common/dropwizard/ioc/utils/ServiceLocatorHolder.java
deleted file mode 100644 (file)
index 394ab6c..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/**
- * Copyright 2017 ZTE Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onap.holmes.common.dropwizard.ioc.utils;
-
-import org.glassfish.hk2.api.ServiceLocator;
-
-/**
- * @author hu.rui
- *
- */
-public class ServiceLocatorHolder {
-
-       private static ServiceLocator locator;
-
-       public static ServiceLocator getLocator() {
-               return locator;
-       }
-
-       public static void setLocator(ServiceLocator locator) {
-               ServiceLocatorHolder.locator = locator;
-       }
-       
-}
index 5ca38e0..71c9827 100644 (file)
@@ -1,5 +1,5 @@
 /**
- * Copyright 2020 ZTE Corporation.
+ * Copyright 2020-2021 ZTE Corporation.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
 
 package org.onap.holmes.common.engine.dao;
 
+import org.jdbi.v3.sqlobject.config.RegisterRowMapper;
+import org.jdbi.v3.sqlobject.customizer.Bind;
+import org.jdbi.v3.sqlobject.customizer.BindBean;
+import org.jdbi.v3.sqlobject.statement.SqlQuery;
+import org.jdbi.v3.sqlobject.statement.SqlUpdate;
 import org.onap.holmes.common.engine.entity.EngineEntity;
-import org.skife.jdbi.v2.sqlobject.Bind;
-import org.skife.jdbi.v2.sqlobject.BindBean;
-import org.skife.jdbi.v2.sqlobject.SqlQuery;
-import org.skife.jdbi.v2.sqlobject.SqlUpdate;
-import org.skife.jdbi.v2.sqlobject.customizers.RegisterMapper;
 
 import java.util.List;
 
-@RegisterMapper(EngineEntityMapper.class)
+@RegisterRowMapper(EngineEntityMapper.class)
 public interface EngineEntityDao {
     @SqlQuery("SELECT * FROM ENGINE_ENTITY WHERE ID = :id")
     EngineEntity getEntity(@Bind("id") String id);
index cda38a5..5432027 100644 (file)
@@ -1,5 +1,5 @@
 /**
- * Copyright 2020 ZTE Corporation.
+ * Copyright 2020-2021 ZTE Corporation.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
 
 package org.onap.holmes.common.engine.dao;
 
+import org.jdbi.v3.core.mapper.RowMapper;
+import org.jdbi.v3.core.statement.StatementContext;
 import org.onap.holmes.common.engine.entity.EngineEntity;
-import org.skife.jdbi.v2.StatementContext;
-import org.skife.jdbi.v2.tweak.ResultSetMapper;
 
 import java.sql.ResultSet;
 import java.sql.SQLException;
 
-public class EngineEntityMapper implements ResultSetMapper<EngineEntity> {
+public class EngineEntityMapper implements RowMapper<EngineEntity> {
     @Override
-    public EngineEntity map(int i, ResultSet resultSet, StatementContext statementContext) throws SQLException {
+    public EngineEntity map(ResultSet rs, StatementContext ctx) throws SQLException {
         EngineEntity entity = new EngineEntity();
-        entity.setIp(resultSet.getString("ip"));
-        entity.setPort(resultSet.getInt("port"));
-        entity.setLastModified(resultSet.getLong("lastmodified"));
+        entity.setIp(rs.getString("ip"));
+        entity.setPort(rs.getInt("port"));
+        entity.setLastModified(rs.getLong("lastmodified"));
         return entity;
     }
 }
\ No newline at end of file
index b913f38..630d55c 100644 (file)
@@ -1,5 +1,5 @@
 /**
- * Copyright 2020 ZTE Corporation.
+ * Copyright 2020-2021 ZTE Corporation.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
 
 package org.onap.holmes.common.engine.service;
 
-import org.jvnet.hk2.annotations.Contract;
 import org.onap.holmes.common.engine.entity.EngineEntity;
 
 import java.util.List;
 
-@Contract
 public interface EngineEntityService {
     EngineEntity getEntity(String id);
     List<EngineEntity> getAllEntities();
index 62d2388..7692cf9 100644 (file)
 
 package org.onap.holmes.common.engine.service.impl;
 
-import org.jvnet.hk2.annotations.Service;
+import org.onap.holmes.common.database.DbDaoUtil;
 import org.onap.holmes.common.engine.dao.EngineEntityDao;
 import org.onap.holmes.common.engine.entity.EngineEntity;
 import org.onap.holmes.common.engine.service.EngineEntityService;
-import org.onap.holmes.common.utils.DbDaoUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
 
-import javax.inject.Inject;
 import java.util.List;
 
 @Service
@@ -30,7 +30,7 @@ public class EngineEntityServiceImpl implements EngineEntityService {
 
     private EngineEntityDao engineEntityDao;
 
-    @Inject
+    @Autowired
     public EngineEntityServiceImpl(DbDaoUtil dbDaoUtil){
         engineEntityDao = dbDaoUtil.getJdbiDaoByOnDemand(EngineEntityDao.class);
     }
index e5b0830..996df25 100644 (file)
@@ -1,5 +1,5 @@
 /**\r
- * Copyright 2017 ZTE Corporation.\r
+ * Copyright 2017-2021 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
  */\r
 package org.onap.holmes.common.utils;\r
 \r
+import org.jdbi.v3.core.mapper.RowMapper;\r
+import org.jdbi.v3.core.statement.StatementContext;\r
 import org.onap.holmes.common.api.entity.AlarmInfo;\r
-import org.skife.jdbi.v2.StatementContext;\r
-import org.skife.jdbi.v2.tweak.ResultSetMapper;\r
+\r
 \r
 import java.sql.ResultSet;\r
 import java.sql.SQLException;\r
 \r
-public class AlarmInfoMapper implements ResultSetMapper<AlarmInfo> {\r
+public class AlarmInfoMapper implements RowMapper<AlarmInfo> {\r
     @Override\r
-    public AlarmInfo map(int i, ResultSet resultSet, StatementContext statementContext) throws SQLException {\r
+    public AlarmInfo map(ResultSet resultSet, StatementContext statementContext) throws SQLException {\r
         AlarmInfo alarmInfo = new AlarmInfo();\r
         alarmInfo.setAlarmIsCleared(resultSet.getInt("alarmiscleared"));\r
         alarmInfo.setRootFlag(resultSet.getInt("rootflag"));\r
index 9aa2e0b..837baed 100644 (file)
 
 package org.onap.holmes.common.utils;
 
-import org.jvnet.hk2.annotations.Service;
+
+import org.springframework.stereotype.Component;
 
 import java.util.regex.Pattern;
 
-@Service
+@Component
 public class CommonUtils {
 
     final static public String IP_REG = "(http(s)?://)?(\\d+\\.\\d+\\.\\d+\\.\\d+)(:(\\d+))?";
index a0fbd93..ed1c581 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2017 ZTE Corporation.
+ * Copyright 2017-2021 ZTE Corporation.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
 
 package org.onap.holmes.common.utils;
 
+import org.jdbi.v3.core.mapper.RowMapper;
+import org.jdbi.v3.core.statement.StatementContext;
+import org.onap.holmes.common.api.entity.CorrelationRule;
+
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.util.Properties;
-import org.onap.holmes.common.api.entity.CorrelationRule;
-import org.skife.jdbi.v2.StatementContext;
-import org.skife.jdbi.v2.tweak.ResultSetMapper;
 
-public class CorrelationRuleMapper implements ResultSetMapper<CorrelationRule> {
+public class CorrelationRuleMapper implements RowMapper<CorrelationRule> {
 
     @Override
-    public CorrelationRule map(int i, ResultSet resultSet, StatementContext statementContext) throws SQLException {
+    public CorrelationRule map(ResultSet resultSet, StatementContext statementContext) throws SQLException {
         CorrelationRule correlationRule = new CorrelationRule();
         correlationRule.setName(resultSet.getString("name"));
         correlationRule.setRid(resultSet.getString("rid"));
diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/utils/DbDaoUtil.java b/holmes-actions/src/main/java/org/onap/holmes/common/utils/DbDaoUtil.java
deleted file mode 100644 (file)
index 05792c5..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-/**\r
- * Copyright 2017-2020 ZTE Corporation.\r
- * <p>\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
- * <p>\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- * <p>\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
-package org.onap.holmes.common.utils;\r
-\r
-import io.dropwizard.db.DataSourceFactory;\r
-import io.dropwizard.jdbi.DBIFactory;\r
-import io.dropwizard.setup.Environment;\r
-import org.jvnet.hk2.annotations.Service;\r
-import org.skife.jdbi.v2.DBI;\r
-import org.skife.jdbi.v2.Handle;\r
-import org.slf4j.Logger;\r
-import org.slf4j.LoggerFactory;\r
-\r
-import javax.annotation.PostConstruct;\r
-import javax.inject.Inject;\r
-import javax.inject.Singleton;\r
-\r
-@Singleton\r
-@Service\r
-public class DbDaoUtil {\r
-\r
-    private Logger log = LoggerFactory.getLogger(DbDaoUtil.class);\r
-\r
-    private DBI jdbi;\r
-    @Inject\r
-    private Environment environmentProvider;\r
-    @Inject\r
-    private DataSourceFactory dataSourceFactoryProvider;\r
-\r
-    private DBIFactory factory = new DBIFactory();\r
-\r
-    @PostConstruct\r
-    public synchronized void init() {\r
-        if (jdbi == null) {\r
-            jdbi = factory.build(environmentProvider, dataSourceFactoryProvider, "postgres");\r
-        }\r
-    }\r
-\r
-    public <K> K getDao(Class<K> clazz) {\r
-        try {\r
-            return jdbi.open(clazz);\r
-        } catch (Exception e) {\r
-            log.warn("get object instance of Dao error.", e);\r
-        }\r
-        return null;\r
-    }\r
-\r
-    public Handle getHandle() {\r
-        try {\r
-            return jdbi.open();\r
-        } catch (Exception e) {\r
-            log.warn("get object instance of Dao error.", e);\r
-        }\r
-        return null;\r
-    }\r
-\r
-    public void close(Object obj) {\r
-        if (obj != null) {\r
-            try {\r
-                jdbi.close(obj);\r
-            } catch (Exception e) {\r
-                log.warn("close jdbi connection error.", e);\r
-            }\r
-        }\r
-    }\r
-\r
-    public <T> T getJdbiDaoByOnDemand(Class<T> daoClazz) {\r
-\r
-        return jdbi.onDemand(daoClazz);\r
-\r
-    }\r
-\r
-    public <T> T getJdbiDaoByOpen(Class<T> daoClazz) {\r
-\r
-        return jdbi.open(daoClazz);\r
-\r
-    }\r
-}\r
index cfb601a..d8b5215 100644 (file)
@@ -16,7 +16,6 @@
 
 package org.onap.holmes.common.utils;
 
-import org.onap.holmes.common.exception.HttpException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
index 33b53c7..957b818 100644 (file)
@@ -18,13 +18,13 @@ package org.onap.holmes.common.utils;
 
 import lombok.Setter;
 import org.apache.commons.lang3.StringUtils;
-import org.jvnet.hk2.annotations.Service;
 import org.onap.holmes.common.config.MicroServiceConfig;
 import org.onap.holmes.common.exception.CorrelationException;
 import org.onap.msb.sdk.discovery.entity.MicroServiceFullInfo;
 import org.onap.msb.sdk.discovery.entity.MicroServiceInfo;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
 
 import javax.ws.rs.client.Entity;
 import javax.ws.rs.core.MediaType;
diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/utils/RestExceptionHandler.java b/holmes-actions/src/main/java/org/onap/holmes/common/utils/RestExceptionHandler.java
new file mode 100644 (file)
index 0000000..f70cf68
--- /dev/null
@@ -0,0 +1,34 @@
+/**
+ * Copyright 2021 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.
+ * You may obtain a copy of the License at
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.holmes.common.utils;
+
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.ExceptionHandler;
+import org.springframework.web.bind.annotation.ResponseStatus;
+import org.springframework.web.bind.annotation.RestControllerAdvice;
+
+import javax.ws.rs.WebApplicationException;
+
+@RestControllerAdvice
+public class RestExceptionHandler {
+
+    @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
+    @ExceptionHandler(WebApplicationException.class)
+    public String handleWebApplicationException(WebApplicationException ex){
+        return ex.getResponse().getEntity().toString();
+    }
+}
diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/utils/SpringContextUtil.java b/holmes-actions/src/main/java/org/onap/holmes/common/utils/SpringContextUtil.java
new file mode 100644 (file)
index 0000000..b959c0a
--- /dev/null
@@ -0,0 +1,45 @@
+/**
+ * Copyright 2021 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.
+ * You may obtain a copy of the License at
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.holmes.common.utils;
+
+import org.springframework.beans.BeansException;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+import org.springframework.stereotype.Component;
+
+@Component
+public class SpringContextUtil implements ApplicationContextAware {
+
+    private static ApplicationContext applicationContext;
+
+    @Override
+    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
+        SpringContextUtil.applicationContext = applicationContext;
+    }
+
+    public static Object getBean(String name) {
+        return applicationContext.getBean(name);
+    }
+
+    public static <T> T getBean(Class<T> clazz) {
+        return applicationContext.getBean(clazz);
+    }
+
+    public static <T> T getBean(String name, Class<T> clazz) {
+        return applicationContext.getBean(name, clazz);
+    }
+}
index 9d42b91..725084a 100644 (file)
@@ -1,5 +1,5 @@
 /**
- * Copyright 2018 - 2021 ZTE Corporation.
+ * Copyright 2018-2021 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.
@@ -17,20 +17,22 @@ package org.onap.holmes.common.utils.transactionid;
 
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
-import org.jvnet.hk2.annotations.Service;
 import org.slf4j.MDC;
 import org.slf4j.Marker;
 import org.slf4j.MarkerFactory;
+import org.springframework.stereotype.Component;
 
 import javax.servlet.*;
+import javax.servlet.annotation.WebFilter;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
 import java.util.UUID;
 
 
-@Service
 @Slf4j
+@Component
+@WebFilter(urlPatterns = {"/*"})
 public class TransactionIdFilter implements Filter {
 
     public static final Marker INVOKE_SYNCHRONOUS;
diff --git a/holmes-actions/src/test/java/org/onap/holmes/common/api/entity/AlarmsCorrelationTest.java b/holmes-actions/src/test/java/org/onap/holmes/common/api/entity/AlarmsCorrelationTest.java
deleted file mode 100644 (file)
index 822d74c..0000000
+++ /dev/null
@@ -1,121 +0,0 @@
-/**
- * Copyright 2017 ZTE Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onap.holmes.common.api.entity;
-
-import static org.hamcrest.core.IsEqual.equalTo;
-import static org.junit.Assert.assertThat;
-
-import java.util.Date;
-import org.junit.Test;
-import org.junit.Before;
-import org.junit.After;
-
-public class AlarmsCorrelationTest {
-
-    private AlarmsCorrelation alarmsCorrelation;
-
-    @Before
-    public void before() throws Exception {
-        alarmsCorrelation = new AlarmsCorrelation();
-    }
-
-    @After
-    public void after() throws Exception {
-
-    }
-
-
-    @Test
-    public void getterAndSetter4RuleId() throws Exception {
-        final String ruleId = "ruleId";
-        alarmsCorrelation.setRuleId(ruleId);
-        assertThat(alarmsCorrelation.getRuleId(), equalTo(ruleId));
-    }
-
-
-    @Test
-    public void getterAndSetter4RuleInfo() throws Exception {
-        final String ruleInfo = "ruleInfo";
-        alarmsCorrelation.setRuleInfo(ruleInfo);
-        assertThat(alarmsCorrelation.getRuleInfo(), equalTo(ruleInfo));
-    }
-
-
-    @Test
-    public void getterAndSetter4ResultType() throws Exception {
-        final byte resultType = 1;
-        alarmsCorrelation.setResultType(resultType);
-        assertThat(alarmsCorrelation.getResultType(), equalTo(resultType));
-    }
-
-
-    @Test
-    public void getterAndSetter4CreateTime() throws Exception {
-        final Date createTime = new Date();
-        alarmsCorrelation.setCreateTime(createTime);
-        assertThat(alarmsCorrelation.getCreateTime(), equalTo(createTime));
-    }
-
-
-    @Test
-    public void getterAndSetter4ParentAlarmId() throws Exception {
-        final long pad = 11L;
-        alarmsCorrelation.setParentAlarmId(pad);
-        assertThat(alarmsCorrelation.getParentAlarmId(), equalTo(pad));
-    }
-
-
-    @Test
-    public void getterAndSetter4ChildAlarmId() throws Exception {
-        final long childAlarmId = 11L;
-        alarmsCorrelation.setChildAlarmId(childAlarmId);
-        assertThat(alarmsCorrelation.getChildAlarmId(), equalTo(childAlarmId));
-    }
-
-
-    @Test
-    public void getterAndSetter4Reserve1() throws Exception {
-        final long reserve1 = 11L;
-        alarmsCorrelation.setReserve1(reserve1);
-        assertThat(alarmsCorrelation.getReserve1(), equalTo(reserve1));
-    }
-
-
-    @Test
-    public void getterAndSetter4Reserve2() throws Exception {
-        final long reserve2 = 11L;
-        alarmsCorrelation.setReserve2(reserve2);
-        assertThat(alarmsCorrelation.getReserve2(), equalTo(reserve2));
-    }
-
-
-    @Test
-    public void getterAndSetter4Reserve3() throws Exception {
-        final long reserve3 = 11L;
-        alarmsCorrelation.setReserve3(reserve3);
-        assertThat(alarmsCorrelation.getReserve3(), equalTo(reserve3));
-    }
-
-    @Test
-    public void testToString() throws Exception {
-        final AlarmsCorrelation alarmsCorrelationTemp = new AlarmsCorrelation();
-        String ruleId = "ruleId";
-        alarmsCorrelationTemp.setRuleId(ruleId);
-        alarmsCorrelation.setRuleId(ruleId);
-        assertThat(alarmsCorrelation.toString(), equalTo(alarmsCorrelationTemp.toString()));
-    }
-}
diff --git a/holmes-actions/src/test/java/org/onap/holmes/common/config/MQConfigTest.java b/holmes-actions/src/test/java/org/onap/holmes/common/config/MQConfigTest.java
deleted file mode 100644 (file)
index cc9dced..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-/**
- * Copyright 2017 ZTE Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onap.holmes.common.config;
-
-import org.junit.Test;
-import org.junit.Before;
-import org.junit.After;
-
-public class MQConfigTest {
-    @Test
-    public void testNewClass() {
-        MQConfig mqConfig= new MQConfig();
-    }
-} 
diff --git a/holmes-actions/src/test/java/org/onap/holmes/common/dropwizard/ioc/bundle/AutoConfigBundleTest.java b/holmes-actions/src/test/java/org/onap/holmes/common/dropwizard/ioc/bundle/AutoConfigBundleTest.java
deleted file mode 100644 (file)
index 8cf044f..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright 2017-2020 ZTE Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onap.holmes.common.dropwizard.ioc.bundle;
-
-import io.dropwizard.Configuration;
-import io.dropwizard.setup.Environment;
-import org.junit.Test;
-
-import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.junit.Assert.assertThat;
-
-public class AutoConfigBundleTest {
-    @Test
-    public void newBuilder() {
-        assertThat(AutoConfigBundle.newBuilder(), instanceOf(AutoConfigBundleBuider.class));
-    }
-
-    @Test
-    public void run() throws Exception {
-        AutoConfigBundle.newBuilder().build().run(new Configuration(), new Environment("Test"));
-    }
-
-}
\ No newline at end of file
index 99b14ab..b201495 100644 (file)
@@ -44,7 +44,7 @@ public class EngineEntityMapperTest {
 
         PowerMock.replay(rsMock);
 
-        EngineEntity entity = mapper.map(0, rsMock, null);
+        EngineEntity entity = mapper.map( rsMock, null);
 
         PowerMock.verify(rsMock);
 
index 21a4025..cb16650 100644 (file)
 
 package org.onap.holmes.common.engine.service.impl;
 
-import com.google.common.base.CharMatcher;
-import org.junit.Before;
+import org.jdbi.v3.core.Jdbi;
 import org.junit.Test;
 import org.onap.holmes.common.engine.dao.EngineEntityDao;
 import org.onap.holmes.common.engine.entity.EngineEntity;
 import org.onap.holmes.common.engine.service.EngineEntityService;
-import org.onap.holmes.common.utils.DbDaoUtil;
+import org.onap.holmes.common.database.DbDaoUtil;
 
 import java.util.*;
 
-import static com.google.common.base.Predicates.notNull;
 import static org.hamcrest.core.Is.is;
 import static org.hamcrest.core.IsNull.notNullValue;
 import static org.junit.Assert.*;
 
 public class EngineEntityServiceImplTest {
-    private EngineEntityService service = new EngineEntityServiceImpl(new DbDaoUtilStub());
+    private EngineEntityService service = new EngineEntityServiceImpl(new DbDaoUtilStub(null));
 
     @Test
     public void getLegacyEngines() {
@@ -78,6 +76,10 @@ public class EngineEntityServiceImplTest {
 class DbDaoUtilStub extends DbDaoUtil {
     private EngineEntityDao dao = new EngineEntityDaoStub();
 
+    public DbDaoUtilStub(Jdbi jdbi) {
+        super(jdbi);
+    }
+
     @Override
     public <T> T getJdbiDaoByOnDemand(Class<T> daoClazz) {
 
index 3d36def..9ea0057 100644 (file)
@@ -1,12 +1,12 @@
 /**\r
  * Copyright 2017 ZTE Corporation.\r
- *\r
+ * <p>\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
+ * <p>\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * <p>\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
@@ -33,13 +33,13 @@ public class AlarmInfoMapperTest {
         expect(resultSet.getString("eventname")).andReturn("");\r
         expect(resultSet.getString("sourceid")).andReturn("");\r
         expect(resultSet.getString("sourcename")).andReturn("");\r
-       expect(resultSet.getInt("sequence")).andReturn(0);\r
+        expect(resultSet.getInt("sequence")).andReturn(0);\r
         expect(resultSet.getLong("startepochmicrosec")).andReturn(0L);\r
         expect(resultSet.getLong("lastepochmicrosec")).andReturn(0L);\r
         expect(resultSet.getInt("alarmiscleared")).andReturn(0);\r
         expect(resultSet.getInt("rootflag")).andReturn(0);\r
         PowerMock.replay(resultSet);\r
-        mapper.map(0, resultSet, null);\r
+        mapper.map(resultSet, null);\r
         PowerMock.verify(resultSet);\r
     }\r
 }\r
index c18c828..9ea92ca 100644 (file)
@@ -49,7 +49,7 @@ public class CorrelationRuleMapperTest {
         expect(resultSet.getString("ctrlloop")).andReturn("");
         expect(resultSet.getString("engineinstance")).andReturn("");
         PowerMock.replay(resultSet);
-        mapper.map(0, resultSet, null);
+        mapper.map(resultSet, null);
         PowerMock.verify(resultSet);
     }
 }
\ No newline at end of file
index dd42044..696de45 100644 (file)
 
 package org.onap.holmes.common.utils;
 
-import io.dropwizard.db.DataSourceFactory;
-import io.dropwizard.jdbi.DBIFactory;
-import io.dropwizard.setup.Environment;
-import org.easymock.EasyMock;
-import org.junit.Before;
-import org.junit.Ignore;
+import org.jdbi.v3.core.Jdbi;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
 import org.junit.runner.RunWith;
+import org.onap.holmes.common.database.DbDaoUtil;
 import org.powermock.api.easymock.PowerMock;
-import org.powermock.core.classloader.annotations.PrepareForTest;
 import org.powermock.modules.junit4.PowerMockRunner;
-import org.powermock.reflect.Whitebox;
-import org.skife.jdbi.v2.DBI;
-import org.skife.jdbi.v2.Handle;
 
 import static org.easymock.EasyMock.anyObject;
 import static org.easymock.EasyMock.expect;
-import static org.hamcrest.core.IsEqual.equalTo;
-import static org.junit.Assert.assertThat;
 
 @RunWith(PowerMockRunner.class)
-@PrepareForTest({DbDaoUtil.class, DBIFactory.class, DBI.class})
 public class DbDaoUtilTest {
 
     @Rule
     public ExpectedException thrown = ExpectedException.none();
 
-    private DBI jdbi;
-
-    private Environment environmentProvider;
-
-    private DataSourceFactory dataSourceFactoryProvider;
-
-    private DbDaoUtil dbDaoUtil;
-
-    private DBIFactory factory;
-
-    @Before
-    public void before() throws Exception {
-        dbDaoUtil = new DbDaoUtil();
-
-        jdbi = PowerMock.createMock(DBI.class);
-        environmentProvider = PowerMock.createMock(Environment.class);
-        dataSourceFactoryProvider = PowerMock.createMock(DataSourceFactory.class);
-        factory = PowerMock.createMock(DBIFactory.class);
-        PowerMock.expectNew(DBIFactory.class).andReturn(factory);
-
-        Whitebox.setInternalState(dbDaoUtil, "environmentProvider", environmentProvider);
-        Whitebox.setInternalState(dbDaoUtil, "dataSourceFactoryProvider",
-                dataSourceFactoryProvider);
-
-        PowerMock.resetAll();
-    }
-
-    @Test
-    @Ignore
-    public void init() {
-        PowerMock.createMock(DBI.class);
-
-        expect(factory.build(anyObject(Environment.class), anyObject(DataSourceFactory.class),
-                anyObject(String.class))).andReturn(jdbi);
-
-        PowerMock.replayAll();
-
-        dbDaoUtil.init();
-
-        PowerMock.verifyAll();
-    }
-
-    @Test
-    public void getDao_normal() {
-        Whitebox.setInternalState(dbDaoUtil, "jdbi", jdbi);
-        expect(jdbi.open(anyObject(Class.class))).andReturn(Class.class);
-
-        PowerMock.replayAll();
-
-        dbDaoUtil.getDao(String.class);
-
-        PowerMock.verifyAll();
-    }
-
-    @Test
-    public void getDao_exception() {
-        Whitebox.setInternalState(dbDaoUtil, "jdbi", jdbi);
-
-        expect(jdbi.open(anyObject(Class.class))).andThrow(new RuntimeException(""));
-
-        PowerMock.replayAll();
-
-        Object o = dbDaoUtil.getDao(String.class);
-
-        PowerMock.verifyAll();
-
-        assertThat(o, equalTo(null));
-    }
-
-    @Test
-    public void getHandle_normal() {
-        Handle handle = PowerMock.createMock(Handle.class);
-
-        Whitebox.setInternalState(dbDaoUtil, "jdbi", jdbi);
-        expect(jdbi.open()).andReturn(handle);
-
-        PowerMock.replayAll();
-
-        dbDaoUtil.getHandle();
-
-        PowerMock.verifyAll();
-    }
-
-    @Test
-    public void getHandle_exception() {
-        Handle handle = PowerMock.createMock(Handle.class);
-
-        Whitebox.setInternalState(dbDaoUtil, "jdbi", jdbi);
-        expect(jdbi.open()).andThrow(new RuntimeException(""));
-
-        PowerMock.replayAll();
-
-        Handle handle1 = dbDaoUtil.getHandle();
-
-        PowerMock.verifyAll();
-
-        assertThat(handle1, equalTo(null));
-    }
-
-    @Test
-    public void close_normal() {
-        Whitebox.setInternalState(dbDaoUtil, "jdbi", jdbi);
-        jdbi.close(anyObject());
-
-        PowerMock.replayAll();
-
-        dbDaoUtil.close(new Object());
-
-        PowerMock.verifyAll();
-    }
-
-    @Test
-    public void close_exception() {
-        Whitebox.setInternalState(dbDaoUtil, "jdbi", jdbi);
-        jdbi.close(anyObject());
-        EasyMock.expectLastCall().andThrow(new RuntimeException(""));
-        PowerMock.replayAll();
-
-        dbDaoUtil.close(new Object());
-
-        PowerMock.verifyAll();
-    }
 
     @Test
     public void testGetJdbiDaoByOnDemand() {
-        Whitebox.setInternalState(dbDaoUtil, "jdbi", jdbi);
+            Jdbi jdbi = PowerMock.createMock(Jdbi.class);
+            DbDaoUtil dbDaoUtil = new DbDaoUtil(jdbi);
         expect(jdbi.onDemand(anyObject(Class.class))).andReturn(Class.class);
 
         PowerMock.replayAll();
@@ -180,15 +48,4 @@ public class DbDaoUtilTest {
         PowerMock.verifyAll();
     }
 
-    @Test
-    public void testGetJdbiDaoByOpen() {
-        Whitebox.setInternalState(dbDaoUtil, "jdbi", jdbi);
-        expect(jdbi.open(anyObject(Class.class))).andReturn(Class.class);
-
-        PowerMock.replayAll();
-
-        dbDaoUtil.getJdbiDaoByOpen(String.class);
-
-        PowerMock.verifyAll();
-    }
 }
diff --git a/pom.xml b/pom.xml
index 0c7021b..d933a5e 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -37,6 +37,9 @@
         <bundle.name>${project.artifactId}-${project.version}</bundle.name>\r
 \r
         <powermock.version>2.0.7</powermock.version>\r
+        <springboot.version>2.7.2</springboot.version>\r
+        <spring-framework.version>5.3.13</spring-framework.version>\r
+        <jdbi.version>3.19.0</jdbi.version>\r
 \r
         <dropwizard.version>2.0.9</dropwizard.version>\r
         <swagger.version>1.6.4</swagger.version>\r
 \r
     <dependencyManagement>\r
         <dependencies>\r
+            <dependency>\r
+                <groupId>org.springframework.boot</groupId>\r
+                <artifactId>spring-boot-dependencies</artifactId>\r
+                <version>${springboot.version}</version>\r
+                <type>pom</type>\r
+                <scope>import</scope>\r
+            </dependency>\r
+            <dependency>\r
+                <groupId>org.springframework</groupId>\r
+                <artifactId>spring-jdbc</artifactId>\r
+                <version>${spring-framework.version}</version>\r
+            </dependency>\r
+            <dependency>\r
+                <groupId>org.springframework</groupId>\r
+                <artifactId>spring-web</artifactId>\r
+                <version>${spring-framework.version}</version>\r
+            </dependency>\r
+            <dependency>\r
+                <groupId>org.jdbi</groupId>\r
+                <artifactId>jdbi3-postgres</artifactId>\r
+                <version>${jdbi.version}</version>\r
+            </dependency>\r
+            <dependency>\r
+                <groupId>org.jdbi</groupId>\r
+                <artifactId>jdbi3-sqlobject</artifactId>\r
+                <version>${jdbi.version}</version>\r
+            </dependency>\r
+            <dependency>\r
+                <groupId>org.jdbi</groupId>\r
+                <artifactId>jdbi3-spring4</artifactId>\r
+                <version>${jdbi.version}</version>\r
+            </dependency>\r
+            <dependency>\r
+                <groupId>javax.servlet</groupId>\r
+                <artifactId>javax.servlet-api</artifactId>\r
+                <version>4.0.1</version>\r
+            </dependency>\r
+            <dependency>\r
+                <groupId>org.postgresql</groupId>\r
+                <artifactId>postgresql</artifactId>\r
+                <version>42.2.13</version>\r
+                <scope>provided</scope>\r
+            </dependency>\r
             <dependency>\r
                 <groupId>ch.qos.logback</groupId>\r
                 <artifactId>logback-classic</artifactId>\r
                 <artifactId>jersey-client</artifactId>\r
                 <version>${jersey.version}</version>\r
             </dependency>\r
-            <dependency>\r
-                <groupId>io.dropwizard</groupId>\r
-                <artifactId>dropwizard-core</artifactId>\r
-                <version>${dropwizard.version}</version>\r
-                <scope>provided</scope>\r
-            </dependency>\r
-            <dependency>\r
-                <groupId>io.dropwizard</groupId>\r
-                <artifactId>dropwizard-db</artifactId>\r
-                <version>${dropwizard.version}</version>\r
-                <scope>provided</scope>\r
-            </dependency>\r
-            <dependency>\r
-                <groupId>io.dropwizard</groupId>\r
-                <artifactId>dropwizard-jdbi</artifactId>\r
-                <version>2.0.0-rc9</version>\r
-            </dependency>\r
             <dependency>\r
                 <groupId>io.swagger</groupId>\r
                 <artifactId>swagger-jersey2-jaxrs</artifactId>\r