use of org.apache.axiom.om.impl.intf.AxiomSourcedElement 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;
}
use of org.apache.axiom.om.impl.intf.AxiomSourcedElement in project webservices-axiom by apache.
the class OMFactoryImpl method createOMElement.
@Override
public final OMSourcedElement createOMElement(OMDataSource source, String localName, OMNamespace ns) {
AxiomSourcedElement element = createNode(AxiomSourcedElement.class);
element.init(localName, ns, source);
return element;
}
use of org.apache.axiom.om.impl.intf.AxiomSourcedElement in project webservices-axiom by apache.
the class OMFactoryImpl method createOMElement.
@Override
public final OMSourcedElement createOMElement(OMDataSource source, QName qname) {
AxiomSourcedElement element = createNode(AxiomSourcedElement.class);
element.init(qname, source);
return element;
}
use of org.apache.axiom.om.impl.intf.AxiomSourcedElement in project webservices-axiom by apache.
the class OMFactoryImpl method createOMElement.
@Override
public final OMSourcedElement createOMElement(OMDataSource source) {
AxiomSourcedElement element = createNode(AxiomSourcedElement.class);
element.init(source);
return element;
}
Aggregations