Switched from Dropwizard to Springboot
[holmes/common.git] / holmes-actions / src / main / java / org / onap / holmes / common / utils / DbDaoUtil.java
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