Results 1 to 2 of 2

Thread: BeanPostProcessors should be instantiated first

  1. #1
    Join Date
    Aug 2004
    Posts
    229

    Default BeanPostProcessors should be instantiated first

    I have an interface in my application similar to "BeanFactoryAware". I've created a BeanPostProcessor In order to automatically inject beans that implement my custom interface. I would like to simply define the BeanPostProcessor bean in my app context to have Spring automatically utilize it when instantiating other beans. However, this is not working. Upon startup the app context will begin to instantiate all singletons, however it will not instantiate my BeanPostProcessor first, and so any beans instantiated before the BeanPostProcessor do not get the benefit of the BeanPostProcessor. Shouldn't Spring determine which contained beans implement the BeanPostProcessor interface and give them a higher instantiation priority? I could have my other beans "depend-on" my BeanPostProcessor, but then that kind of defeats the purpose of the BeanPostProcessor (it creates an explicit relationship in my Spring config when I was trying to make it implicit and automatic). I realize that I could manually instantiate the BeanPostProcessor and set it up before loading the config file, but this is something I want to avoid.

    - Andy

  2. #2
    Join Date
    Aug 2004
    Posts
    229

    Default

    To answer my own question - BeanPostProcessors are instantiated first. My problem was that one BeanPostProcessor (through a series of dependencies) ended up referencing a bean that depended on another BeanPostProcessor before its afterPropertiesSet() was called.

Similar Threads

  1. Order of Bean definitions matters?
    By cfuser in forum Container
    Replies: 2
    Last Post: Oct 21st, 2005, 10:29 AM
  2. Unit testing with JOTM and JtaTransactionManager
    By lalle in forum Architecture
    Replies: 1
    Last Post: Oct 15th, 2005, 09:05 AM
  3. Spring container fails with no exception
    By naor in forum Container
    Replies: 9
    Last Post: Oct 1st, 2005, 03:39 PM
  4. EHCaching Hibernate
    By dencamel in forum Data
    Replies: 3
    Last Post: Sep 6th, 2005, 09:03 PM
  5. Stack Overflow
    By rayho222 in forum Container
    Replies: 6
    Last Post: May 17th, 2005, 03:42 AM

Posting Permissions

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