Announcement Announcement Module
Collapse
No announcement yet.
Howto inject Annotation-based Service to a Map Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Howto inject Annotation-based Service to a Map

    i want the annotation-based Service created and be put to a map.

    let's take it for example:
    Code:
    @Service
    public class SimpleMovieLister {
    
        private MovieFinder movieFinder;
    
        @Autowired
        public SimpleMovieLister(MovieFinder movieFinder) {
            this.movieFinder = movieFinder;
        }
    }
    @Repository
    public class JpaMovieFinder implements MovieFinder {
        // implementation elided for clarity
    }
    However, i don't want the implemention that like this.

    Code:
    @Service
    public class SimpleMovieLister implements InitializingBean{
    
        private Map<?, ?> map = null;
        //....
    
        @Override
        public void afterPropertiesSet() throws Exception {
            // TODO Auto-generated method stub
             map.put(getServiceName(), this);
        }
    }
    Is there any interface in spring to let me add the code after annotation-based bean be created.

    give me some advice, thx
Working...
X