Contributing/Coding guidelines (was: svn commit: r1834662 - /ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ConfigXMLReader.java)
Hello Jacques, Jacques Le Roux writes: > OK I reviewed those they sounds good to me, here are my remarks > > I did not know about XXX tag > http://www.outpost9.com/reference/jargon/jargon_21.html#TAG637 funny I learned it from my fellow GNU hackers. ;-) > private static final long serialVersionUID = -8765719278480440687L; > In OFBiz we don't set serialVersionUID but let the system handles that for us > and rather use @SuppressWarnings("serial") where necessary. > More at https://markmail.org/message/jjhf5p5hbhon7vam and above. I'll > try to write a word about that in our coding conventions or elsewhere? I agree this should go in OFBiz coding conventions. Maybe this goes beyond your question but it would be great if the contributing/coding guidelines was included in the OFBiz developer manual instead of the Wiki. > Not a big deal but I saw you often (automatically?) format length lines to 80 > or so > - private final String defaultStatusCodeString = > UtilProperties.getPropertyValue("requestHandler", "status-code", "302"); > + private final static String defaultStatusCodeString = > + UtilProperties.getPropertyValue("requestHandler", > "status-code", "302"); > We have commonly decided to use a length of lines 120, see > https://cwiki.apache.org/confluence/display/OFBIZ/Coding+Conventions > https://svn.apache.org/repos/asf/ofbiz/tools/wiki-files/OFBizJavaFormatter.xml OK I will adjust my code. Maybe the line length of 120 could be explicitly stated as an exception to the Sun standard [1]? Thanks. [1] http://www.oracle.com/technetwork/java/javase/documentation/codeconventions-136091.html#313 -- Mathieu Lirzin GPG: F2A3 8D7E EB2B 6640 5761 070D 0ADE E100 9460 4D37
Re: svn commit: r1834662 - /ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ConfigXMLReader.java
Hi Mathieu, All, OK I reviewed those they sounds good to me, here are my remarks I did not know about XXX tag http://www.outpost9.com/reference/jargon/jargon_21.html#TAG637 funny private static final long serialVersionUID = -8765719278480440687L; In OFBiz we don't set serialVersionUID but let the system handles that for us and rather use @SuppressWarnings("serial") where necessary. More at https://markmail.org/message/jjhf5p5hbhon7vam and above. I'll try to write a word about that in our coding conventions or elsewhere? (please suggest) Not a big deal but I saw you often (automatically?) format length lines to 80 or so - private final String defaultStatusCodeString = UtilProperties.getPropertyValue("requestHandler", "status-code", "302"); + private final static String defaultStatusCodeString = + UtilProperties.getPropertyValue("requestHandler", "status-code", "302"); We have commonly decided to use a length of lines 120, see https://cwiki.apache.org/confluence/display/OFBIZ/Coding+Conventions https://svn.apache.org/repos/asf/ofbiz/tools/wiki-files/OFBizJavaFormatter.xml And thank you Jinghai for the comment about the service method <> It tortured me too reviewing :D. Good to know that you are already using Mathieu code. Let's document it now in this ML after the revert. To commit it again later... Jacques Le 29/06/2018 à 17:26, Jacques Le Roux a écrit : I'm currently reviewing http://svn.apache.org/viewvc?view=revision=1834389 http://svn.apache.org/viewvc?view=revision=1834465 I'll get back to this later, but I'm surprised that it would be an issue, it's just simple and fast to review... unlike above... Jacques Le 29/06/2018 à 16:11, Taher Alkhateeb a écrit : I refactored many parts of the framework. I might have done more refactoring than anyone recently. However, I never just pushed a commit. I always ask for feedback, I make a patch and I consistently ask for people's feedback, some of that feedback came directly from you Jacques. So for you to call it just refactoring as if this makes it a benign this is surprising to me. I would join Michael in recommending that you revert and start a proper discussion. On Jun 29, 2018 1:29 PM, "Jacques Le Roux" wrote: Michael It's not a change just a refactorization. I thought it was simple enough to be committed. If we go this way for simple and small changes like here things will be quite slow I also answered in the Jira since you also asked the same there Jacques Le 29/06/2018 à 12:21, Michael Brohl a écrit : Jacques, didn't we just agreed upon a slower process and review from more committers when changing these core aspects of the framework? Especially when you change the patch there is no chance for anyone to review before it gets committed {#emotions_dlg.sad} Michael Am 29.06.18 um 12:03 schrieb jler...@apache.org: Author: jleroux Date: Fri Jun 29 10:03:22 2018 New Revision: 1834662 URL: http://svn.apache.org/viewvc?rev=1834662=rev Log: Improved: Factorize code logic from ‘ConfigXMLReader’ (OFBIZ-10453) There is a lot of repetitive code in ConfigXMLReader. Using a functional interface as a parameter of a generic algorithm avoids those repetitions. Thanks: Mathieu Lirzin Modified: ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ConfigXMLReader.java Modified: ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ConfigXMLReader.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ConfigXMLReader.java?rev=1834662=1834661=1834662=diff == --- ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ConfigXMLReader.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ConfigXMLReader.java Fri Jun 29 10:03:22 2018 @@ -32,6 +32,7 @@ import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Set; +import java.util.function.Function; import java.util.stream.Collectors; import javax.servlet.ServletContext; @@ -218,120 +219,67 @@ public class ConfigXMLReader { } } - public Map getAfterLoginEventList() throws WebAppConfigurationException { - MapContext result = MapContext.getMapContext(); - for (URL includeLocation : includes) { - ControllerConfig controllerConfig = getControllerConfig(includeLocation); - result.push(controllerConfig.getAfterLoginEventList()); + private Map pushIncludes(Function> f) throws WebAppConfigurationException { + MapContext res = MapContext.getMapContext(); + for (URL include : includes) { + res.push(getControllerConfig(include).pushIncludes(f)); + } +
Re: svn commit: r1834662 - /ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ConfigXMLReader.java
I'm currently reviewing http://svn.apache.org/viewvc?view=revision=1834389 http://svn.apache.org/viewvc?view=revision=1834465 I'll get back to this later, but I'm surprised that it would be an issue, it's just simple and fast to review... unlike above... Jacques Le 29/06/2018 à 16:11, Taher Alkhateeb a écrit : I refactored many parts of the framework. I might have done more refactoring than anyone recently. However, I never just pushed a commit. I always ask for feedback, I make a patch and I consistently ask for people's feedback, some of that feedback came directly from you Jacques. So for you to call it just refactoring as if this makes it a benign this is surprising to me. I would join Michael in recommending that you revert and start a proper discussion. On Jun 29, 2018 1:29 PM, "Jacques Le Roux" wrote: Michael It's not a change just a refactorization. I thought it was simple enough to be committed. If we go this way for simple and small changes like here things will be quite slow I also answered in the Jira since you also asked the same there Jacques Le 29/06/2018 à 12:21, Michael Brohl a écrit : Jacques, didn't we just agreed upon a slower process and review from more committers when changing these core aspects of the framework? Especially when you change the patch there is no chance for anyone to review before it gets committed {#emotions_dlg.sad} Michael Am 29.06.18 um 12:03 schrieb jler...@apache.org: Author: jleroux Date: Fri Jun 29 10:03:22 2018 New Revision: 1834662 URL: http://svn.apache.org/viewvc?rev=1834662=rev Log: Improved: Factorize code logic from ‘ConfigXMLReader’ (OFBIZ-10453) There is a lot of repetitive code in ConfigXMLReader. Using a functional interface as a parameter of a generic algorithm avoids those repetitions. Thanks: Mathieu Lirzin Modified: ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ConfigXMLReader.java Modified: ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ConfigXMLReader.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ConfigXMLReader.java?rev=1834662=1834661=1834662=diff == --- ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ConfigXMLReader.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ConfigXMLReader.java Fri Jun 29 10:03:22 2018 @@ -32,6 +32,7 @@ import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Set; +import java.util.function.Function; import java.util.stream.Collectors; import javax.servlet.ServletContext; @@ -218,120 +219,67 @@ public class ConfigXMLReader { } } -public Map getAfterLoginEventList() throws WebAppConfigurationException { -MapContext result = MapContext.getMapContext(); -for (URL includeLocation : includes) { -ControllerConfig controllerConfig = getControllerConfig(includeLocation); - result.push(controllerConfig.getAfterLoginEventList()); +private Map pushIncludes(Function> f) throws WebAppConfigurationException { +MapContext res = MapContext.getMapContext(); +for (URL include : includes) { + res.push(getControllerConfig(include).pushIncludes(f)); +} +res.push(f.apply(this)); +return res; +} + +private String getIncludes(Function f) throws WebAppConfigurationException { +String val = f.apply(this); +if (val != null) { +return val; +} +for (URL include : includes) { +String inc = getControllerConfig(include).getIncludes(f); +if (inc != null) { +return inc; +} } -result.push(afterLoginEventList); -return result; +return null; +} + +public Map getAfterLoginEventList() throws WebAppConfigurationException { +return pushIncludes(ccfg -> ccfg.afterLoginEventList); } public Map getBeforeLogoutEventList() throws WebAppConfigurationException { -MapContext result = MapContext.getMapContext(); -for (URL includeLocation : includes) { -ControllerConfig controllerConfig = getControllerConfig(includeLocation); - result.push(controllerConfig.getBeforeLogoutEventList()); -} -result.push(beforeLogoutEventList); -return result; +return pushIncludes(ccfg -> ccfg.beforeLogoutEventList); } public String getDefaultRequest() throws WebAppConfigurationException { -if (defaultRequest !=
Re: svn commit: r1834662 - /ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ConfigXMLReader.java
I refactored many parts of the framework. I might have done more refactoring than anyone recently. However, I never just pushed a commit. I always ask for feedback, I make a patch and I consistently ask for people's feedback, some of that feedback came directly from you Jacques. So for you to call it just refactoring as if this makes it a benign this is surprising to me. I would join Michael in recommending that you revert and start a proper discussion. On Jun 29, 2018 1:29 PM, "Jacques Le Roux" wrote: Michael It's not a change just a refactorization. I thought it was simple enough to be committed. If we go this way for simple and small changes like here things will be quite slow I also answered in the Jira since you also asked the same there Jacques Le 29/06/2018 à 12:21, Michael Brohl a écrit : > Jacques, > > didn't we just agreed upon a slower process and review from more committers when changing these core aspects of the framework? > > Especially when you change the patch there is no chance for anyone to review before it gets committed {#emotions_dlg.sad} > > Michael > > Am 29.06.18 um 12:03 schrieb jler...@apache.org: >> Author: jleroux >> Date: Fri Jun 29 10:03:22 2018 >> New Revision: 1834662 >> >> URL: http://svn.apache.org/viewvc?rev=1834662=rev >> Log: >> Improved: Factorize code logic from ‘ConfigXMLReader’ >> (OFBIZ-10453) >> >> There is a lot of repetitive code in ConfigXMLReader. >> Using a functional interface as a parameter of a generic algorithm avoids those >> repetitions. >> >> Thanks: Mathieu Lirzin >> >> Modified: >> ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ConfigXMLReader.java >> >> Modified: ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ConfigXMLReader.java >> URL: >> http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ConfigXMLReader.java?rev=1834662=1834661=1834662=diff >> == >> --- ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ConfigXMLReader.java (original) >> +++ ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ConfigXMLReader.java Fri Jun 29 10:03:22 2018 >> @@ -32,6 +32,7 @@ import java.util.List; >> import java.util.Map; >> import java.util.Objects; >> import java.util.Set; >> +import java.util.function.Function; >> import java.util.stream.Collectors; >> import javax.servlet.ServletContext; >> @@ -218,120 +219,67 @@ public class ConfigXMLReader { >> } >> } >> -public Map getAfterLoginEventList() throws WebAppConfigurationException { >> -MapContext result = MapContext.getMapContext(); >> -for (URL includeLocation : includes) { >> -ControllerConfig controllerConfig = getControllerConfig(includeLocation); >> - result.push(controllerConfig.getAfterLoginEventList()); >> +private Map pushIncludes(Function> f) throws WebAppConfigurationException { >> +MapContext res = MapContext.getMapContext(); >> +for (URL include : includes) { >> + res.push(getControllerConfig(include).pushIncludes(f)); >> +} >> +res.push(f.apply(this)); >> +return res; >> +} >> + >> +private String getIncludes(Function f) throws WebAppConfigurationException { >> +String val = f.apply(this); >> +if (val != null) { >> +return val; >> +} >> +for (URL include : includes) { >> +String inc = getControllerConfig(include).getIncludes(f); >> +if (inc != null) { >> +return inc; >> +} >> } >> -result.push(afterLoginEventList); >> -return result; >> +return null; >> +} >> + >> +public Map getAfterLoginEventList() throws WebAppConfigurationException { >> +return pushIncludes(ccfg -> ccfg.afterLoginEventList); >> } >> public Map getBeforeLogoutEventList() throws WebAppConfigurationException { >> -MapContext result = MapContext.getMapContext(); >> -for (URL includeLocation : includes) { >> -ControllerConfig controllerConfig = getControllerConfig(includeLocation); >> - result.push(controllerConfig.getBeforeLogoutEventList()); >> -} >> -result.push(beforeLogoutEventList); >> -return result; >> +return pushIncludes(ccfg -> ccfg.beforeLogoutEventList); >> } >> public String getDefaultRequest() throws WebAppConfigurationException { >> -if (defaultRequest != null) { >> -return defaultRequest; >> -} >> -for (URL includeLocation : includes) { >> -
Re: svn commit: r1834662 - /ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ConfigXMLReader.java
Michael It's not a change just a refactorization. I thought it was simple enough to be committed. If we go this way for simple and small changes like here things will be quite slow I also answered in the Jira since you also asked the same there Jacques Le 29/06/2018 à 12:21, Michael Brohl a écrit : Jacques, didn't we just agreed upon a slower process and review from more committers when changing these core aspects of the framework? Especially when you change the patch there is no chance for anyone to review before it gets committed {#emotions_dlg.sad} Michael Am 29.06.18 um 12:03 schrieb jler...@apache.org: Author: jleroux Date: Fri Jun 29 10:03:22 2018 New Revision: 1834662 URL: http://svn.apache.org/viewvc?rev=1834662=rev Log: Improved: Factorize code logic from ‘ConfigXMLReader’ (OFBIZ-10453) There is a lot of repetitive code in ConfigXMLReader. Using a functional interface as a parameter of a generic algorithm avoids those repetitions. Thanks: Mathieu Lirzin Modified: ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ConfigXMLReader.java Modified: ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ConfigXMLReader.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ConfigXMLReader.java?rev=1834662=1834661=1834662=diff == --- ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ConfigXMLReader.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ConfigXMLReader.java Fri Jun 29 10:03:22 2018 @@ -32,6 +32,7 @@ import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Set; +import java.util.function.Function; import java.util.stream.Collectors; import javax.servlet.ServletContext; @@ -218,120 +219,67 @@ public class ConfigXMLReader { } } - public Map getAfterLoginEventList() throws WebAppConfigurationException { - MapContext result = MapContext.getMapContext(); - for (URL includeLocation : includes) { - ControllerConfig controllerConfig = getControllerConfig(includeLocation); - result.push(controllerConfig.getAfterLoginEventList()); + private Map pushIncludes(Function> f) throws WebAppConfigurationException { + MapContext res = MapContext.getMapContext(); + for (URL include : includes) { + res.push(getControllerConfig(include).pushIncludes(f)); + } + res.push(f.apply(this)); + return res; + } + + private String getIncludes(Function f) throws WebAppConfigurationException { + String val = f.apply(this); + if (val != null) { + return val; + } + for (URL include : includes) { + String inc = getControllerConfig(include).getIncludes(f); + if (inc != null) { + return inc; + } } - result.push(afterLoginEventList); - return result; + return null; + } + + public Map getAfterLoginEventList() throws WebAppConfigurationException { + return pushIncludes(ccfg -> ccfg.afterLoginEventList); } public Map getBeforeLogoutEventList() throws WebAppConfigurationException { - MapContext result = MapContext.getMapContext(); - for (URL includeLocation : includes) { - ControllerConfig controllerConfig = getControllerConfig(includeLocation); - result.push(controllerConfig.getBeforeLogoutEventList()); - } - result.push(beforeLogoutEventList); - return result; + return pushIncludes(ccfg -> ccfg.beforeLogoutEventList); } public String getDefaultRequest() throws WebAppConfigurationException { - if (defaultRequest != null) { - return defaultRequest; - } - for (URL includeLocation : includes) { - ControllerConfig controllerConfig = getControllerConfig(includeLocation); - String defaultRequest = controllerConfig.getDefaultRequest(); - if (defaultRequest != null) { - return defaultRequest; - } - } - return null; + return getIncludes(ccfg -> ccfg.defaultRequest); } public String getErrorpage() throws WebAppConfigurationException { - if (errorpage != null) { - return errorpage; - } - for (URL includeLocation : includes) { - ControllerConfig controllerConfig = getControllerConfig(includeLocation); - String errorpage =
Re: svn commit: r1834662 - /ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ConfigXMLReader.java
Jacques, didn't we just agreed upon a slower process and review from more committers when changing these core aspects of the framework? Especially when you change the patch there is no chance for anyone to review before it gets committed {#emotions_dlg.sad} Michael Am 29.06.18 um 12:03 schrieb jler...@apache.org: Author: jleroux Date: Fri Jun 29 10:03:22 2018 New Revision: 1834662 URL: http://svn.apache.org/viewvc?rev=1834662=rev Log: Improved: Factorize code logic from ‘ConfigXMLReader’ (OFBIZ-10453) There is a lot of repetitive code in ConfigXMLReader. Using a functional interface as a parameter of a generic algorithm avoids those repetitions. Thanks: Mathieu Lirzin Modified: ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ConfigXMLReader.java Modified: ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ConfigXMLReader.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ConfigXMLReader.java?rev=1834662=1834661=1834662=diff == --- ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ConfigXMLReader.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ConfigXMLReader.java Fri Jun 29 10:03:22 2018 @@ -32,6 +32,7 @@ import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Set; +import java.util.function.Function; import java.util.stream.Collectors; import javax.servlet.ServletContext; @@ -218,120 +219,67 @@ public class ConfigXMLReader { } } -public Map getAfterLoginEventList() throws WebAppConfigurationException { -MapContext result = MapContext.getMapContext(); -for (URL includeLocation : includes) { -ControllerConfig controllerConfig = getControllerConfig(includeLocation); -result.push(controllerConfig.getAfterLoginEventList()); +private Map pushIncludes(Function> f) throws WebAppConfigurationException { +MapContext res = MapContext.getMapContext(); +for (URL include : includes) { +res.push(getControllerConfig(include).pushIncludes(f)); +} +res.push(f.apply(this)); +return res; +} + +private String getIncludes(Function f) throws WebAppConfigurationException { +String val = f.apply(this); +if (val != null) { +return val; +} +for (URL include : includes) { +String inc = getControllerConfig(include).getIncludes(f); +if (inc != null) { +return inc; +} } -result.push(afterLoginEventList); -return result; +return null; +} + +public Map getAfterLoginEventList() throws WebAppConfigurationException { +return pushIncludes(ccfg -> ccfg.afterLoginEventList); } public Map getBeforeLogoutEventList() throws WebAppConfigurationException { -MapContext result = MapContext.getMapContext(); -for (URL includeLocation : includes) { -ControllerConfig controllerConfig = getControllerConfig(includeLocation); -result.push(controllerConfig.getBeforeLogoutEventList()); -} -result.push(beforeLogoutEventList); -return result; +return pushIncludes(ccfg -> ccfg.beforeLogoutEventList); } public String getDefaultRequest() throws WebAppConfigurationException { -if (defaultRequest != null) { -return defaultRequest; -} -for (URL includeLocation : includes) { -ControllerConfig controllerConfig = getControllerConfig(includeLocation); -String defaultRequest = controllerConfig.getDefaultRequest(); -if (defaultRequest != null) { -return defaultRequest; -} -} -return null; +return getIncludes(ccfg -> ccfg.defaultRequest); } public String getErrorpage() throws WebAppConfigurationException { -if (errorpage != null) { -return errorpage; -} -for (URL includeLocation : includes) { -ControllerConfig controllerConfig = getControllerConfig(includeLocation); -String errorpage = controllerConfig.getErrorpage(); -if (errorpage != null) { -return errorpage; -} -} -return null; +return getIncludes(ccfg -> ccfg.errorpage); }