permaculture playing cards*
The moose likes Spring and the fly likes Basic Spring Doubt Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Basic Spring Doubt" Watch "Basic Spring Doubt" New topic
Author

Basic Spring Doubt

Dhanesh Rote
Greenhorn

Joined: Sep 29, 2005
Posts: 3
Hello ,
I have following two beans in the xml context. I want to know whether the underlying objects denoted by these 2 beans remains the same or different? In case of String its the same one. What about with spring? Can anybody let me know on this...


<bean id="ftpConnector1"
class="com.service.integ.transport.FtpConnectorCommonsNetImpl">
<property name="ftpUser">
<value>${ftp.provisioning.user}</value>
</property>
<property name="ftpPassword">
<value>${ftp.provisioning.password}</value>
</property>
<property name="ftpServer">
<value>${ftp.provisioning.host}</value>
</property>
</bean>


<bean id="ftpConnector2"
class="com.service.integ.transport.FtpConnectorCommonsNetImpl">
<property name="ftpUser">
<value>${ftp.provisioning.user}</value>
</property>
<property name="ftpPassword">
<value>${ftp.provisioning.password}</value>
</property>
<property name="ftpServer">
<value>${ftp.provisioning.host}</value>
</property>
</bean>

Jelle Klap
Bartender

Joined: Mar 10, 2008
Posts: 1756
    
    7

Hi, welcome to JavaRanch!

If you define two beans of the same type, each with the default singleton scope, then two distinct instances of that type will be registered with Spring's IoC container.
It can be a cause of some headaches if you auto-wire your beans by type, though.
Does that answer your question?

Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.
Dhanesh Rote
Greenhorn

Joined: Sep 29, 2005
Posts: 3
Thanks. Got it..
 
wood burning stoves
 
subject: Basic Spring Doubt
 
Similar Threads
BeanDefinitionStoreException
Call setter on one bean with getter from other bean
Please explain the logic
Spring MVC - no ContextLoaderListener registered
nested exception is org.xml.sax.SAXParseException: Attribute "value" must be declared