Results 1 to 3 of 3

Thread: Ho to make non singleton bean

  1. #1
    Join Date
    May 2007
    Posts
    3

    Default Ho to make non singleton bean

    Hi I am using spring in my project, i want to make my bean as non singleton. I made sigleton="false" in my xml configuration also.
    DTD version is "http://www.springframework.org/dtd/spring-beans.dtd"
    Can any please help me out in this regard.
    Thanks in advance.

    Regards,
    Y Kumar Reddy

  2. #2
    Join Date
    Mar 2008
    Location
    Southampton, UK
    Posts
    28

    Default

    The attribute you're looking for is 'scope' on the 'bean' element:

    Code:
    <bean class="baz.bar.Foo" scope="prototype" />

  3. #3
    Join Date
    Oct 2007
    Location
    Bangalore
    Posts
    29

    Arrow Bean Scopes

    You may have a look at the spring documentation http://static.springframework.org/sp...factory-scopes, which explains bean scopes.

    The prototype scope will create a new instance of the class whenever a call to applicationContext.getBean(name) is called.

    If you are injecting the prototype bean into another bean then during the creation of the referencing bean a new instance of the prototype bean will be created, That means referencing bean will always use a single instance of the prototype bean during its scope, it will not use different instances of the prototype bean.

    With Regards,
    Arun P Johny

Posting Permissions

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