Search in sources :

Example 1 with AbstractDataBinding

use of org.apache.cxf.databinding.AbstractDataBinding in project cxf by apache.

the class AbstractServiceFactoryBean method fillDataBindingSchemas.

private void fillDataBindingSchemas() {
    ResourceManager rr = getBus().getExtension(ResourceManager.class);
    List<DOMSource> schemas = new ArrayList<>();
    for (String l : schemaLocations) {
        URL url = rr.resolveResource(l, URL.class);
        if (url == null) {
            try (URIResolver res = new URIResolver(l)) {
                if (!res.isResolved()) {
                    throw new ServiceConstructionException(new Message("INVALID_SCHEMA_URL", LOG, l));
                }
                url = res.getURL();
            } catch (IOException e) {
                throw new ServiceConstructionException(new Message("INVALID_SCHEMA_URL", LOG, l), e);
            }
        }
        Document d;
        try (InputStream in = url.openStream()) {
            d = StaxUtils.read(in);
        } catch (Exception e) {
            throw new ServiceConstructionException(new Message("ERROR_READING_SCHEMA", LOG, l), e);
        }
        schemas.add(new DOMSource(d, url.toString()));
    }
    ((AbstractDataBinding) getDataBinding()).setSchemas(schemas);
}
Also used : AbstractDataBinding(org.apache.cxf.databinding.AbstractDataBinding) DOMSource(javax.xml.transform.dom.DOMSource) Message(org.apache.cxf.common.i18n.Message) InputStream(java.io.InputStream) ArrayList(java.util.ArrayList) ModCountCopyOnWriteArrayList(org.apache.cxf.common.util.ModCountCopyOnWriteArrayList) URIResolver(org.apache.cxf.resource.URIResolver) ResourceManager(org.apache.cxf.resource.ResourceManager) IOException(java.io.IOException) Document(org.w3c.dom.Document) URL(java.net.URL) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1 DOMSource (javax.xml.transform.dom.DOMSource)1 Message (org.apache.cxf.common.i18n.Message)1 ModCountCopyOnWriteArrayList (org.apache.cxf.common.util.ModCountCopyOnWriteArrayList)1 AbstractDataBinding (org.apache.cxf.databinding.AbstractDataBinding)1 ResourceManager (org.apache.cxf.resource.ResourceManager)1 URIResolver (org.apache.cxf.resource.URIResolver)1 Document (org.w3c.dom.Document)1