diff options
author | Guangrong Fu <fu.guangrong@zte.com.cn> | 2017-02-18 06:48:49 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@open-o.org> | 2017-02-18 06:48:49 +0000 |
commit | bbe89f96cde1faad401ec1a697c0c4b17d04bc18 (patch) | |
tree | ee84c2f09ee49c742b5ea1afb353fda7672842f0 /holmes-actions/src/main | |
parent | 516c3ba3c8768e4f8861aa5626d0077a3ea1b94b (diff) | |
parent | 2882d700cc2a21c581b7fb1299b8bd8ecbd2635f (diff) |
Merge "Fix DbDaoUtil.java code"
Diffstat (limited to 'holmes-actions/src/main')
-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");
}
}
}
|