[jira] [Updated] (OFBIZ-6783) Refactor start.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[jira] [Updated] (OFBIZ-6783) Refactor start.java

Nicolas Malin (Jira)

     [ https://issues.apache.org/jira/browse/OFBIZ-6783?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Taher Alkhateeb updated OFBIZ-6783:
-----------------------------------
    Attachment: OFBIZ-6783.patch

After a lot of work, I finally have a working patch that passes all tests and runs ant commands correctly.

This is a big patch that does the following:
- adds the commons-cli to the classpath
- fixes the start component build.xml to include commons-cli
- change the formatting of all commands in java -jar ofbiz.jar to be unified in the way they are used
- provide much better printing when doing java -jar ofbiz.jar --help
- fix the main build.xml to follow the new syntax
- replace the raw args that are passed everywhere in the ofbiz with a more specialized StartupCommand.java object. This completely decouples the processing of arguments from ofbiz
- also, hide all commons-cli operation in a class called StartupCommandUtil. This keeps ofbiz decoupled from commons-cli.
- Unify the exception model as much as possible to be based on the StartupException
- simplify Start.main and Start.init
- Because args propagate everywhere, I had to create an adapter method called populateLoaderArgs that builds args as expected by the containers. This allows us to change the ofbiz arguments without breaking the system

To test this patch:
- apply the patch
- download and copy the commons-cli jar to framework/start/lib/commons-cli-1.3.1.jar. You can find it in http://www-us.apache.org/dist//commons/cli/binaries/commons-cli-1.3.1-bin.zip
- ./ant clean-all load-demo run-tests

All the tests work, however, a lot of testing is needed on almost all the build.xml targets to ensure that processing is done correctly. Also, testing all kinds of scenarios on java -jar ofbiz.jar

> Refactor start.java
> -------------------
>
>                 Key: OFBIZ-6783
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-6783
>             Project: OFBiz
>          Issue Type: Improvement
>          Components: framework
>    Affects Versions: Upcoming Branch
>            Reporter: Taher Alkhateeb
>            Assignee: Taher Alkhateeb
>              Labels: framework, main, refactoring, start
>         Attachments: OFBIZ-6783.patch, OFBIZ-6783.patch, OFBIZ-6783.patch, StartCommandUtil.java
>
>
> Looking at the main method and design of Start.java looks ugly. The things I would like to fix so far are:
> - the file is too long
> - some variables are not even needed (loaderArgs?)
> - the level of abstraction is wrong
> - main throws an exception!
> - the arguments processing logic is terrible, need to move it to commons-cli
> It's just so messy and ugly to look at. So for me refactoring starts at Start! Given that this is an important file, I will provide a patch to be reviewed by the community before committing just to be on the safe side.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)