`
leon.s.kennedy
  • 浏览: 107495 次
  • 性别: Icon_minigender_2
  • 来自: 北京
社区版块
存档分类
最新评论

IOC Annotation_Pre_Post_Scope

 
阅读更多

 

1.     @Scope 对应XML的bean scope 默认singleton

@Scope("prototype") @Component("movieFinderImpl ") public class MovieFinderImpl implements MovieFinder { // ... }

2.     @PostConstruct = init-method; @PreDestroy = destroy-method;

PostConstruct 在构造之后执行方法

public class CachingMovieLister { @PostConstruct public void populateMovieCache() { // populates the movie cache upon initialization... } @PreDestroy public void clearMovieCache() { // clears the movie cache upon destruction... } }
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics