There is a concept of PropertyEditors which convert string values to a specific custom type. You can implement your own, but for common types PropertyEditors already exist and you have to do nothing, other then know about their existence and how they operate.
More info on PropertyEditors is here: http://static.springframework.org/sp...ans-conversion
But, so I don't sound like RTFM guy :-) here is an example:
Spring configuration (config.xml)
Code:
. . . . . . .
<bean id="foo" class="org.sample.Foo">
<property name="myByteArray" ref="myByteArray"></property>
</bean>
<bean id="myByteArray" class="java.lang.String">
<constructor-arg value="010"/>
</bean>
. . . . . . .
Foo.java
Code:
public class Foo {
private byte[] myByteArray;
public byte[] getMyByteArray() {
return myByteArray;
}
public void setMyByteArray(byte[] myByteArray) {
this.myByteArray = myByteArray;
}
}
Test code:
Code:
ApplicationContext ac = new ClassPathXmlApplicationContext("config.xml");
Foo foo = (Foo) ac.getBean("foo");
System.out.println("Foo.myByteArray: " + foo.getMyByteArray());