File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Other Application Frameworks and the fly likes FactoryBean's isSingleton() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "FactoryBean Watch "FactoryBean New topic

FactoryBean's isSingleton()

Arya Pramod

Joined: Jan 10, 2008
Posts: 12
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,
Christophe Verré

Joined: Nov 24, 2005
Posts: 14688

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 ?

[My Blog]
All roads lead to JavaRanch
Arya Pramod

Joined: Jan 10, 2008
Posts: 12
Thank You Christophe,

I am actually new to Spring Framework, so just getting some hands-on knowledge.
I agree. Here's the link:
subject: FactoryBean's isSingleton()
It's not a secret anymore!