Roy Golan has uploaded a new change for review. Change subject: core: Inject Config instance to CommandBase ......................................................................
core: Inject Config instance to CommandBase As part of the dependency injection into Commands class it is now available at CommandBase. The Config class was made a singleton so it could be fetched by the CDI container. In the future this class should loose all its static characteristics and it would be injected all over the engine. Change-Id: I42517ed27b29bc91ffe5062ada651a1d5eb07bed Signed-off-by: Roy Golan <rgo...@redhat.com> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommandBase.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/utils/BllCDIAdapter.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/config/Config.java 3 files changed, 36 insertions(+), 0 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/13/17613/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommandBase.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommandBase.java index 41ce066..d018ab7 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommandBase.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommandBase.java @@ -134,6 +134,9 @@ @Inject protected DbFacade dbFacade; + @Inject + protected Config config; + /** The context defines how to monitor the command and handle its compensation */ private final CommandContext context = new CommandContext(); diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/utils/BllCDIAdapter.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/utils/BllCDIAdapter.java index 2b9d3d4..12142d3 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/utils/BllCDIAdapter.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/utils/BllCDIAdapter.java @@ -3,6 +3,7 @@ import javax.enterprise.inject.Produces; import javax.enterprise.inject.spi.InjectionPoint; +import org.ovirt.engine.core.common.config.Config; import org.ovirt.engine.core.dal.dbbroker.DbFacade; import org.ovirt.engine.core.utils.log.Log; import org.ovirt.engine.core.utils.log.LogFactory; @@ -23,6 +24,9 @@ public class BllCDIAdapter { @Produces + Config config = Config.getInstance(); + + @Produces DbFacade dbFacade = DbFacade.getInstance(); diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/config/Config.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/config/Config.java index 0fc5fc2..bf6d113 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/config/Config.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/config/Config.java @@ -1,10 +1,16 @@ package org.ovirt.engine.core.common.config; + /** * Config Class */ public final class Config { private static IConfigUtilsInterface _configUtils; + + private static Config instance = new Config(); + + private Config() { + } public static IConfigUtilsInterface getConfigUtils() { return _configUtils; @@ -44,4 +50,27 @@ Config.<String> GetValue(ConfigValues.AttestationTruststore)); } + /** + * TODO This method was added in order for other modules to be able to inject a Config instance. Once this limitation + * is removed this class should loose its static methods.<br> + * Note: the object is not ready for use till it has the setConfigUtils method + * fired. As part of the future change the class will be made mutable by moving the setConfigUtils to the constructor + * so th object is ready for use immediately + * i.e + * <code> public Config(IConfigUtilsInterface configUtils) { ... set the internal config utils } </code> + * + * + * @return + */ + public static Config getInstance() { + return instance; + } + + public <T> T getValue(ConfigValues value) { + return Config.<T>GetValue(value); + } + + public <T> T getValue(ConfigValues value, String version) { + return Config.<T>GetValue(value, version); + } } -- To view, visit http://gerrit.ovirt.org/17613 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I42517ed27b29bc91ffe5062ada651a1d5eb07bed Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Roy Golan <rgo...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches