InitializingBean 인터페이스
빈 객체의 라이프 사이클과 관련된 인터페이스 중에서 가장 많이 사용되는 것 중의 하나가
  org.springframework.beans.factory.InitializingBean 인터페이다.
  
  객체를 생성하고 프로퍼티를 초기화 하고, 컨테이너관련 설정을 완료한 뒤에 호출되는 메서드를 정의하고 있다.
  
  public interface InitializingBean {
    public void afterPropertiesSet() throws Exception
  }
  
  afterPropertiesSet() 메서드는 주로 빈 객체의 프로퍼티가 모두 올바르게 설정되었는지의 여부를 검사하는 용도
  (프로퍼티 값을 검증하는 코드를 구현)
  
  public abstract class AbstractUrlBasedView extends AbstractView implements InitializingBean {
    ...
    public void afterPropertiesSet() throws Exception {
      if( getUrl() == null ) {
        throw new lllegalArgumentException("Property 'url' is required");
      }
    }
    ...
  }
'공부 > SPRING(3.0)' 카테고리의 다른 글
| SPRING_[ @Autowired & @Resource 프로퍼티설정 차이 ] (0) | 2013.03.19 | 
|---|---|
| SPRING_[ @어노테이션별 BeanPostProcessor ] (0) | 2013.03.18 | 
| SPRING_[ 부모 빈을 통한 설정 재사용 ] (0) | 2013.03.18 | 
| SPRING_[ Propertie타입 설정 <props>예제] (0) | 2013.03.18 | 
| SPRING_[ 파일업로드 예제(MultipartResolver & @RequestParam 이용) ] (0) | 2013.02.01 |