CastorMarshaller multiple mappingLocations and custom FieldHandlers
Castor version: 1.2
Spring-OXM version: 1.0.2
My spring CastorMarshaller bean definition is shown below, I am using it to aggregate multiple mapping files from different jars in my classpath. I see the mapping locations setting up ok during application context startup. However, the problem arises when I try to define a custom ConfigurableFieldHandler in one of my mapping files.
my marshaller bean:
Code:
<bean id="castorMarshaller"
class="org.springframework.oxm.castor.CastorMarshaller">
<property name="mappingLocations">
<list>
<value>classpath*:castor/**/*cbm.xml</value>
</list>
</property>
</bean>
my field handler as defined in one of my mapping files:
Code:
<field-handler name="myHandler" class="com.xxx.SomeConfigurableFieldHandler">
<param name="someProp" value="somePropValue" />
</field-handler>
This works fine if I change classpath*:castor/**/*cbm.xml to load a single mapping file that has all the other mapping files as castor includes (e.g., <include href="someOtherMappingFile"/>).
I believe the underlying problem starts in CastorMarshaller's createClassDescriptorResolver method where the following happens:
Code:
for (int i = 0; i < mappingLocations.length; i++) {
mapping.loadMapping(new InputSource(mappingLocations[i].getInputStream()));
}
This trickles down to Castor's code (XMLMappingLoader.loadMapping) but the mapping root is lost this causes the _fieldHandlers in AbstractMappingLoader to reset.
Is this a Castor issue?
If I bypass spring's CastorMarshaller and load my multiple mappings manually using the method shown below it works fine:
Code:
XMLContext context = new XMLContext();
context.addMapping("");