Monday, 9 January 2012

Spring Property Editors

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">


<bean id="primitiveCollectionBean" class="com.sapient.spring.ioc.PrimitiveCollectionBean">

<property name="number1" value="555"></property>
<property name="name" value="Jack"></property>
<property name="cricketers">
<list>
<value>Sachin Tendulkar</value>
<value>Virendra Sehwag</value>
<value>Mahendra Singh Dhoni</value>
<value>Yusuf Pathan</value>
</list>
</property>

</bean>

<bean id="propertyEditorSample" class="com.sapient.spring.ioc.PropertyEditorSampleBean">
<property name="class">
<value>java.lang.String</value>
</property>
<property name="file">
<value>c:/test.txt</value>
</property>
<property name="locale">
<value>en-GB</value>
</property>
<property name="url">
<value>http://www.springframework.org</value>
</property>
<property name="strings">
<value>rob,jan,rod,jurgen,alef</value>
</property>
<property name="bytes">
<value>Hello World</value>
</property>
</bean>

<!-- Registering a custom property editor-->
<bean class="org.springframework.beans.factory.config.CustomEditorConfigurer">
<property name="customEditors">
<map>
<entry key="java.util.Date">
<bean class="com.sapient.spring.ioc.DatePropertyEditor"/>
</entry>
</map>
</property>
</bean>

<bean id="dateBean" class="com.sapient.spring.ioc.DateBean">
<property name="date">
<value>2009/02/24</value>
</property>
</bean>

</beans>
Dear All,

Please copy all attached files into com.sapient.spring.ioc package.

And applicationContext.xml directly in the project folder SpringCore.

Regards,
Vivek Mehta

No comments:

Post a Comment