I want to use restlet with Spring framework and I want Spring can help me to
initialize all the object I needed.
So I wrote a beans definition file as the following:
<?xml version="1.0" encoding="UTF-8"?>
<beans>
<bean id="component" class="org.restlet.ext.spring.SpringComponent">
<property name="server" ref="server" />
<property name="clients">
<list>
<value>file</value>
</list>
</property>
</bean>
<bean id="server" class="org.restlet.ext.spring.SpringServer">
<constructor-arg value="http" />
<constructor-arg value="8182" />
</bean>
</beans>
Before I use the spring component, I want to define the server and client
properties that are needed in the future.
I wrote a test method for this file:
public static void main(String[] args) {
try {
Resource resource = new ClassPathResource("beans.xml");
XmlBeanFactory beanFactory = new XmlBeanFactory
(resource);
SpringComponent component = (SpringComponent)
beanFactory
.getBean("component");
component.start();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
But When I ran this method I got an error as "Failed to convert property value
of type [java.util.ArrayList] to required type [org.restlet.util.ClientList]
for property 'clients'".
I checked the source code of SpringComponent. I finded two setters fot clients
property. One is setClients(List<Object> clients) and another is setClients
(ClientList clients), which is inherited from class Component. I think Spring
called a wrong method when it tried to set clients property.
I tried servral ways to fix it but failed.
How can I resolve this problem?
Thanks a lot.
Garriot zhang