I am developing a series of webservices (based on spring and spring mvc).For the first time in my dev career I do plan on replacing the dao layer in the future(I have always seen it mentioned but never had to do it).Currently I'm using spring annotations, so I could simply change the qualifier name of the injected dao in each place it is used; is there a better (global) mechanism I could use ? Currently my code looks like this (declaring the dao) :@Repository(regionDao)public class RegionDao implements IRegionDaoand Injecting it :@Resource(name = regionDao)IRegionDao regionDao;But going into each service class and changing the qualifier name seems rather long winded, is their a better way. Basically in the future I want to flip a switch and each reference to a regionDao will then point to newRegionDao and so on for other dao's.A solution using annotations is preferred- for no other reason than I subjectively prefer them. But I realize this may be a case for xml based config ?
Replacing dao layer
java;design;spring;dao
You can add a layer of indirection by using property placeholders for class names:< bean id=regionDao class=${com.wibble.newRegionDao} >And then configuring DAOs class names in the property files.I agree with other posters that this is possibly overkill to do this for a task you'll do as rarely as changing your persistence back end.  [This technique is possibly more useful in integration testing scenarios by the way - where you for instance want to run tests against one data store or messaging provider and run in production against another.]http://static.springsource.org/spring/docs/1.1.5/api/org/springframework/beans/factory/config/PropertyPlaceholderConfigurer.html