Rj Ewing wrote:How would you go about running a method via the cmd line from code designed to be run in a servlet?
Paul Clapham wrote:
But to move to Spring you would probably have to break your application into little pieces, modify them, and incorporate the result into Spring. Small modifications of your existing code over time could also produce something workable, but in either case there's a lot to learn. The advantage of Spring is that it tells you what architectural principles are useful and then implements them on your behalf.
Rj Ewing wrote:
Junilu, quick question in regards to your recommendation for moving to Spring.
The 2nd database is only for storing the actual datasets. We currently are using a triple store (apache fuseki). However the 2nd mysql db is because a client didn't want to use the triple store implementation and prefered mysql for storing the datasets.
Does that make any difference in your recommendation?
Junilu Lacar wrote:Above all, refactor in small steps and try to have tests before you refactor anything -- that's your safety net. Refactoring large sections of code all at once is very dangerous and can create more problems on top of the ones you already have.
Rj Ewing wrote:
Do you have any suggestions on how I would go about testing this class before refactoring? There's db calls directly alongside logic methods like login? I think I would like to create a User entity as well as a UserDAO. Then in login, I could get call UserDAO.findByUsername("user").getHashedPass(). I think that will make things much more testable as I can mock User and UserDAO. So how do I create tests before the refactor?
Also, do you have any tips to start integrating spring? Our app is currently a jersey servlet. I was thinking that I would start integrating spring with any new development and refactoring.
Rj Ewing wrote:Then in login, I could get call UserDAO.findByUsername("user").getHashedPass()
Rj Ewing wrote:
I believe I need to declare the MySqlUploader as an attribute w @Autowire whenever I want to use it, otherwise DI wouldn't work, correct?
Junilu Lacar wrote:
Doing it that way makes it necessary to change the file for every variation. You want to parameterize/tokenize that so the XML is stable. Put the value that can change in a properties file. In your config, you'd have the property name as a placeholder token that gets replaced with the value read from the properties file. You can also do that via annotations. No time right now to give you an example but you should be able to find more info with Google.
Junilu Lacar wrote:Don't do that. Once you relinquish lifecycle management of a class to Spring, it's best not to mess with calling new on it. Add a method and call that instead.
Politics is a circus designed to distract you from what is really going on. So is this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
|