[ https://issues.apache.org/jira/browse/OFBIZ-6783?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15275559#comment-15275559 ] Taher Alkhateeb commented on OFBIZ-6783: ---------------------------------------- I have been working non-stop for over a week trying to refactor Start.java. The code is absolutely disgusting with amazingly dumb design decisions! First, the StartupLoader constructor takes an argument "String[] args", which means that args that are passed to main, are just propagated down to every single container in the system, and every single container would have to parse the args, remove dashes, and process them!! Oh my god, this is absolutely sh$##y So I'm trying to replace the args with commons-cli, and I trace down what breaks, and EVERYTHING breaks. Here is my investigation so far: - Start.init(...) breaks, so I have to refactor that - Config breaks as it handles args, so I have to refactor that - The loaderArgs list in Start.java is actually copied the values from args, which is then passed to the ContainerLoader in the line loader.load(config, argsArray) - the ContainerLoader has this terrible piece of code inside a loop: {code} Container tmpContainer = loadContainer(containerCfg, args); {code} - That crap code eventually calls this code also inside the "loadContainer" method: {code}containerObj.init(args, containerCfg.name, configFile);{code} - Finally, every single container in the system (16 listed below) gets a copy of the raw unprocessed args - Of the 16 containers, four containers actually use the args as follows: -- EntityDataLoadContainer -- TestListContainer -- TestRunContainer -- XuiContainer - All system containers: - BeanShellContainer.java - ComponentContainer.java - JustLoadComponentsContainer.java - NamingServiceContainer.java - DelegatorContainer.java - GeronimoContainer.java - JavaMailContainer.java - ServiceContainer.java - RmiServiceContainer.java - EntityDataLoadContainer.java - CatalinaContainer.java - TestListContainer.java - TestRunContainer.java - BirtContainer.java - XuiContainer.java - JposDeviceContainer.java So to fix all the above we must apply the following: - Change the signature of the containers not to include args - Pass the args in a different format _after_ processing - Fix everything everywhere > 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 > > > 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) |
Free forum by Nabble | Edit this page |