Inherited a big jumbled, messy, old java application. Currently the app overview is like this:
-some Struts 2 that we added but, 75% old legacy stupidly written java that is total spaghetti and almost non-existent OO design implementation. (Don't even have a 'user' object for example)
-running on Tomcat 6 which handles the connection pooling
*upon login, the user selects the database out of a dropdown. his datasource, based upon user selection, is then passed around in every method signature all the way back to the DAO where it is then used. Don't even ask *why?*, let's just say...it's the government
All the designs I have previously worked on never had any kind of selectable database/datasource requirement like this. So, I'm looking for some design input on how this could be refactored in a more efficient/elegent way.
Let me know if more detail is needed. I appreciate in advance, everyone's time.
You could have init method that will set data source to every services that require data source.
When user login just call the init method.
SCJA 1.0, SCJP 1.4, SCWCD 1.4, SCBCD 1.3, SCJP 5.0, SCEA 5, SCBCD 5; OCUP - Fundamental, Intermediate and Advanced; IBM Certified Solution Designer - OOAD, vUML 2; SpringSource Certified Spring Professional
Joined: Aug 18, 2009
thanks for the reply. Could you explain this a little more?
"set data source to every services that require data source".
It's just a ton of classes that have the need for the datasource. So, how do you get the datasource from the login (or init method, as you mentioned, to the back end dao's (and other legacy classes that hit the db)?