Results 1 to 3 of 3

Thread: Documentation error - pre-instantiation of singleton beans

  1. #1
    Join Date
    Dec 2004
    Posts
    2

    Default Documentation error - pre-instantiation of singleton beans

    Page 12 of the Spring Framework Version 1.1.2 states:

    "This potentially delayed visibility of some configuration issues is why ApplicationContext by default pre-instantiates singleton beans. At the cost of some upfront time and memory to create these beans before they are actually needed, you find out about configuration issues when the ApplicationContext is created, not later. If you wish, you can still override this default behavior and set any of these singleton beans to lazy-load (not be pre-instantiated)."

    I've tried setting singleton beans as lazy-init = "true", but the framework still tries to instantiate an instance when ApplicationContext is created.

    If the documentation incorrect? Is there any way around the framework trying to pre-instanstiate singleton beans?

  2. #2
    Join Date
    Aug 2004
    Posts
    2,715

    Default Re: Documentation error - pre-instantiation of singleton bea

    Quote Originally Posted by shoffy
    I've tried setting singleton beans as lazy-init = "true", but the framework still tries to instantiate an instance when ApplicationContext is created.
    The question is, if the offending beans are referenced from within the context. If for example a bean A is pre-instantiated an refers to a bean B which is marked as lazy-init, B is instantiated nonetheless.
    If the pre-instantiation does occur also on unreferenced beans which are marked as lazy-init, you should create an according issue in JIRA.

    Regards,
    Andreas

  3. #3
    Join Date
    Aug 2004
    Location
    Toronto, Canada
    Posts
    736

    Default

    Note also that os of Spring 1.1.2 when doing autowiring, Spring will force even lazy-init marked FactoryBeans to be pre-instantiated, if the return type for those FactoryBeans is not declared (FactoryBeans have a getObjectType method for this). This is to see if they are suitable candidates for autowiring. I actually feel this is not appropriate (and not the old behaviour prior to 1.1.2), so I brought it up for discussion on the dev list today.
    Colin Sampaleanu
    SpringSource - http://www.springsource.com

Similar Threads

  1. Spring container fails with no exception
    By naor in forum Container
    Replies: 9
    Last Post: Oct 1st, 2005, 03:39 PM
  2. EHCaching Hibernate
    By dencamel in forum Data
    Replies: 3
    Last Post: Sep 6th, 2005, 09:03 PM
  3. Odd behaviour when injecting TransactionTemplate
    By damon311 in forum Container
    Replies: 3
    Last Post: Jul 23rd, 2005, 11:21 AM
  4. Stack Overflow
    By rayho222 in forum Container
    Replies: 6
    Last Post: May 17th, 2005, 03:42 AM
  5. DefaultAdvisorAutoProxyCreator skipping beans
    By youngm in forum Container
    Replies: 6
    Last Post: Apr 12th, 2005, 04:29 PM

Posting Permissions

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