Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class PetService {
- private final Provider<PetDao> dao;
- public PetService(PetDao dao) {
- this.dao = dao;
- }
- public int numberOfPets(String name) {
- return dao.get().getNumberOfPets();
- }
- }
- @Configuration
- class PetServiceConfiguration {
- @Bean
- @Scope(BeanDefinition.SCOPE_PROTOTYPE)
- PetDao petDao() {
- if("true".equals(System.getProperty("useV1PetDao"))) {
- return new PetDaoV1();
- } else {
- return new PetDaoV2();
- }
- }
- @Bean
- PetService petService(Provider<PetDao> provider) {
- return new PetService(provider);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement