diff options
author | 6092002067 <wu.youbo@zte.com.cn> | 2017-02-18 14:38:29 +0800 |
---|---|---|
committer | 6092002067 <wu.youbo@zte.com.cn> | 2017-02-18 14:38:29 +0800 |
commit | 2882d700cc2a21c581b7fb1299b8bd8ecbd2635f (patch) | |
tree | 1ad16d02be0c6d0866f7663d4a14757466bca0d8 /holmes-actions | |
parent | 415aaeb592bf4645705bece01bc570cb3a398fd9 (diff) |
Fix DbDaoUtil.java code
Issue-ID:HOLMES-9
Change-Id: Ibc5f4fbefe98d651a977eb27def7983fe98bfdd7
Signed-off-by: youbowu <wu.youbo@zte.com.cn>
Diffstat (limited to 'holmes-actions')
-rw-r--r-- | holmes-actions/src/main/java/org/openo/holmes/common/utils/DbDaoUtil.java | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/holmes-actions/src/main/java/org/openo/holmes/common/utils/DbDaoUtil.java b/holmes-actions/src/main/java/org/openo/holmes/common/utils/DbDaoUtil.java index fcd90aa..b45fb4a 100644 --- a/holmes-actions/src/main/java/org/openo/holmes/common/utils/DbDaoUtil.java +++ b/holmes-actions/src/main/java/org/openo/holmes/common/utils/DbDaoUtil.java @@ -18,10 +18,10 @@ package org.openo.holmes.common.utils; import io.dropwizard.db.DataSourceFactory;
import io.dropwizard.jdbi.DBIFactory;
import io.dropwizard.setup.Environment;
+import javax.annotation.PostConstruct;
import javax.inject.Inject;
import javax.inject.Singleton;
import lombok.extern.slf4j.Slf4j;
-import org.glassfish.hk2.api.IterableProvider;
import org.jvnet.hk2.annotations.Service;
import org.skife.jdbi.v2.DBI;
import org.skife.jdbi.v2.Handle;
@@ -32,20 +32,19 @@ import org.skife.jdbi.v2.Handle; public class DbDaoUtil {
private static DBI jdbi;
-
@Inject
- private static IterableProvider<Environment> environmentProvider;
-
+ private Environment environmentProvider;
@Inject
- private static IterableProvider<DataSourceFactory> dataSourceFactoryProvider;
+ private DataSourceFactory dataSourceFactoryProvider;
- static {
+ @PostConstruct
+ public void init() {
if (jdbi == null) {
synchronized (DbDaoUtil.class) {
if (jdbi == null) {
final DBIFactory factory = new DBIFactory();
jdbi = factory
- .build(environmentProvider.get(), dataSourceFactoryProvider.get(), "mysql");
+ .build(environmentProvider, dataSourceFactoryProvider, "mysql");
}
}
}
|