Roy Golan has uploaded a new change for review.
Change subject: core: Introduce postConstruct for commands
......................................................................
core: Introduce postConstruct for commands
Replace the need to call DbFacade or other interaction with the command
dependencies during the constructor which is both not recommended for
perfomance, and very bad for testing frameworks.
It is ensured (by CommandFactory) that all the command injected
dependencies are already in place.
so instead of:
public DoThisCommand(P p) {
DbFacade.getInstance().getVmDao...
}
we would:
@Override
private postConstruct() {
dbFacade.getVmDao...
}
Change-Id: Ic0686c430b5151eb227eefb49096a27161d87723
Signed-off-by: Roy Golan <[email protected]>
---
M
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommandBase.java
1 file changed, 11 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/99/37599/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 02fcb90..9f53280 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
@@ -12,6 +12,7 @@
import java.util.Map.Entry;
import java.util.Set;
+import javax.annotation.PostConstruct;
import javax.ejb.TransactionRolledbackLocalException;
import javax.enterprise.inject.Instance;
import javax.inject.Inject;
@@ -219,6 +220,16 @@
this.commandId = commandId;
}
+ /**
+ * Implement this method whenever you need extra initialization of the
command after the
+ * constructor. All DB calls or other interaction with the command
dependencies for initialization
+ * should be done here. It is ensured that all injected dependencies
should be injected at the time calling.
+ *
+ * @see PostConstruct
+ */
+ @PostConstruct
+ abstract void postConstruct();
+
protected List<SPMAsyncTaskHandler> initTaskHandlers() {
return null;
}
--
To view, visit http://gerrit.ovirt.org/37599
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic0686c430b5151eb227eefb49096a27161d87723
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Roy Golan <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches