Announcement Announcement Module
Collapse
No announcement yet.
Deferring class instantiation until first use Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Deferring class instantiation until first use

    It appears as if Spring instantiates a class when a configuration file is loaded instead of deferring to first use of that bean, regardless of whether the lazy-init parameter has been set to true. It throws a "ClassNotFoundException".

    Is there any way to defer the instantiation of the class until first use?

    We are attempting to use Spring as sort of a pseudo-registry. We'd like to be able to deploy a Spring ApplicationContext xml file which has definitions for all of our Services, but allow users to only load in the particular services they need.

  • #2
    Instantiation of all (singleton) beans during bean factory startup is a feature of an application context, so by using a normal bean factory you should be able to avoid it.

    Another option is using prototype beans instead of singletons by setting the singleton="false" attribute on your bean definition. That way the bean factory will create a new instance of your bean every time you call getBean().

    Erwin

    Comment

    Working...
    X