Martin Mucha has uploaded a new change for review.

Change subject: core: do not instantiate singleton class
......................................................................

core: do not instantiate singleton class

- removed instantiation of class which is singleton and should not be
instantiated, and should be injected if needed, and which field was
unsused

- removed other unused stuff

Longer description using lines' length under 72 chars.

With multiple paragraphs if necessary.

Change-Id: Id142e03724cf83e10aa631e2785632610d7cecc9
Bug-Url: https://bugzilla.redhat.com/??????
Signed-off-by: Martin Mucha <[email protected]>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommandsFactory.java
1 file changed, 4 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/13/30513/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommandsFactory.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommandsFactory.java
index 94b0b71..c34a0c2 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommandsFactory.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommandsFactory.java
@@ -20,7 +20,6 @@
 import org.ovirt.engine.core.utils.log.LogFactory;
 
 public final class CommandsFactory {
-    private static final Injector injector = new Injector();
     private static final String CLASS_NAME_FORMAT = "%1$s.%2$s%3$s";
     private static final String CommandSuffix = "Command";
     private static final String QueryPrefix = "Query";
@@ -46,7 +45,7 @@
             "org.ovirt.engine.core.bll.scheduling.queries" };
 
     private static ConcurrentMap<String, Class<CommandBase<? extends 
VdcActionParametersBase>>> commandsCache =
-            new ConcurrentHashMap<String, Class<CommandBase<? extends 
VdcActionParametersBase>>>(VdcActionType.values().length);
+            new ConcurrentHashMap<>(VdcActionType.values().length);
 
     @SuppressWarnings("unchecked")
     public static <P extends VdcActionParametersBase> CommandBase<P> 
createCommand(VdcActionType action, P parameters) {
@@ -56,7 +55,7 @@
     @SuppressWarnings("unchecked")
     public static <P extends VdcActionParametersBase> CommandBase<P> 
createCommand(VdcActionType action, P parameters, CommandContext 
commandContext) {
         try {
-            CommandBase<P> result = null;
+            CommandBase<P> result;
             if (commandContext == null) {
                 result = 
(CommandBase<P>)findCommandConstructor(getCommandClass(action.name(), 
CommandSuffix), parameters.getClass()).newInstance(parameters);
             } else {
@@ -98,7 +97,7 @@
                 isAcessible = constructor.isAccessible();
                 constructor.setAccessible(true);
             }
-            CommandBase<?> cmd = (CommandBase<?>) constructor.newInstance(new 
Object[]{commandId});
+            CommandBase<?> cmd = (CommandBase<?>) 
constructor.newInstance(commandId);
             Injector.injectMembers(cmd);
             return cmd;
         } catch (Exception e) {
@@ -117,7 +116,7 @@
         Class<?> type = null;
         try {
             type = getCommandClass(query.name(), QueryPrefix);
-            QueriesCommandBase<?> result = null;
+            QueriesCommandBase<?> result;
             if (engineContext == null) {
                 result =
                         (QueriesCommandBase<?>) findCommandConstructor(type, 
parameters.getClass()).newInstance(parameters);


-- 
To view, visit http://gerrit.ovirt.org/30513
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id142e03724cf83e10aa631e2785632610d7cecc9
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Martin Mucha <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to