Announcement Announcement Module
Collapse
No announcement yet.
Documentation error - pre-instantiation of singleton beans Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    Re: Documentation error - pre-instantiation of singleton bea

    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

    Comment


    • #3
      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.

      Comment

      Working...
      X