RSS RSS feed | Atom Atom feed | |

Array properties in Spring Framework

Easy, simple, and apperently beyond me

Spring automatically converts the strings in the configuration file into the Java objects required by your application. The mecanism that accomplishes this is a set of beans know as Property Editors. While it is possible to create and configure your own Property Editors, Spring comes preconfigured with Property Editors for most situations.

What makes Spring easy to use is the support for complex types as well as primitives. List, Set, Properties, and Map objects can be ceated with Spring tags. Even better, Spring will convert Lists to Java arrays for some types.

So, if you have Java that looks like this:

void setProperty1(String[] aStringArray){...}
void setProperty2(List aStringList){...}

You can configure it with XML that looks like this:

<property name="property1">
  	<list>
    	<value>one</value>
    	<value>two</value>
  	</list>
</property>
<property name="property2">
  	<list>
    	<value>one</value>
    	<value>two</value>
  	</list>
</property>
Tags :



Add a comment Send a TrackBack