Announcement Announcement Module
Collapse
No announcement yet.
AnnotationContextAware and AutowireCapableBeanFactory Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • AnnotationContextAware and AutowireCapableBeanFactory

    hi,

    I've got a couple of classes implementing ApplicationContextAware. I create my objects by myself and pass them to the autowireBean- Method in an AutowireCapableBeanFactory. Doing so, the setApplicationContext()- Method is never called. It is possible to get an application context by creating a field of type ApplicationContext and annotate it with @autowired.

    I guess that's because autowireBean() performs autowiring only and an Interface is no autowiring.

    (1) Is my guess correct?
    (2) Is there any chance to make spring call setApplicationContext() on an object not created by the container?

  • #2
    1) No
    2) No

    The ApplicationContextAware is a marker interface which is called after bean construction by a BeanPostProcessor, as you are instantiating beans yourself the initialization and BeanPostProcessors aren't called for your beans.

    Comment

    Working...
    X