Results 1 to 2 of 2

Thread: AnnotationContextAware and AutowireCapableBeanFactory

  1. #1
    Join Date
    Mar 2010
    Posts
    8

    Default 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. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,695

    Default

    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.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •