Advertisement
Guest User

Untitled

a guest
Aug 17th, 2019
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. @Configuration
  2. class PetServiceConfiguration {
  3. @Bean(BeanIdentifiers.PET_DAO_V1)
  4. PetDao petDao() {
  5. return new PetDaoV1();
  6. }
  7.  
  8. @Bean(BeanIdentifiers.PET_DAO_V2)
  9. PetDao petDao() {
  10. return new PetDaoV2();
  11. }
  12.  
  13. @Bean
  14. PetService petService(@Qualifier(BeanIdentifiers.PET_DAO_V1) PetDao petDaoV1,
  15. @Qualifier(BeanIdentifiers.PET_DAO_V1) PetDao petDaoV2) {
  16. if("true".equals(System.getProperty("useV1PetDao"))) {
  17. return new PetService(petDaoV1);
  18. } else {
  19. return new PetService(petDaoV2);
  20. }
  21. }
  22. }
  23.  
  24. static class BeanIdentifiers {
  25. static final String PET_DAO_V1 = "petDaoV1";
  26. static final String PET_DAO_V1 = "petDaoV2";
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement