现在的位置: 首页 > 综合 > 正文

学习SPRING中的一个疑惑.请教一下各位

2011年07月05日 ⁄ 综合 ⁄ 共 1225字 ⁄ 字号 评论关闭
<?xml version="1.0" encoding="utf-8" ?>

<objects>

    <description>An  example that demonstrates simple IoC features.</description>

    <object name="MyMovieLister" type="Spring.Examples.MovieFinder.MovieLister, MovieFinder">

        <property name="movieFinder">

            <ref local="AnotherMovieFinder" />

        </property>

    </object>

    <object name="MyMovieFinder" type="Spring.Examples.MovieFinder.SimpleMovieFinder, MovieFinder"></object>

    <!--

    An IMovieFinder implementation that uses a text file as it's movie source...

    -->

    <object name="AnotherMovieFinder" type="Spring.Examples.MovieFinder.ColonDelimitedMovieFinder, MovieFinder">

        <constructor-arg index="0">

            <value>movies.txt</value>

        </constructor-arg>

    </object>

</objects>

这是Spring Quick中的程序.这里的Object AnotherMovieFinder定义一个构造函数.并将这个值设为movies.txt

我的疑惑是.如果我需要在程序中把movies.txt改在test.txt的话.怎么实现呢?

下面还有一个类似的问题.前面是构造函数.以下是一个属性.同样我需要在程序中去修改Message

 <object id="TheAction" type="MSPlus.ClassLibrary.UpperAction, MSPlus.ClassLibrary">

  <property name="Message">

   <value>MYFirst</value>

  </property>

 </object>

并且我这里默认是Singleton模式.如果在程序中去修改Message的值后.再次从ObjectFactoy中获取对象时这个Message是显示的是Xml中默认定义的MYFirst值呢还是我在程序中修改后的新值?(我试了一下他还是会显示Xml中定义的值,但如何在Singleton模式下在以后获取这个对像时显示修改后的Message值的?)

请大家请教一下...

抱歉!评论已关闭.