DevLogs/LearningSpring

Spring의 *Aware 인터페이스들에 대한 정리

밥먹고해요 2024. 11. 13. 17:10

 

개요

  • XyzAware 인터페이스는 setXyz(Xyz) 메서드를 가지는 규약이 있어 보인다.
  • 메서드를 구현하면, IoC 컨테이너에 의해 콜백 호출된다.

종류와 메서드

  1. ApplicationContextAware
    • 메서드: setApplicationContext(ApplicationContext applicationContext)
  2. ApplicationEventPublisherAware
    • 메서드: setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher)
  3. BeanClassLoaderAware
    • 메서드: setBeanClassLoader(ClassLoader classLoader)
  4. BeanFactoryAware
    • 메서드: setBeanFactory(BeanFactory beanFactory)
  5. BeanNameAware
    • 메서드: setBeanName(String name)
  6. BootstrapContextAware (Spring Batch)
    • 메서드: setBootstrapContext(BootstrapContext bootstrapContext)
  7. EmbeddedValueResolverAware
    • 메서드: setEmbeddedValueResolver(StringValueResolver resolver)
  8. EnvironmentAware
    • 메서드: setEnvironment(Environment environment)
  9. LoadTimeWeaverAware
    • 메서드: setLoadTimeWeaver(LoadTimeWeaver loadTimeWeaver)
  10. MessageSourceAware
    • 메서드: setMessageSource(MessageSource messageSource)
  11. NotificationPublisherAware (Spring JMX)
    • 메서드: setNotificationPublisher(NotificationPublisher notificationPublisher)
  12. ResourceLoaderAware
    • 메서드: setResourceLoader(ResourceLoader resourceLoader)
  13. ServletConfigAware (Spring Web)
    • 메서드: setServletConfig(ServletConfig servletConfig)
  14. ServletContextAware (Spring Web)
    • 메서드: setServletContext(ServletContext servletContext)