Arik Hadas has posted comments on this change. Change subject: engine: Added init method to command base. ......................................................................
Patch Set 2: (2 comments) http://gerrit.ovirt.org/#/c/37110/2/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommandBase.java File backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommandBase.java: Line 1057: addCanDoActionMessage(VdcBllMessages.FAILED_TO_INITIALIZE); Line 1058: return false; Line 1059: } Line 1060: return true; Line 1061: } a typical initialization in the constructor looks like that: BlaBlaCommand(Parameters p) { super(p); if (get<something> != null) { init1; init2; ... } } IIUC, the init method should extract the initialization part from the constructor right? if so, I think that since people tend to forget to add null-checks etc (look at http://gerrit.ovirt.org/#/c/36882/ where I fixed it for hibernate), this method should look like: private boolean init<...>() { try { init(); } catch (Exception e) { /* not interesting, will be handled by can-do-action*/ } } there's no point to return true/false since if there's a problem to initialize it, something with the parameters or the environment is wrong and can-do-action should report it Line 1062: Line 1063: /** Line 1064: * This method should be inherited by subclasses that would like to perform initialization after permission check Line 1065: * Line 1064: * This method should be inherited by subclasses that would like to perform initialization after permission check Line 1065: * Line 1066: * @return Line 1067: */ Line 1068: protected boolean initImpl() { it's better to call the method that will be implemented inside the commands 'init' and call the method above 'invokeInit' or somthing like that Line 1069: return true; Line 1070: } Line 1071: Line 1072: protected boolean checkPermissions(final List<PermissionSubject> permSubjects) { -- To view, visit http://gerrit.ovirt.org/37110 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I0c71548a8fab5538ee97c279f12a821999635950 Gerrit-PatchSet: 2 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Yair Zaslavsky <[email protected]> Gerrit-Reviewer: Arik Hadas <[email protected]> Gerrit-Reviewer: Oved Ourfali <[email protected]> Gerrit-Reviewer: Ravi Nori <[email protected]> Gerrit-Reviewer: [email protected] Gerrit-Reviewer: oVirt Jenkins CI Server Gerrit-HasComments: Yes _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
