用Spring执行java代码

Java代码如下
Properties props = System.getProperties();
System.out.println(props.getProperty("os.name"));
props.store(new FileOutputStream("a.txt"),"hello world");
Spring 配置

<bean id="props" class="java.util.Properties">
    <constructor-arg ref="getprops"></constructor-arg>

</bean>

<bean id ="getprops" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
    <property name="staticMethod" value="java.lang.System.getProperties"></property>

</bean>

<bean id ="osname" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
    <property name="targetObject" ref="props"></property>
    <property name="targetMethod" value="getProperty"></property>
    <property name="arguments">
        <list>
            <value>os.name</value>
        </list>
    </property>

</bean>

<bean id="out" name="staticField" class="org.springframework.beans.factory.config.FieldRetrievingFactoryBean">
    <property name="staticField" value="java.lang.System.out"></property>
</bean>

<bean id="systemout" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">

    <property name="targetObject" ref="out"></property>
    <property name="targetMethod" value="println"></property>
    <property name="arguments" ref="osname"></property>

</bean>

<bean id="fileout" class="java.io.FileOutputStream">
    <constructor-arg value="a.txt"></constructor-arg>
</bean>

<bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">

    <property name="targetObject" ref="props"></property>
    <property name="targetMethod" value="store"></property>
    <property name="arguments">
        <list>
            <ref bean="fileout"></ref>
            <value>hello world</value>
        </list>
    </property>

</bean>