1,<util:constant/>
取代了之前通过FieldRetrevingFactoryBean获取bean静态常量的FactoryBean!
老的用法
[code]<bean id="..." class="...">
<property name="isolation">
<bean id="java.sql.Connection.TRANSACTION_SERIALIZABLE"
class="org.springframework.beans.factory.config.FieldRetrievingFactoryBean" />
</property>
</bean>[/code]
新用法
[code]<bean id="..." class="...">
<property name="isolation">
<util:constant static-field="java.sql.Connection.TRANSACTION_SERIALIZABLE"/>
</property>
</bean>[/code]
2,<util:property-path/>
取代了之前通过PropertyPathFactoryBean来指定属性路径获取属性值的FactoryBean!
老的用法
[code]
<bean id="testBean" class="org.springframework.beans.TestBean" singleton="false">
<property name="age" value="10"/>
<property name="spouse">
<bean class="org.springframework.beans.TestBean">
<property name="age" value="11"/>
</bean>
</property>
</bean>
<bean id="testBean.age" class="org.springframework.beans.factory.config.PropertyPathFactoryBean"/>[/code]
新的用法
[code]
<bean id="testBean" class="org.springframework.beans.TestBean" singleton="false">
<property name="age" value="10"/>
<property name="spouse">
<bean class="org.springframework.beans.TestBean">
<property name="age" value="11"/>
</bean>
</property>
</bean>
<util:property-path id="name" path="testBean.age"/>
[/code]
3,<util:properties/>
替代了之前通过PropertiesFactoryBean来获取properties配制文件数据的FactoryBean!
老用法
[code]<bean id="jdbcConfiguration" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
<property name="location" value="classpath:com/foo/jdbc-production.properties"/>
</bean>[/code]
新用法
[code]<util:properties id="jdbcConfiguration" location="classpath:com/foo/jdbc-production.properties"/>[/code]
4,<util:list/>
替代了之前通过<list><value></value></list>的内置配制方式,让多个bean调用同一list成为可能!
老的用法
[code]<bean id="emails" class="org.springframework.beans.factory.config.ListFactoryBean">
<property name="sourceList">
<list>
<value>pechorin@hero.org</value>
<value>raskolnikov@slums.org</value>
<value>stavrogin@gov.org</value>
<value>porfiry@gov.org</value>
</list>
</property>
</bean>[/code]
新的用法
[code]<util:list id="emails" list-class="java.util.LinkedList">
<value>pechorin@hero.org</value>
<value>raskolnikov@slums.org</value>
<value>stavrogin@gov.org</value>
<value>porfiry@gov.org</value>
</util:list>[/code]
5,<util:map/>
替代了之前适用<map><entry key=""><value></value></entry></map>的配置方式,让多个bean调用同一map成为可能!
老的用法
[code]<bean id="emails" class="org.springframework.beans.factory.config.MapFactoryBean">
<property name="sourceMap">
<map>
<entry key="pechorin" value="pechorin@hero.org"/>
<entry key="raskolnikov" value="raskolnikov@slums.org"/>
<entry key="stavrogin" value="stavrogin@gov.org"/>
<entry key="porfiry" value="porfiry@gov.org"/>
</list>
</property>
</bean>[/code]
新的用法
[code]<util:map id="emails" map-class="java.util.TreeMap">
<entry key="pechorin" value="pechorin@hero.org"/>
<entry key="raskolnikov" value="raskolnikov@slums.org"/>
<entry key="stavrogin" value="stavrogin@gov.org"/>
<entry key="porfiry" value="porfiry@gov.org"/>
</util:map>[/code]
6,<util:set/>
替代了之前适用<set><value></value></set>的配置方式,
让多个bean调用同一set成为可能!
老的用法
[code]<bean id="emails" class="org.springframework.beans.factory.config.SetFactoryBean">
<property name="sourceSet">
<set>
<value>pechorin@hero.org</value>
<value>raskolnikov@slums.org</value>
<value>stavrogin@gov.org</value>
<value>porfiry@gov.org</value>
</set>
</property>
</bean>[/code]
新的用法
[code]<util:set id="emails" set-class="java.util.TreeSet">
<value>pechorin@hero.org</value>
<value>raskolnikov@slums.org</value>
<value>stavrogin@gov.org</value>
<value>porfiry@gov.org</value>
</util:set>[/code]
7,<jee:jndi-lookup/>
替代了之前使用JndiObjectFactoryBean指定配制获取容器JNDI资源的FactoryBean!
老的用法
[code]<bean id="simple" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="jdbc/MyDataSource"/>
<property name="cache" value="true"/>
<property name="resourceRef" value="true"/>
<property name="lookupOnStartup" value="false"/>
<property name="expectedType" value="com.myapp.DefaultFoo"/>
<property name="proxyInterface" value="com.myapp.Foo"/>
</bean>
[/code]
新用法
[code]<jee:jndi-lookup id="simple"
jndi-name="jdbc/MyDataSource"
cache="true"
resource-ref="true"
lookup-on-startup="false"
expected-type="com.myapp.DefaultFoo"
proxy-interface="com.myapp.Foo"/>[/code]
8,<jee:local-slsb/>
替代了之前使用LocalStatelessSessionProxyFactoryBean来获取无状态会话BEAN的FactoryBean!
老的用法
[code]<bean id="complexRemoteEjb"
class="org.springframework.ejb.access.LocalStatelessSessionProxyFactoryBean">
<property name="jndiName" value="ejb/MyRemoteBean"/>
<property name="businessInterface" value="com.foo.service.RentalService"/>
<property name="cacheHome" value="true"/>
<property name="lookupHomeOnStartup" value="true"/>
<property name="resourceRef" value="true"/>
<property name="homeInterface" value="com.foo.service.RentalService"/>
<property name="refreshHomeOnConnectFailure" value="true"/>
</bean>[/code]
新的用法
[code]<jee:remote-slsb id="complexRemoteEjb"
jndi-name="ejb/MyRemoteBean"
business-interface="com.foo.service.RentalService"
cache-home="true"
lookup-home-on-startup="true"
resource-ref="true"
home-interface="com.foo.service.RentalService"
refresh-home-on-connect-failure="true">[/code]