SHARE
TWEET

Untitled

a guest Aug 17th, 2019 47 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top