Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Configuration
- class PetServiceConfiguration {
- @Bean(BeanIdentifiers.PET_DAO_V1)
- PetDao petDao() {
- return new PetDaoV1();
- }
- @Bean(BeanIdentifiers.PET_DAO_V2)
- PetDao petDao() {
- return new PetDaoV2();
- }
- @Bean
- PetService petService(@Qualifier(BeanIdentifiers.PET_DAO_V1) PetDao petDaoV1,
- @Qualifier(BeanIdentifiers.PET_DAO_V1) PetDao petDaoV2) {
- if("true".equals(System.getProperty("useV1PetDao"))) {
- return new PetService(petDaoV1);
- } else {
- return new PetService(petDaoV2);
- }
- }
- }
- static class BeanIdentifiers {
- static final String PET_DAO_V1 = "petDaoV1";
- static final String PET_DAO_V1 = "petDaoV2";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement