This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I'm quite new to Spring.
While working on my application I found a part of the xml file that I think can be done better.
I'm using two xml files:
the first one (context.xml):
and the second (widokiContext.xml):
As you can see the beans "liniaWidok", "polaczenieWidok" and "przystanekWidok" have a reference to a bean "fileDataReader". You can also put a "dbDataReader" bean as a reference there. The problem is that always, when I need to change the reference in all 3 beans, I have to make a change in 3 places.
I'm guessing that there is a better way to achieve that, probably making a change only in a single line, but I can't figure out how.
I would be very thankful if someone could help me.
(Oh, and sorry if my english isn't too good. I didn't have the opportunity to use it for a long time).
Ok. It seems I found a solution: I added the bean "appController" and now this bean has a reference to "fileDataReader" or "dbDataReader". So the "liniaWidok", "przystanekWidok" and "polaczenieWidok" beans will have a reference to "appController" instead of "fileDataReader" or "dbDataReader". And when I need to change the dataReader I simply change it only in one place - the "appController".
Here are the files including this solution:
context.xml stays the same:
This problem look quite silly now when I managed to solve it
But if anyone has a different idea please, let me know.