문서의 선택한 두 판 사이의 차이를 보여줍니다.
| 양쪽 이전 판 이전 판 다음 판 | 이전 판 | ||
|
springframework:bean [2015/11/17 13:56] kwon37xi [Dynamic Bean Definition - 동적 Bean 생성] |
springframework:bean [2021/11/12 13:05] (현재) kwon37xi |
||
|---|---|---|---|
| 줄 1: | 줄 1: | ||
| ====== SpringFramework Bean ====== | ====== SpringFramework Bean ====== | ||
| - | | + | |
| + | ===== Springframework Bean Life Cycle ===== | ||
| + | * [[springframework: | ||
| + | * [[http:// | ||
| + | |||
| + | ==== BeanPostProcessor ==== | ||
| + | * [[http:// | ||
| + | * Spring Bean의 생성 전후에 Bean에 대한 초기화 작업을 수행할 수 있다. | ||
| + | * BeanPostProcessor는 빈(또는 객체) 인스턴스상에서 동작한다. 즉, 스프링 IoC 컨테이너는 빈 인스턴스를 인스턴스화한 다음에 BeanPostProcessor가 자신의 일을 수행한다. | ||
| + | * [[http:// | ||
| + | |||
| + | ==== BeanFactoryPostProcessor ==== | ||
| + | * [[http:// | ||
| + | * Bean의 정의 자체를 바꿀 수 있다. '' | ||
| + | | ||
| ===== Dynamic Bean Definition - 동적 Bean 생성 ===== | ===== Dynamic Bean Definition - 동적 Bean 생성 ===== | ||
| - | * [[http://blog.jdriven.com/2015/ | + | * [[http://www.tutorialspoint.com/ |
| - | * [[https:// | + | |
| + | ==== 구현 ==== | ||
| * [[http:// | * [[http:// | ||
| @Override | @Override | ||
| public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) | public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) | ||
| - | throws BeansException { | + | |
| - | RootBeanDefinition beanDefinition = | + | |
| - | new RootBeanDefinition(MyServiceImpl.class); | + | new RootBeanDefinition(MyServiceImpl.class); |
| - | serviceDefinition.setTargetType(MyService.class); | + | serviceDefinition.setTargetType(MyService.class); |
| - | serviceDefinition.setRole(BeanDefinition.ROLE_APPLICATION); | + | serviceDefinition.setRole(BeanDefinition.ROLE_APPLICATION); |
| - | registry.registerBeanDefinition(" | + | registry.registerBeanDefinition(" |
| } | } | ||
| // 혹은 다음과 같은 스타일 | // 혹은 다음과 같은 스타일 | ||
| 줄 28: | 줄 43: | ||
| } | } | ||
| </ | </ | ||
| - | * 해당 구현체 자체를 '' | + | |
| - | * 혹은 | + | * '' |
| + | |||
| + | ==== 설정에 등록 ==== | ||
| + | | ||
| + | * [[http:// | ||
| + | |||
| + | |||
| + | |||
| + | ==== 참조 ==== | ||
| + | * [[http:// | ||
| + | * [[https:// | ||