Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

FactoryBean's isSingleton()

 
Arya Pramod
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Everybody,

By returning true from isSingleton() method of FactoryBean implementation class,

Does Spring create a Singleton instance of the Class Implementing the FactoryBean Interface


If yes, then the following code



does not throw an exception even when the Implementing class has explicitly defined itself as a singleton through scope="prototype" and isSingleton() method returns true.

Thanks In Advance,
Pramod
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Returning true in isSingleton() will not magically make your bean a singleton. You have to make it work like a singleton, so you have to make sure that getObject() always returns the same object (a reference that can be cached). Is there any special reason why you are using this interface ?
 
Arya Pramod
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank You Christophe,

I am actually new to Spring Framework, so just getting some hands-on knowledge.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic