Search in sources :

Example 1 with AxiomSOAPHeaderBlock

use of org.apache.axiom.soap.impl.intf.AxiomSOAPHeaderBlock in project webservices-axiom by apache.

the class CustomBuilderManager method getAction.

private Runnable getAction(CoreNode node, int depth, int firstCustomBuilder) {
    lastCandidateElement = null;
    lastCandidateDepth = -1;
    if (node instanceof AxiomElement && (node instanceof AxiomSOAPHeaderBlock || !(node instanceof AxiomSOAPElement))) {
        final AxiomElement element = (AxiomElement) node;
        if (registrations != null) {
            for (int i = firstCustomBuilder; i < registrations.size(); i++) {
                CustomBuilderRegistration registration = registrations.get(i);
                final String namespaceURI = element.coreGetNamespaceURI();
                final String localName = element.coreGetLocalName();
                if (registration.getSelector().accepts(element.getParent(), depth, namespaceURI, localName)) {
                    final CustomBuilder customBuilder = registration.getCustomBuilder();
                    if (log.isDebugEnabled()) {
                        log.debug("Custom builder " + customBuilder + " accepted element {" + namespaceURI + "}" + localName + " at depth " + depth);
                    }
                    return new Runnable() {

                        @Override
                        public void run() {
                            if (log.isDebugEnabled()) {
                                log.debug("Invoking custom builder " + customBuilder);
                            }
                            OMDataSource dataSource = customBuilder.create(element);
                            Class<? extends AxiomSourcedElement> type;
                            if (element instanceof AxiomSOAP11HeaderBlock) {
                                type = AxiomSOAP11HeaderBlock.class;
                            } else if (element instanceof AxiomSOAP12HeaderBlock) {
                                type = AxiomSOAP12HeaderBlock.class;
                            } else {
                                type = AxiomSourcedElement.class;
                            }
                            if (log.isDebugEnabled()) {
                                log.debug("Replacing element with new sourced element of type " + type);
                            }
                            AxiomSourcedElement newElement = element.coreCreateNode(type);
                            newElement.init(localName, new OMNamespaceImpl(namespaceURI, null), dataSource);
                            try {
                                element.coreReplaceWith(newElement, AxiomSemantics.INSTANCE);
                            } catch (CoreModelException ex) {
                                throw AxiomExceptionTranslator.translate(ex);
                            }
                        }
                    };
                }
            }
        }
        // Save a reference to the element so that we can process it when another custom builder is registered
        lastCandidateElement = element;
        lastCandidateDepth = depth;
    }
    return null;
}
Also used : OMDataSource(org.apache.axiom.om.OMDataSource) AxiomSOAPHeaderBlock(org.apache.axiom.soap.impl.intf.AxiomSOAPHeaderBlock) CustomBuilder(org.apache.axiom.om.ds.custombuilder.CustomBuilder) AxiomSOAP12HeaderBlock(org.apache.axiom.soap.impl.intf.AxiomSOAP12HeaderBlock) AxiomSOAPElement(org.apache.axiom.soap.impl.intf.AxiomSOAPElement) AxiomSourcedElement(org.apache.axiom.om.impl.intf.AxiomSourcedElement) CoreModelException(org.apache.axiom.core.CoreModelException) AxiomElement(org.apache.axiom.om.impl.intf.AxiomElement) AxiomSOAP11HeaderBlock(org.apache.axiom.soap.impl.intf.AxiomSOAP11HeaderBlock) OMNamespaceImpl(org.apache.axiom.om.impl.common.OMNamespaceImpl)

Example 2 with AxiomSOAPHeaderBlock

use of org.apache.axiom.soap.impl.intf.AxiomSOAPHeaderBlock in project webservices-axiom by apache.

the class SOAPFactoryImpl method createSOAPHeaderBlock.

@Override
public final SOAPHeaderBlock createSOAPHeaderBlock(String localName, OMNamespace ns, OMDataSource ds) {
    AxiomSOAPHeaderBlock element = createNode(getSOAPHelper().getHeaderBlockClass());
    element.init(localName, ns, ds);
    return element;
}
Also used : AxiomSOAPHeaderBlock(org.apache.axiom.soap.impl.intf.AxiomSOAPHeaderBlock)

Example 3 with AxiomSOAPHeaderBlock

use of org.apache.axiom.soap.impl.intf.AxiomSOAPHeaderBlock in project webservices-axiom by apache.

the class SOAPFactoryImpl method createSOAPHeaderBlock.

@Override
public final SOAPHeaderBlock createSOAPHeaderBlock(OMDataSource source) {
    AxiomSOAPHeaderBlock element = createNode(getSOAPHelper().getHeaderBlockClass());
    element.init(source);
    return element;
}
Also used : AxiomSOAPHeaderBlock(org.apache.axiom.soap.impl.intf.AxiomSOAPHeaderBlock)

Aggregations

AxiomSOAPHeaderBlock (org.apache.axiom.soap.impl.intf.AxiomSOAPHeaderBlock)3 CoreModelException (org.apache.axiom.core.CoreModelException)1 OMDataSource (org.apache.axiom.om.OMDataSource)1 CustomBuilder (org.apache.axiom.om.ds.custombuilder.CustomBuilder)1 OMNamespaceImpl (org.apache.axiom.om.impl.common.OMNamespaceImpl)1 AxiomElement (org.apache.axiom.om.impl.intf.AxiomElement)1 AxiomSourcedElement (org.apache.axiom.om.impl.intf.AxiomSourcedElement)1 AxiomSOAP11HeaderBlock (org.apache.axiom.soap.impl.intf.AxiomSOAP11HeaderBlock)1 AxiomSOAP12HeaderBlock (org.apache.axiom.soap.impl.intf.AxiomSOAP12HeaderBlock)1 AxiomSOAPElement (org.apache.axiom.soap.impl.intf.AxiomSOAPElement)1