Search in sources :

Example 11 with XMLContext

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;
}
Also used : XMLContext(org.exolab.castor.xml.XMLContext) Mapping(org.exolab.castor.mapping.Mapping)

Aggregations

Mapping (org.exolab.castor.mapping.Mapping)11 XMLContext (org.exolab.castor.xml.XMLContext)11 IOException (java.io.IOException)7 Marshaller (org.exolab.castor.xml.Marshaller)6 StringWriter (java.io.StringWriter)4 FileNotFoundException (java.io.FileNotFoundException)3 OpenClinicaSystemException (org.akaza.openclinica.exception.OpenClinicaSystemException)3 MappingException (org.exolab.castor.mapping.MappingException)3 MarshalException (org.exolab.castor.xml.MarshalException)3 Unmarshaller (org.exolab.castor.xml.Unmarshaller)3 ValidationException (org.exolab.castor.xml.ValidationException)3 SimpleDateFormat (java.text.SimpleDateFormat)2 Calendar (java.util.Calendar)2 Date (java.util.Date)2 GET (javax.ws.rs.GET)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 WebApplicationException (javax.ws.rs.WebApplicationException)2 XPath (javax.xml.xpath.XPath)2 CRFVersionBean (org.akaza.openclinica.bean.submit.CRFVersionBean)2