</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
         <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
 
  * ============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.
 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) {
 
 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;
 @Slf4j
 public class AaiQuery {
 
-    @Inject
+    @Autowired
     private AaiResponseUtil aaiResponseUtil;
 
     public VnfEntity getAaiVnfData(String vnfId, String vnfName) throws CorrelationException {
 
  * ============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.
 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;
 
 import static org.onap.holmes.common.aai.AaiJsonParserUtil.*;
 
-@Service
 @Slf4j
+@Service
 public class AaiQuery4Ccvpn2 {
 
     private Map<String, Object> headers;
 
 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;
 
 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;
 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;
 
 /**
- * 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 {
 
     public static final CorrelationUtil getInstance() {
         if (aaiQuery == null) {
-            aaiQuery = ServiceLocatorHolder.getLocator().getService(AaiQuery.class);
+            aaiQuery = SpringContextUtil.getBean(AaiQuery.class);
         }
         return LazyHolder.INSTANCE;
     }
 
+++ /dev/null
-/**\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
 
--- /dev/null
+/**
+ * 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);
+    }
+}
 
+++ /dev/null
-/**\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
 
 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
 \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
 
--- /dev/null
+/**
+ * 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;
+//    }
+}
 
--- /dev/null
+/**\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
 
  */
 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;
 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;
     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;
     }
 
 \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
 
 /*
- * 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);
 
 /*
- * 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> {
 
 
+++ /dev/null
-/**
- * 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 {
-
-}
 
+++ /dev/null
-/**
- * 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 {
-
-}
 
+++ /dev/null
-/**
- * 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 {
-
-}
 
+++ /dev/null
-/**
- * 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 {
-
-}
 
+++ /dev/null
-/**
- * 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 {
-
-}
 
+++ /dev/null
-/**
- * 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 {
-
-}
 
+++ /dev/null
-/**
- * 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);
-                    }
-                });
-    }
-}
 
+++ /dev/null
-/**
- * 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);
-    }
-}
 
+++ /dev/null
-/**
- * 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 {
-
-  }
-}
 
+++ /dev/null
-/**
- * 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();
-       }
-
-}
 
+++ /dev/null
-/**
- * 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);
-                       }
-                       
-                       
-               }
-       }
-}
 
+++ /dev/null
-/**
- * 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;
-       }
-       
-}
 
 /**
- * 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);
 
 /**
- * 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
 
 /**
- * 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();
 
 
 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
 
     private EngineEntityDao engineEntityDao;
 
-    @Inject
+    @Autowired
     public EngineEntityServiceImpl(DbDaoUtil dbDaoUtil){
         engineEntityDao = dbDaoUtil.getJdbiDaoByOnDemand(EngineEntityDao.class);
     }
 
 /**\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
 
 
 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+))?";
 
 /*
- * 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"));
 
+++ /dev/null
-/**\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
 
 
 package org.onap.holmes.common.utils;
 
-import org.onap.holmes.common.exception.HttpException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 
 
 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;
 
--- /dev/null
+/**
+ * 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();
+    }
+}
 
--- /dev/null
+/**
+ * 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);
+    }
+}
 
 /**
- * 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.
 
 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;
 
+++ /dev/null
-/**
- * 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()));
-    }
-}
 
+++ /dev/null
-/**
- * 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();
-    }
-} 
 
+++ /dev/null
-/*
- * 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
 
 
         PowerMock.replay(rsMock);
 
-        EngineEntity entity = mapper.map(0, rsMock, null);
+        EngineEntity entity = mapper.map( rsMock, null);
 
         PowerMock.verify(rsMock);
 
 
 
 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() {
 class DbDaoUtilStub extends DbDaoUtil {
     private EngineEntityDao dao = new EngineEntityDaoStub();
 
+    public DbDaoUtilStub(Jdbi jdbi) {
+        super(jdbi);
+    }
+
     @Override
     public <T> T getJdbiDaoByOnDemand(Class<T> daoClazz) {
 
 
 /**\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
         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
 
         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
 
 
 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();
         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();
-    }
 }
 
         <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