Skip to content

Commit 97036a4

Browse files
committed
some comments about scope of the beans(singleton, prototype)
1 parent 7518ced commit 97036a4

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/main/resources/applicationContext.xml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
<!-- </bean>-->
4141

4242
<!-- Dependency injection using setters and taking information from properties file -->
43+
<!-- !!!! By default we have scope - 'singleton' ( it means that all the variables in main class which were created from the same bean will reference on the same object(bean) -->
4344
<bean id="musicPlayer"
4445
class="dlivitin.springapp1.MusicPlayer">
4546
<property name="musicList">
@@ -52,4 +53,19 @@
5253
<property name="volume" value="${musicPlayer.volume}"/>
5354
</bean>
5455

56+
57+
<!-- We can set scope = prototype (in that case for all variables created using this bean new object will be created). Each variable will reference to its own object. -->
58+
59+
<!-- <bean id="musicPlayer"-->
60+
<!-- class="dlivitin.springapp1.MusicPlayer" scope="prototype">-->
61+
<!-- <property name="musicList">-->
62+
<!-- <list>-->
63+
<!-- <ref bean="classicalMusicBean"/>-->
64+
<!-- <ref bean="rockMusicBean"/>-->
65+
<!-- </list>-->
66+
<!-- </property>-->
67+
<!-- <property name="name" value="${musicPlayer.name}"/>-->
68+
<!-- <property name="volume" value="${musicPlayer.volume}"/>-->
69+
<!-- </bean>-->
70+
5571
</beans>

0 commit comments

Comments
 (0)