use of org.exolab.castor.xml.XMLContext in project camel by apache.
the class AbstractCastorDataFormat method createXMLContext.
protected XMLContext createXMLContext(ClassResolver resolver, ClassLoader contextClassLoader) throws Exception {
XMLContext xmlContext = new XMLContext();
if (ObjectHelper.isNotEmpty(getMappingFile())) {
Mapping xmlMap;
if (contextClassLoader != null) {
xmlMap = new Mapping(contextClassLoader);
} else {
xmlMap = new Mapping();
}
xmlMap.loadMapping(resolver.loadResourceAsURL(getMappingFile()));
xmlContext.addMapping(xmlMap);
}
if (getPackages() != null) {
xmlContext.addPackages(getPackages());
}
if (getClassNames() != null) {
for (String name : getClassNames()) {
Class<?> clazz = resolver.resolveClass(name);
xmlContext.addClass(clazz);
}
}
return xmlContext;
}
Aggregations