Search in sources :

Example 1 with OMMetaFactoryLoader

use of org.apache.axiom.locator.loader.OMMetaFactoryLoader in project webservices-axiom by apache.

the class ImplementationFactory method parseImplementation.

private static Implementation parseImplementation(Loader loader, Element implementation) {
    String name = implementation.getAttributeNS(null, "name");
    if (name.length() == 0) {
        log.error("Encountered " + QNAME_IMPLEMENTATION + " element without name attribute");
        return null;
    }
    String loaderClassName = implementation.getAttributeNS(null, "loader");
    if (loaderClassName.length() == 0) {
        log.error("Encountered " + QNAME_IMPLEMENTATION + " element without loader attribute");
        return null;
    }
    OMMetaFactory metaFactory = ((OMMetaFactoryLoader) load(loader, loaderClassName)).load(null);
    if (metaFactory == null) {
        return null;
    }
    List<Feature> features = new ArrayList<Feature>();
    Node child = implementation.getFirstChild();
    while (child != null) {
        if (child instanceof Element) {
            QName childQName = getQName(child);
            if (childQName.equals(QNAME_FEATURE)) {
                Feature feature = parseFeature(loader, (Element) child);
                if (feature != null) {
                    features.add(feature);
                }
            } else {
                log.warn("Skipping unexpected element " + childQName + "; only " + QNAME_FEATURE + " is expected");
            }
        }
        child = child.getNextSibling();
    }
    return new Implementation(name, metaFactory, features.toArray(new Feature[features.size()]));
}
Also used : OMMetaFactoryLoader(org.apache.axiom.locator.loader.OMMetaFactoryLoader) QName(javax.xml.namespace.QName) Node(org.w3c.dom.Node) Element(org.w3c.dom.Element) ArrayList(java.util.ArrayList) OMMetaFactory(org.apache.axiom.om.OMMetaFactory)

Aggregations

ArrayList (java.util.ArrayList)1 QName (javax.xml.namespace.QName)1 OMMetaFactoryLoader (org.apache.axiom.locator.loader.OMMetaFactoryLoader)1 OMMetaFactory (org.apache.axiom.om.OMMetaFactory)1 Element (org.w3c.dom.Element)1 Node (org.w3c.dom.Node)1