Roy Golan has uploaded a new change for review.

Change subject: core: Inject instead of expensive JNDI lookups
......................................................................

core: Inject instead of expensive JNDI lookups

Inject BackendCommandObjectsHandler instead of continuously fetch it
using jndi lookup

Change-Id: Ie1efa3a0cefa2f2ece6cd0c5aa4f8be8dd07055f
Signed-off-by: Roy Golan <rgo...@redhat.com>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommandBase.java
1 file changed, 11 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/95/35495/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 d3a76ac..03ce2fa 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
@@ -13,6 +13,8 @@
 import java.util.Set;
 
 import javax.ejb.TransactionRolledbackLocalException;
+import javax.enterprise.inject.Instance;
+import javax.inject.Inject;
 import javax.transaction.Status;
 import javax.transaction.SystemException;
 import javax.transaction.Transaction;
@@ -24,6 +26,7 @@
 import org.ovirt.engine.core.bll.context.DefaultCompensationContext;
 import org.ovirt.engine.core.bll.context.EngineContext;
 import org.ovirt.engine.core.bll.context.NoOpCompensationContext;
+import org.ovirt.engine.core.bll.interfaces.BackendCommandObjectsHandler;
 import org.ovirt.engine.core.bll.interfaces.BackendInternal;
 import org.ovirt.engine.core.bll.job.ExecutionContext;
 import org.ovirt.engine.core.bll.job.ExecutionHandler;
@@ -40,7 +43,6 @@
 import org.ovirt.engine.core.bll.tasks.interfaces.Command;
 import org.ovirt.engine.core.bll.tasks.interfaces.CommandCallBack;
 import org.ovirt.engine.core.bll.tasks.interfaces.SPMTask;
-import org.ovirt.engine.core.bll.utils.BackendUtils;
 import org.ovirt.engine.core.bll.utils.PermissionSubject;
 import org.ovirt.engine.core.common.AuditLogType;
 import org.ovirt.engine.core.common.VdcObjectType;
@@ -89,10 +91,10 @@
 import org.ovirt.engine.core.dao.GenericDao;
 import org.ovirt.engine.core.dao.StatusAwareDao;
 import org.ovirt.engine.core.dao.VdsSpmIdMapDAO;
+import org.ovirt.engine.core.utils.CorrelationIdTracker;
 import org.ovirt.engine.core.utils.Deserializer;
 import org.ovirt.engine.core.utils.ReflectionUtils;
 import org.ovirt.engine.core.utils.SerializationFactory;
-import org.ovirt.engine.core.utils.CorrelationIdTracker;
 import org.ovirt.engine.core.utils.lock.EngineLock;
 import org.ovirt.engine.core.utils.lock.LockManager;
 import org.ovirt.engine.core.utils.lock.LockManagerFactory;
@@ -105,6 +107,10 @@
 
 public abstract class CommandBase<T extends VdcActionParametersBase> extends 
AuditLogableBase implements
         RollbackHandler, TransactionMethod<Object>, Command<T> {
+
+    // lazy instance injection as an instance isn't needed most of the time
+    @Inject
+    private Instance<BackendCommandObjectsHandler> 
commandObjectsHandlerProvider;
 
     /* Multiplier used to convert GB to bytes or vice versa. */
     protected static final long BYTES_IN_GB = 1024 * 1024 * 1024;
@@ -153,7 +159,7 @@
 
     protected VdcReturnValueBase executeChildCommand(Guid idInCommandsMap) {
         CommandBase<?> command = childCommandsMap.get(idInCommandsMap);
-        return 
BackendUtils.getBackendCommandObjectsHandler(log).runAction(command, 
getExecutionContext());
+        return commandObjectsHandlerProvider.get().runAction(command, 
getExecutionContext());
     }
 
 
@@ -1376,7 +1382,8 @@
                         buildChildCommandInfos();
                         for (Map.Entry<Guid, Pair<VdcActionType, 
VdcActionParametersBase>> entry : childCommandInfoMap.entrySet()) {
                             CommandBase<?> command =
-                                    
BackendUtils.getBackendCommandObjectsHandler(log).createAction(entry.getValue().getFirst(),
+                                    
commandObjectsHandlerProvider.get().createAction(entry.getValue()
+                                                    .getFirst(),
                                             entry.getValue().getSecond(),
                                             context);
                             log.info("Command '{}' persisting async task 
placeholder for child command '{}'",


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie1efa3a0cefa2f2ece6cd0c5aa4f8be8dd07055f
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

Reply via email to