#43 Spring bean/MantaConnectionFactory problem

wish_list
open
nobody
General (20)
5
2010-04-08
2010-04-08
davout_eis
No

I've been trying to define the use of Mantaray with my Java Spring web app, by adding the MantaConnectionFactory as a bean to the Spring 'applicationContext.xml' file.

In doing so I've come up against a problem with the fact that the two ways of pushing the config file contents directly into the MantaConnectionFactory class share the same property name, i.e. 'configuration'. This lead to errors like...

---oOo---

Code:
caused by: java.lang.IllegalArgumentException: Cannot convert value of type [java.lang.String] to required type [org.w3c.dom.Element] for property 'configuration': no matching editors or conversion strategy found
at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:231)Is it possible to define the 'configuration' type parameter type as string only?

---oOo---

I think it would be an improvement to change the name of the Element version of the configuration property to 'XML'. Hence, the original method of...

setConfiguration(Element anElement)

... would change to.....

setConfigAsXML(Element anElement)

Also I'd like to see a new property method added that allowed the config file to be passed as a file on the classpath, like

setConfigFileClassPath(String aFileName);
setConfigFile(String aFileName);

To get around the current problem I had to derive a new sub class, see...

public class SkapConnectionFactory extends MantaConnectionFactory {
private static final long serialVersionUID = -6425796291574414062L;
public SkapConnectionFactory() {
}
public SkapConnectionFactory(String s) {
super(s);
}

public void setConfigAsString(String aStr) throws ParserConfigurationException, SAXException, IOException {
super.setConfiguration(aStr);
}

}

<bean id="jmsFactory" class="com.eis.jms.mantaray.SkapConnectionFactory" >
<property name="configAsString">
<bean class="org.apache.commons.io.IOUtils" factory-method="toString" >
<constructor-arg type="java.io.InputStream" value="classpath:mantaray_config.xml"/>
</bean>
</property>
</bean>

Discussion