You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ws.apache.org by ve...@apache.org on 2016/02/13 20:10:19 UTC
svn commit: r1730260 - in /webservices/axiom/trunk:
aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/
aspects/om-aspects/src/main/java/org/apache/axiom/soap/impl/common/builder/
axiom-api/ axiom-api/src/main/java/org/apache/axio...
Author: veithen
Date: Sat Feb 13 19:10:18 2016
New Revision: 1730260
URL: http://svn.apache.org/viewvc?rev=1730260&view=rev
Log:
Redesign the custom builder API introduced in AXIOM-330.
Added:
webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/CustomBuilderManager.java (with props)
webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/CustomBuilderRegistration.java (with props)
webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/om/ds/custombuilder/CustomBuilder.java
- copied, changed from r1730239, webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/CustomBuilder.java
webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/om/ds/custombuilder/CustomBuilderSupport.java
- copied, changed from r1730239, webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/CustomBuilderSupport.java
Removed:
webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/PayloadSelector.java
webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/soap/impl/common/builder/SOAPPayloadSelector.java
webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/CustomBuilder.java
webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/CustomBuilderSupport.java
Modified:
webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/BuilderHandler.java
webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/BuilderListener.java
webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/StAXHelper.java
webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/StAXOMBuilder.java
webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/soap/impl/common/builder/StAXSOAPModelBuilder.java
webservices/axiom/trunk/axiom-api/pom.xml
webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/ext/stax/DelegatingXMLStreamReader.java
webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/om/ds/custombuilder/ByteArrayCustomBuilder.java
webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/util/stax/XMLStreamReaderUtils.java
webservices/axiom/trunk/implementations/fom-impl/src/main/java/org/apache/abdera/parser/stax/FOMBuilder.java
webservices/axiom/trunk/src/site/markdown/release-notes/1.3.0.md
webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/JAXBCustomBuilder.java
webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/RegisterCustomBuilderForPayloadJAXBTestCase.java
webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/TestRegisterCustomBuilderForPayloadJAXBPlain.java
webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/TestRegisterCustomBuilderForPayloadJAXBWithDataHandlerReaderExtension.java
webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/TestRegisterCustomBuilderForPayloadJAXBWithXOP.java
webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/body/FirstElementNameWithParserTestCase.java
webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/builder/TestRegisterCustomBuilder.java
webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/builder/TestRegisterCustomBuilderForPayload.java
webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/builder/TestRegisterCustomBuilderForPayloadAfterSOAPFaultCheck.java
webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap11/misc/TestElementPullStreamAndOMExpansion.java
webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap11/misc/TestElementPullStreamAndOMExpansion2.java
webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap11/misc/TestElementPullStreamAndOMExpansion3.java
Modified: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/BuilderHandler.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/BuilderHandler.java?rev=1730260&r1=1730259&r2=1730260&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/BuilderHandler.java (original)
+++ webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/BuilderHandler.java Sat Feb 13 19:10:18 2016
@@ -20,7 +20,9 @@ package org.apache.axiom.om.impl.common.
import java.util.ArrayList;
import java.util.LinkedHashMap;
+import java.util.LinkedList;
import java.util.Map;
+import java.util.Queue;
import javax.xml.stream.XMLStreamConstants;
@@ -82,6 +84,7 @@ public final class BuilderHandler implem
public Map<CoreParentNode,Throwable> discardTracker = log.isDebugEnabled() ? new LinkedHashMap<CoreParentNode,Throwable>() : null;
private ArrayList<BuilderListener> listeners;
+ private Queue<Runnable> deferredListenerActions;
public BuilderHandler(NodeFactory nodeFactory, Model model, AxiomSourcedElement root, Builder builder) {
this.nodeFactory = nodeFactory;
@@ -97,14 +100,29 @@ public final class BuilderHandler implem
listeners.add(listener);
}
- public void nodeAdded(CoreNode node) {
+ private void nodeAdded(CoreNode node) {
if (listeners != null) {
for (int i=0, size=listeners.size(); i<size; i++) {
- listeners.get(i).nodeAdded(node, depth);
+ Runnable action = listeners.get(i).nodeAdded(node, depth);
+ if (action != null) {
+ if (deferredListenerActions == null) {
+ deferredListenerActions = new LinkedList<Runnable>();
+ }
+ deferredListenerActions.add(action);
+ }
}
}
}
+ void executeDeferredListenerActions() {
+ if (deferredListenerActions != null) {
+ Runnable action;
+ while ((action = deferredListenerActions.poll()) != null) {
+ action.run();
+ }
+ }
+ }
+
public boolean isCompleted() {
return done;
}
Modified: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/BuilderListener.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/BuilderListener.java?rev=1730260&r1=1730259&r2=1730260&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/BuilderListener.java (original)
+++ webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/BuilderListener.java Sat Feb 13 19:10:18 2016
@@ -24,14 +24,19 @@ import org.apache.axiom.core.CoreNode;
public interface BuilderListener {
/**
* Inform the listener that a node has been added to the tree. Note that this method will also
- * be invoked for the {@link CoreDocument}.
+ * be invoked for the {@link CoreDocument}. Since the builder is not reentrant, implementations
+ * must not perform any operations on the node that would require building additional nodes. If
+ * such operations need to be executed, the listener should return a {@link Runnable}
+ * encapsulating these operations. The builder will then execute that runnable as soon as it is
+ * safe to do so.
*
* @param node
* the node that has been added
* @param depth
* the depth of the node, with 0 corresponding to the document
+ * @return a runnable to be executed when the object model can safely be accessed again
*/
// TODO: specify if what happens for attributes (including depth)
// TODO: an ancestor of the node may have been detached or moved; specify what this means for the depth
- void nodeAdded(CoreNode node, int depth);
+ Runnable nodeAdded(CoreNode node, int depth);
}
Added: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/CustomBuilderManager.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/CustomBuilderManager.java?rev=1730260&view=auto
==============================================================================
--- webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/CustomBuilderManager.java (added)
+++ webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/CustomBuilderManager.java Sat Feb 13 19:10:18 2016
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.axiom.om.impl.common.builder;
+
+import java.util.ArrayList;
+
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.axiom.core.CoreNode;
+import org.apache.axiom.om.OMDataSource;
+import org.apache.axiom.om.OMException;
+import org.apache.axiom.om.ds.custombuilder.CustomBuilder;
+import org.apache.axiom.om.impl.common.AxiomSemantics;
+import org.apache.axiom.om.impl.common.OMNamespaceImpl;
+import org.apache.axiom.om.impl.intf.AxiomElement;
+import org.apache.axiom.om.impl.intf.AxiomSourcedElement;
+import org.apache.axiom.soap.impl.intf.AxiomSOAP11HeaderBlock;
+import org.apache.axiom.soap.impl.intf.AxiomSOAP12HeaderBlock;
+import org.apache.axiom.soap.impl.intf.AxiomSOAPElement;
+import org.apache.axiom.soap.impl.intf.AxiomSOAPHeaderBlock;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+final class CustomBuilderManager implements BuilderListener {
+ private static final Log log = LogFactory.getLog(CustomBuilderManager.class);
+
+ private final ArrayList<CustomBuilderRegistration> registrations = new ArrayList<CustomBuilderRegistration>();
+
+ void register(CustomBuilder.Selector selector, CustomBuilder customBuilder) {
+ registrations.add(new CustomBuilderRegistration(selector, customBuilder));
+ }
+
+ @Override
+ public Runnable nodeAdded(CoreNode node, int depth) {
+ if (node instanceof AxiomElement && (node instanceof AxiomSOAPHeaderBlock || !(node instanceof AxiomSOAPElement))) {
+ final AxiomElement element = (AxiomElement)node;
+ for (int i=0; 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);
+ }
+ XMLStreamReader reader = element.getXMLStreamReader(false);
+ // Advance the reader to the START_ELEMENT event of the root element
+ try {
+ reader.next();
+ } catch (XMLStreamException ex) {
+ // We should never get here
+ throw new OMException(ex);
+ }
+ OMDataSource dataSource = customBuilder.create(reader);
+ try {
+ reader.close();
+ } catch (XMLStreamException ex) {
+ // We should never get here
+ throw new OMException(ex);
+ }
+ 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);
+ element.coreReplaceWith(newElement, AxiomSemantics.INSTANCE);
+ }
+ };
+ }
+ }
+ }
+ return null;
+ }
+}
Propchange: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/CustomBuilderManager.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/CustomBuilderRegistration.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/CustomBuilderRegistration.java?rev=1730260&view=auto
==============================================================================
--- webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/CustomBuilderRegistration.java (added)
+++ webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/CustomBuilderRegistration.java Sat Feb 13 19:10:18 2016
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.axiom.om.impl.common.builder;
+
+import org.apache.axiom.om.ds.custombuilder.CustomBuilder;
+import org.apache.axiom.om.ds.custombuilder.CustomBuilder.Selector;
+
+final class CustomBuilderRegistration {
+ private final CustomBuilder.Selector selector;
+ private final CustomBuilder customBuilder;
+
+ CustomBuilderRegistration(Selector selector, CustomBuilder customBuilder) {
+ this.selector = selector;
+ this.customBuilder = customBuilder;
+ }
+
+ CustomBuilder.Selector getSelector() {
+ return selector;
+ }
+
+ CustomBuilder getCustomBuilder() {
+ return customBuilder;
+ }
+}
Propchange: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/CustomBuilderRegistration.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/StAXHelper.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/StAXHelper.java?rev=1730260&r1=1730259&r2=1730260&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/StAXHelper.java (original)
+++ webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/StAXHelper.java Sat Feb 13 19:10:18 2016
@@ -22,15 +22,12 @@ package org.apache.axiom.om.impl.common.
import org.apache.axiom.ext.stax.DTDReader;
import org.apache.axiom.ext.stax.datahandler.DataHandlerReader;
import org.apache.axiom.om.DeferredParsingException;
-import org.apache.axiom.om.OMDataSource;
import org.apache.axiom.om.OMException;
-import org.apache.axiom.om.impl.builder.CustomBuilder;
import org.apache.axiom.om.impl.intf.TextContent;
import org.apache.axiom.om.impl.stream.StreamException;
import org.apache.axiom.om.impl.stream.XmlHandler;
import org.apache.axiom.util.stax.XMLEventUtils;
import org.apache.axiom.util.stax.XMLStreamReaderUtils;
-import org.apache.axiom.util.xml.QNameMap;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -38,7 +35,6 @@ import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamConstants;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
-import javax.xml.namespace.QName;
import java.io.Closeable;
@@ -89,12 +85,6 @@ public class StAXHelper {
private boolean _isClosed = false; // Indicate if parser is closed
- // Fields for Custom Builder implementation
- private final PayloadSelector payloadSelector;
- private CustomBuilder customBuilderForPayload;
- private QNameMap<CustomBuilder> customBuilders;
- private int maxDepthForCustomBuilders = -1;
-
/**
* Reference to the {@link DataHandlerReader} extension of the parser, or <code>null</code> if
* the parser doesn't support this extension.
@@ -110,19 +100,18 @@ public class StAXHelper {
private int lookAheadToken;
public StAXHelper(XMLStreamReader parser, XmlHandler handler, BuilderHandler builderHandler,
- Closeable closeable, boolean autoClose, PayloadSelector payloadSelector) {
+ Closeable closeable, boolean autoClose) {
this.parser = parser;
this.handler = handler;
this.builderHandler = builderHandler;
this.closeable = closeable;
this.autoClose = autoClose;
- this.payloadSelector = payloadSelector;
dataHandlerReader = XMLStreamReaderUtils.getDataHandlerReader(parser);
lookAheadToken = parser.getEventType();
}
public StAXHelper(XMLStreamReader parser, XmlHandler handler) {
- this(parser, handler, null, null, false, PayloadSelector.DEFAULT);
+ this(parser, handler, null, null, false);
}
private static String normalize(String s) {
@@ -172,26 +161,6 @@ public class StAXHelper {
}
}
- public final CustomBuilder registerCustomBuilder(QName qName, int maxDepth, CustomBuilder customBuilder) {
- CustomBuilder old = null;
- if (customBuilders == null) {
- customBuilders = new QNameMap<CustomBuilder>();
- } else {
- old = customBuilders.get(qName);
- }
- maxDepthForCustomBuilders =
- (maxDepthForCustomBuilders > maxDepth) ?
- maxDepthForCustomBuilders: maxDepth;
- customBuilders.put(qName, customBuilder);
- return old;
- }
-
- public final CustomBuilder registerCustomBuilderForPayload(CustomBuilder customBuilder) {
- CustomBuilder old = null;
- this.customBuilderForPayload = customBuilder;
- return old;
- }
-
public final void close() {
try {
if (!isClosed()) {
@@ -315,18 +284,6 @@ public class StAXHelper {
String namespaceURI = normalize(parser.getNamespaceURI());
String localName = parser.getLocalName();
String prefix = normalize(parser.getPrefix());
- if (builderHandler != null) {
- if (customBuilderForPayload != null && payloadSelector.isPayload(builderHandler.depth+1, builderHandler.target)
- && processWithCustomBuilder(customBuilderForPayload)) {
- return;
- }
- if (customBuilders != null && builderHandler.depth < this.maxDepthForCustomBuilders) {
- CustomBuilder customBuilder = customBuilders.get(namespaceURI, localName);
- if (customBuilder != null && processWithCustomBuilder(customBuilder)) {
- return;
- }
- }
- }
handler.startElement(namespaceURI, localName, prefix);
for (int i = 0, count = parser.getNamespaceCount(); i < count; i++) {
handler.processNamespaceDeclaration(
@@ -345,37 +302,6 @@ public class StAXHelper {
handler.attributesCompleted();
}
- private boolean processWithCustomBuilder(CustomBuilder customBuilder) throws StreamException {
-
- String namespace = parser.getNamespaceURI();
- if (namespace == null) {
- namespace = "";
- }
- String localPart = parser.getLocalName();
-
- if (log.isDebugEnabled()) {
- log.debug("Invoking CustomBuilder, " + customBuilder.toString() +
- ", to the OMNode for {" + namespace + "}" + localPart);
- }
-
- OMDataSource ds = customBuilder.create(parser);
- if (ds == null) {
- if (log.isDebugEnabled()) {
- log.debug("The CustomBuilder, " + customBuilder.toString() +
- " did not construct an OMDataSource for {" + namespace + "}" + localPart +
- ". The OMElement will be constructed using the installed stax om builder");
- }
- return false;
- } else {
- if (log.isDebugEnabled()) {
- log.debug("The CustomBuilder, " + customBuilder.toString() +
- "successfully constructed the OMDataSource for {" + namespace + "}" + localPart);
- }
- handler.processOMDataSource(namespace, localPart, ds);
- return true;
- }
- }
-
private void processDTD() throws StreamException {
DTDReader dtdReader;
try {
Modified: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/StAXOMBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/StAXOMBuilder.java?rev=1730260&r1=1730259&r2=1730260&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/StAXOMBuilder.java (original)
+++ webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/StAXOMBuilder.java Sat Feb 13 19:10:18 2016
@@ -25,8 +25,9 @@ import org.apache.axiom.om.OMContainer;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMException;
import org.apache.axiom.om.OMFactory;
-import org.apache.axiom.om.impl.builder.CustomBuilder;
-import org.apache.axiom.om.impl.builder.CustomBuilderSupport;
+import org.apache.axiom.om.ds.custombuilder.CustomBuilder;
+import org.apache.axiom.om.ds.custombuilder.CustomBuilderSupport;
+import org.apache.axiom.om.ds.custombuilder.CustomBuilder.Selector;
import org.apache.axiom.om.impl.builder.Detachable;
import org.apache.axiom.om.impl.intf.AxiomContainer;
import org.apache.axiom.om.impl.intf.AxiomElement;
@@ -36,7 +37,6 @@ import org.apache.commons.logging.LogFac
import javax.xml.stream.XMLStreamConstants;
import javax.xml.stream.XMLStreamReader;
-import javax.xml.namespace.QName;
import java.io.Closeable;
@@ -54,28 +54,30 @@ public class StAXOMBuilder extends Abstr
private boolean parserAccessed = false;
private String charEncoding = null;
+ private CustomBuilderManager customBuilderManager;
+
protected StAXOMBuilder(NodeFactory nodeFactory, XMLStreamReader parser,
- boolean autoClose, Detachable detachable, Closeable closeable, Model model, PayloadSelector payloadSelector,
+ boolean autoClose, Detachable detachable, Closeable closeable, Model model,
AxiomSourcedElement root) {
// TODO: disable namespace repairing for XMLStreamReader created from a parser
super(nodeFactory, model, root, true);
if (parser.getEventType() != XMLStreamReader.START_DOCUMENT) {
throw new IllegalStateException("The XMLStreamReader must be positioned on a START_DOCUMENT event");
}
- helper = new StAXHelper(parser, handler, builderHandler, closeable, autoClose, payloadSelector);
+ helper = new StAXHelper(parser, handler, builderHandler, closeable, autoClose);
this.detachable = detachable;
charEncoding = parser.getEncoding();
}
public StAXOMBuilder(NodeFactory nodeFactory, XMLStreamReader parser, boolean autoClose,
Detachable detachable, Closeable closeable) {
- this(nodeFactory, parser, autoClose, detachable, closeable, PlainXMLModel.INSTANCE, PayloadSelector.DEFAULT, null);
+ this(nodeFactory, parser, autoClose, detachable, closeable, PlainXMLModel.INSTANCE, null);
}
public StAXOMBuilder(NodeFactory nodeFactory,
XMLStreamReader parser,
AxiomSourcedElement element) {
- this(nodeFactory, parser, true, null, null, PlainXMLModel.INSTANCE, PayloadSelector.DEFAULT, element);
+ this(nodeFactory, parser, true, null, null, PlainXMLModel.INSTANCE, element);
}
private void discarded(CoreParentNode container) {
@@ -281,13 +283,13 @@ public class StAXOMBuilder extends Abstr
builderHandler.cache = true;
}
- public final CustomBuilder registerCustomBuilder(QName qName, int maxDepth, CustomBuilder customBuilder) {
- return helper.registerCustomBuilder(qName, maxDepth, customBuilder);
- }
-
-
- public final CustomBuilder registerCustomBuilderForPayload(CustomBuilder customBuilder) {
- return helper.registerCustomBuilderForPayload(customBuilder);
+ @Override
+ public void registerCustomBuilder(Selector selector, CustomBuilder customBuilder) {
+ if (customBuilderManager == null) {
+ customBuilderManager = new CustomBuilderManager();
+ builderHandler.addListener(customBuilderManager);
+ }
+ customBuilderManager.register(selector, customBuilder);
}
public final String getCharsetEncoding() {
@@ -337,7 +339,9 @@ public class StAXOMBuilder extends Abstr
* @throws OMException
*/
public int next() throws OMException {
- return helper.next();
+ int result = helper.next();
+ builderHandler.executeDeferredListenerActions();
+ return result;
}
public final OMElement getDocumentElement() {
Modified: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/soap/impl/common/builder/StAXSOAPModelBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/soap/impl/common/builder/StAXSOAPModelBuilder.java?rev=1730260&r1=1730259&r2=1730260&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/soap/impl/common/builder/StAXSOAPModelBuilder.java (original)
+++ webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/soap/impl/common/builder/StAXSOAPModelBuilder.java Sat Feb 13 19:10:18 2016
@@ -42,8 +42,7 @@ import javax.xml.stream.XMLStreamReader;
public class StAXSOAPModelBuilder extends StAXOMBuilder implements SOAPModelBuilder {
public StAXSOAPModelBuilder(NodeFactory nodeFactory, XMLStreamReader parser,
boolean autoClose, Detachable detachable, Closeable closeable) {
- super(nodeFactory, parser, autoClose, detachable, closeable, new SOAPModel(),
- SOAPPayloadSelector.INSTANCE, null);
+ super(nodeFactory, parser, autoClose, detachable, closeable, new SOAPModel(), null);
// The SOAPFactory instance linked to the SOAPMessage is unknown until we reach the
// SOAPEnvelope. Register a post-processor that does the necessary updates on the
// SOAPMessage.
@@ -51,12 +50,13 @@ public class StAXSOAPModelBuilder extend
private AxiomSOAPMessage message;
@Override
- public void nodeAdded(CoreNode node, int depth) {
+ public Runnable nodeAdded(CoreNode node, int depth) {
if (node instanceof AxiomSOAPMessage) {
message = (AxiomSOAPMessage)node;
} else if (message != null && node instanceof AxiomSOAPEnvelope) {
message.initSOAPFactory((SOAPFactory)((AxiomSOAPEnvelope)node).getOMFactory());
}
+ return null;
}
});
}
Modified: webservices/axiom/trunk/axiom-api/pom.xml
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/axiom-api/pom.xml?rev=1730260&r1=1730259&r2=1730260&view=diff
==============================================================================
--- webservices/axiom/trunk/axiom-api/pom.xml (original)
+++ webservices/axiom/trunk/axiom-api/pom.xml Sat Feb 13 19:10:18 2016
@@ -307,9 +307,6 @@
org.apache.axiom.om.ds.AbstractPullOMDataSource -> org.apache.axiom.om.impl.serialize.StreamingOMSerializer,
<!-- ParserInputStreamDataSource will be deprecated -->
org.apache.axiom.om.ds.ParserInputStreamDataSource$Data -> org.apache.axiom.om.util.CommonUtils,
- <!-- TODO: CustomBuilder should not be in an impl package -->
- org.apache.axiom.om.impl.builder.CustomBuilder -> org.apache.axiom.om.OMDataSource,
- org.apache.axiom.om.impl.builder.CustomBuilder -> org.apache.axiom.om.OMException,
<!-- TODO: Detachable should go to om-aspects -->
org.apache.axiom.om.impl.builder.Detachable -> org.apache.axiom.om.OMException,
<!-- TODO -->
Modified: webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/ext/stax/DelegatingXMLStreamReader.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/ext/stax/DelegatingXMLStreamReader.java?rev=1730260&r1=1730259&r2=1730260&view=diff
==============================================================================
--- webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/ext/stax/DelegatingXMLStreamReader.java (original)
+++ webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/ext/stax/DelegatingXMLStreamReader.java Sat Feb 13 19:10:18 2016
@@ -34,6 +34,8 @@ import javax.xml.stream.XMLStreamReader;
* This interface is used by
* {@link org.apache.axiom.util.stax.XMLStreamReaderUtils#getOriginalXMLStreamReader(XMLStreamReader)}
* to get access to the original parser.
+ *
+ * @deprecated
*/
public interface DelegatingXMLStreamReader extends XMLStreamReader {
XMLStreamReader getParent();
Modified: webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/om/ds/custombuilder/ByteArrayCustomBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/om/ds/custombuilder/ByteArrayCustomBuilder.java?rev=1730260&r1=1730259&r2=1730260&view=diff
==============================================================================
--- webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/om/ds/custombuilder/ByteArrayCustomBuilder.java (original)
+++ webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/om/ds/custombuilder/ByteArrayCustomBuilder.java Sat Feb 13 19:10:18 2016
@@ -22,7 +22,6 @@ package org.apache.axiom.om.ds.custombui
import org.apache.axiom.om.OMDataSource;
import org.apache.axiom.om.OMException;
import org.apache.axiom.om.ds.ByteArrayDataSource;
-import org.apache.axiom.om.impl.builder.CustomBuilder;
import org.apache.axiom.om.impl.serialize.StreamingOMSerializer;
import org.apache.axiom.om.util.StAXUtils;
Copied: webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/om/ds/custombuilder/CustomBuilder.java (from r1730239, webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/CustomBuilder.java)
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/om/ds/custombuilder/CustomBuilder.java?p2=webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/om/ds/custombuilder/CustomBuilder.java&p1=webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/CustomBuilder.java&r1=1730239&r2=1730260&rev=1730260&view=diff
==============================================================================
--- webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/CustomBuilder.java (original)
+++ webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/om/ds/custombuilder/CustomBuilder.java Sat Feb 13 19:10:18 2016
@@ -17,26 +17,68 @@
* under the License.
*/
-package org.apache.axiom.om.impl.builder;
+package org.apache.axiom.om.ds.custombuilder;
+import org.apache.axiom.om.OMContainer;
import org.apache.axiom.om.OMDataSource;
+import org.apache.axiom.om.OMDocument;
import org.apache.axiom.om.OMException;
import org.apache.axiom.om.OMXMLParserWrapper;
+import org.apache.axiom.soap.SOAPBody;
import javax.xml.stream.XMLStreamReader;
/**
- * A Custom Builder is registered on the {@link OMXMLParserWrapper} for a particular QName or payload.
- * When the QName or payload is encountered, the CustomBuilder will build an {@link OMDataSource}
+ * A Custom Builder is registered on the {@link OMXMLParserWrapper} for a particular set of elements.
+ * When a matching element is encountered, the CustomBuilder will build an {@link OMDataSource}
* for the builder.
*
- * @see CustomBuilderSupport#registerCustomBuilder(javax.xml.namespace.QName, int, CustomBuilder)
- * @see CustomBuilderSupport#registerCustomBuilderForPayload(CustomBuilder)
+ * @see CustomBuilderSupport#registerCustomBuilder(Selector, CustomBuilder)
*/
public interface CustomBuilder {
/**
+ * Selects the elements to which a custom builder is applied. Note that this interface may be
+ * implemented by the {@link CustomBuilder} itself.
+ */
+ public interface Selector {
+ /**
+ * Selects the message payload element. For plain XML documents, that is the document
+ * element. For SOAP messages, that is the child element of the SOAP body.
+ */
+ Selector PAYLOAD = new Selector() {
+ @Override
+ public boolean accepts(OMContainer parent, int depth, String namespaceURI, String localName) {
+ // Note: usage of SOAPBody here may create a package cycle, but that cycle could easily
+ // be broken by introducing a marker interface to be extended by SOAPBody.
+ return parent instanceof OMDocument || parent instanceof SOAPBody;
+ }
+ };
+
+ /**
+ * Check if the custom builder registered with this selector should be applied to the given
+ * element. Note that this method will only be invoked for elements that can be represented
+ * as {@link OMSourcedElement} instances in the object model. For plain XML documents this
+ * means every element, but for SOAP messages this restricts the set of elements. E.g. this
+ * method will never be invoked for SOAP faults.
+ *
+ * @param parent
+ * the parent of the {@link OMElement} to be built
+ * @param depth
+ * the depth of the element (with the root element having depth 1)
+ * @param namespaceURI
+ * the namespace URI of the element; never {@code null}
+ * @param localName
+ * the local name of the element; never {@code null}
+ * @return {@code true} if the element should be built as an {@link OMSourcedElement} using
+ * the custom builder registered with this selector, in which case
+ * {@link CustomBuilder#create(XMLStreamReader)} will be called to create the
+ * corresponding {@link OMDataSource}; {@code false} otherwise
+ */
+ boolean accepts(OMContainer parent, int depth, String namespaceURI, String localName);
+ }
+
+ /**
* Create an {@link OMDataSource} for this whole subtree.
- * A null is returned if the default builder behavior should be used.
*
* @param reader
* The stream reader to read the StAX events from. The data read
@@ -63,25 +105,7 @@ public interface CustomBuilder {
* work if the builder was created from an {@link XMLStreamReader}
* implementing the {@link org.apache.axiom.ext.stax.datahandler.DataHandlerReader}
* extension).
- * <p>
- * The implementation MUST NOT assume that <code>reader</code> is the original
- * reader returned by the StAX implementation. In general, it
- * will be a wrapper around the original reader, e.g. one added
- * by the {@link org.apache.axiom.util.stax.dialect.StAXDialect}
- * implementation. If the method requires access to the original
- * parser (e.g. to pass the {@link XMLStreamReader} object to
- * another library that uses some special optimizations for
- * particular parser implementations), it SHOULD use
- * {@link org.apache.axiom.util.stax.XMLStreamReaderUtils#getOriginalXMLStreamReader(XMLStreamReader)}
- * to unwrap the reader. If the method solely relies on the
- * conformance of the reader to the StAX specification, it SHOULD
- * NOT attempt to unwrap it.
- * <p>
- * If the implementation requires both an
- * XOP encoded stream and wants to get access to the original reader, it should invoke
- * {@link org.apache.axiom.util.stax.XMLStreamReaderUtils#getOriginalXMLStreamReader(XMLStreamReader)}
- * after {@link org.apache.axiom.util.stax.xop.XOPUtils#getXOPEncodedStream(XMLStreamReader)}.
- * @return null or OMDataSource
+ * @return OMDataSource
*/
public OMDataSource create(XMLStreamReader reader) throws OMException;
}
Copied: webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/om/ds/custombuilder/CustomBuilderSupport.java (from r1730239, webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/CustomBuilderSupport.java)
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/om/ds/custombuilder/CustomBuilderSupport.java?p2=webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/om/ds/custombuilder/CustomBuilderSupport.java&p1=webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/CustomBuilderSupport.java&r1=1730239&r2=1730260&rev=1730260&view=diff
==============================================================================
--- webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/CustomBuilderSupport.java (original)
+++ webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/om/ds/custombuilder/CustomBuilderSupport.java Sat Feb 13 19:10:18 2016
@@ -16,9 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.axiom.om.impl.builder;
-
-import javax.xml.namespace.QName;
+package org.apache.axiom.om.ds.custombuilder;
/**
* Interface allowing registration of a custom builder. This is a semi-public API used by Axis2; it
@@ -26,21 +24,10 @@ import javax.xml.namespace.QName;
*/
public interface CustomBuilderSupport {
/**
- * Register a CustomBuilder associated with the indicated QName.
- * The CustomBuilder will be used when an element of that qname is encountered.
- * @param qName
- * @param maxDepth indicate the maximum depth that this qname will be found. (root = 0)
- * @param customBuilder
- * @return replaced CustomBuilder or null
- */
- CustomBuilder registerCustomBuilder(QName qName, int maxDepth, CustomBuilder customBuilder);
-
- /**
- * Register a CustomBuilder for a payload.
- * The payload is defined as the elements inside a SOAPBody or the
- * document element of a REST message.
+ * Register a custom builder.
+ *
+ * @param selector specifies the elements to which the custom builder will be applied
* @param customBuilder
- * @return replaced CustomBuilder or null
*/
- CustomBuilder registerCustomBuilderForPayload(CustomBuilder customBuilder);
+ void registerCustomBuilder(CustomBuilder.Selector selector, CustomBuilder customBuilder);
}
Modified: webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/util/stax/XMLStreamReaderUtils.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/util/stax/XMLStreamReaderUtils.java?rev=1730260&r1=1730259&r2=1730260&view=diff
==============================================================================
--- webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/util/stax/XMLStreamReaderUtils.java (original)
+++ webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/util/stax/XMLStreamReaderUtils.java Sat Feb 13 19:10:18 2016
@@ -322,6 +322,8 @@ public class XMLStreamReaderUtils {
* access the original stream reader.
* @param parser XMLStreamReader used by Axiom
* @return original parser
+ * @deprecated As of version 1.3.0, Axiom no longer permits access to the original stream
+ * reader.
*/
public static XMLStreamReader getOriginalXMLStreamReader(XMLStreamReader parser) {
if (log.isDebugEnabled()) {
Modified: webservices/axiom/trunk/implementations/fom-impl/src/main/java/org/apache/abdera/parser/stax/FOMBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/implementations/fom-impl/src/main/java/org/apache/abdera/parser/stax/FOMBuilder.java?rev=1730260&r1=1730259&r2=1730260&view=diff
==============================================================================
--- webservices/axiom/trunk/implementations/fom-impl/src/main/java/org/apache/abdera/parser/stax/FOMBuilder.java (original)
+++ webservices/axiom/trunk/implementations/fom-impl/src/main/java/org/apache/abdera/parser/stax/FOMBuilder.java Sat Feb 13 19:10:18 2016
@@ -30,10 +30,8 @@ import org.apache.axiom.core.CoreNode;
import org.apache.axiom.fom.AbderaNode;
import org.apache.axiom.fom.impl.FOMNodeFactory;
import org.apache.axiom.om.OMException;
-import org.apache.axiom.om.OMSerializable;
import org.apache.axiom.om.impl.builder.Detachable;
import org.apache.axiom.om.impl.common.builder.BuilderListener;
-import org.apache.axiom.om.impl.common.builder.PayloadSelector;
import org.apache.axiom.om.impl.common.builder.StAXOMBuilder;
@SuppressWarnings("unchecked")
@@ -44,13 +42,14 @@ public class FOMBuilder extends StAXOMBu
public FOMBuilder(final FOMFactory factory, XMLStreamReader parser, ParserOptions parserOptions) {
super(FOMNodeFactory.INSTANCE, new FOMStAXFilter(parser, parserOptions), false, (Detachable)null, (Closeable)null,
- factory, PayloadSelector.DEFAULT, null);
+ factory, null);
this.parserOptions = parserOptions;
this.fomfactory = factory;
addListener(new BuilderListener() {
@Override
- public void nodeAdded(CoreNode node, int depth) {
+ public Runnable nodeAdded(CoreNode node, int depth) {
((AbderaNode)node).setFactory(factory);
+ return null;
}
});
}
Modified: webservices/axiom/trunk/src/site/markdown/release-notes/1.3.0.md
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/src/site/markdown/release-notes/1.3.0.md?rev=1730260&r1=1730259&r2=1730260&view=diff
==============================================================================
--- webservices/axiom/trunk/src/site/markdown/release-notes/1.3.0.md (original)
+++ webservices/axiom/trunk/src/site/markdown/release-notes/1.3.0.md Sat Feb 13 19:10:18 2016
@@ -55,6 +55,14 @@ Changes in this release
* Elements no longer store line number information, and the corresponding
methods on the `OMElement` interface have been deprecated.
-* The `CustomBuilder` API has changed in an incompatible way. Note that this
- API was designed to enable some very specific optimizations in Axis2, so
- that this change should have limited impact.
+* The `CustomBuilder` and `CustomBuilderSupport` interfaces have changed in
+ an incompatible way. Note that this API was designed to enable some very
+ specific optimizations in Axis2, so that this change should have limited
+ impact.
+
+ In addition to the interface changes, the API no longer gives access to the
+ raw `XMLStreamReader` returned by the StAX implementation. That feature was
+ originally introduced to allow negotiation of additional optimizations
+ between proprietary StAX and JAXB implementations from a particular vendor.
+ That feature is no longer necessary and has been removed to allow a
+ simplification of the builder design.
Modified: webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/JAXBCustomBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/JAXBCustomBuilder.java?rev=1730260&r1=1730259&r2=1730260&view=diff
==============================================================================
--- webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/JAXBCustomBuilder.java (original)
+++ webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/JAXBCustomBuilder.java Sat Feb 13 19:10:18 2016
@@ -19,8 +19,6 @@
package org.apache.axiom.ts.om.builder;
-import static org.junit.Assert.assertTrue;
-
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
@@ -31,19 +29,17 @@ import javax.xml.stream.XMLStreamWriter;
import org.apache.axiom.om.OMDataSource;
import org.apache.axiom.om.OMException;
import org.apache.axiom.om.ds.AbstractPushOMDataSource;
-import org.apache.axiom.om.impl.builder.CustomBuilder;
+import org.apache.axiom.om.ds.custombuilder.CustomBuilder;
import org.apache.axiom.util.stax.xop.XOPEncodedStream;
import org.apache.axiom.util.stax.xop.XOPUtils;
public class JAXBCustomBuilder implements CustomBuilder {
private final JAXBContext jaxbContext;
- private final boolean expectBareReader;
private Object jaxbObject;
private boolean attachmentsAccessed;
- public JAXBCustomBuilder(JAXBContext jaxbContext, boolean expectBareReader) {
+ public JAXBCustomBuilder(JAXBContext jaxbContext) {
this.jaxbContext = jaxbContext;
- this.expectBareReader = expectBareReader;
}
public OMDataSource create(XMLStreamReader reader)
@@ -53,11 +49,6 @@ public class JAXBCustomBuilder implement
final String localName = reader.getLocalName();
XOPEncodedStream xopStream = XOPUtils.getXOPEncodedStream(reader);
XMLStreamReader encodedReader = xopStream.getReader();
- if (expectBareReader) {
- String className = encodedReader.getClass().getName();
- assertTrue(!className.startsWith("org.apache.axiom.")
- || className.startsWith("org.apache.axiom.util.stax.dialect."));
- }
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
AttachmentUnmarshallerImpl attachmentUnmarshaller = new AttachmentUnmarshallerImpl(xopStream.getMimePartProvider());
unmarshaller.setAttachmentUnmarshaller(attachmentUnmarshaller);
Modified: webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/RegisterCustomBuilderForPayloadJAXBTestCase.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/RegisterCustomBuilderForPayloadJAXBTestCase.java?rev=1730260&r1=1730259&r2=1730260&view=diff
==============================================================================
--- webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/RegisterCustomBuilderForPayloadJAXBTestCase.java (original)
+++ webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/RegisterCustomBuilderForPayloadJAXBTestCase.java Sat Feb 13 19:10:18 2016
@@ -27,7 +27,8 @@ import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMMetaFactory;
import org.apache.axiom.om.OMXMLParserWrapper;
-import org.apache.axiom.om.impl.builder.CustomBuilderSupport;
+import org.apache.axiom.om.ds.custombuilder.CustomBuilder;
+import org.apache.axiom.om.ds.custombuilder.CustomBuilderSupport;
import org.apache.axiom.testutils.io.IOTestUtils;
import org.apache.axiom.ts.AxiomTestCase;
@@ -48,9 +49,9 @@ public abstract class RegisterCustomBuil
return document;
}
- protected final void test(DataHandler dh, OMXMLParserWrapper builder, boolean same, boolean usesAttachments, boolean expectBareReader) throws Exception {
- JAXBCustomBuilder customBuilder = new JAXBCustomBuilder(JAXBContext.newInstance(MyDocument.class), expectBareReader);
- ((CustomBuilderSupport)builder).registerCustomBuilderForPayload(customBuilder);
+ protected final void test(DataHandler dh, OMXMLParserWrapper builder, boolean same, boolean usesAttachments) throws Exception {
+ JAXBCustomBuilder customBuilder = new JAXBCustomBuilder(JAXBContext.newInstance(MyDocument.class));
+ ((CustomBuilderSupport)builder).registerCustomBuilder(CustomBuilder.Selector.PAYLOAD, customBuilder);
builder.getDocumentElement().build();
MyDocument myDocument = (MyDocument)customBuilder.getJaxbObject();
if (same) {
Modified: webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/TestRegisterCustomBuilderForPayloadJAXBPlain.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/TestRegisterCustomBuilderForPayloadJAXBPlain.java?rev=1730260&r1=1730259&r2=1730260&view=diff
==============================================================================
--- webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/TestRegisterCustomBuilderForPayloadJAXBPlain.java (original)
+++ webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/TestRegisterCustomBuilderForPayloadJAXBPlain.java Sat Feb 13 19:10:18 2016
@@ -41,6 +41,6 @@ public class TestRegisterCustomBuilderFo
OutputStream out = blob.getOutputStream();
createTestDocument(dh).serialize(out);
out.close();
- test(dh, OMXMLBuilderFactory.createOMBuilder(metaFactory.getOMFactory(), blob.getInputStream()), false, false, true);
+ test(dh, OMXMLBuilderFactory.createOMBuilder(metaFactory.getOMFactory(), blob.getInputStream()), false, false);
}
}
Modified: webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/TestRegisterCustomBuilderForPayloadJAXBWithDataHandlerReaderExtension.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/TestRegisterCustomBuilderForPayloadJAXBWithDataHandlerReaderExtension.java?rev=1730260&r1=1730259&r2=1730260&view=diff
==============================================================================
--- webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/TestRegisterCustomBuilderForPayloadJAXBWithDataHandlerReaderExtension.java (original)
+++ webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/TestRegisterCustomBuilderForPayloadJAXBWithDataHandlerReaderExtension.java Sat Feb 13 19:10:18 2016
@@ -35,6 +35,6 @@ public class TestRegisterCustomBuilderFo
protected void runTest() throws Throwable {
DataHandler dh = new DataHandler(new TestDataSource('X', Integer.MAX_VALUE));
OMElement document = createTestDocument(dh);
- test(dh, OMXMLBuilderFactory.createStAXOMBuilder(metaFactory.getOMFactory(), document.getXMLStreamReader()), true, true, false);
+ test(dh, OMXMLBuilderFactory.createStAXOMBuilder(metaFactory.getOMFactory(), document.getXMLStreamReader()), true, true);
}
}
Modified: webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/TestRegisterCustomBuilderForPayloadJAXBWithXOP.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/TestRegisterCustomBuilderForPayloadJAXBWithXOP.java?rev=1730260&r1=1730259&r2=1730260&view=diff
==============================================================================
--- webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/TestRegisterCustomBuilderForPayloadJAXBWithXOP.java (original)
+++ webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/TestRegisterCustomBuilderForPayloadJAXBWithXOP.java Sat Feb 13 19:10:18 2016
@@ -47,6 +47,6 @@ public class TestRegisterCustomBuilderFo
createTestDocument(dh).serialize(out, format);
out.close();
Attachments attachments = new Attachments(blob.getInputStream(), format.getContentType());
- test(dh, OMXMLBuilderFactory.createOMBuilder(metaFactory.getOMFactory(), StAXParserConfiguration.DEFAULT, attachments), false, true, true);
+ test(dh, OMXMLBuilderFactory.createOMBuilder(metaFactory.getOMFactory(), StAXParserConfiguration.DEFAULT, attachments), false, true);
}
}
Modified: webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/body/FirstElementNameWithParserTestCase.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/body/FirstElementNameWithParserTestCase.java?rev=1730260&r1=1730259&r2=1730260&view=diff
==============================================================================
--- webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/body/FirstElementNameWithParserTestCase.java (original)
+++ webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/body/FirstElementNameWithParserTestCase.java Sat Feb 13 19:10:18 2016
@@ -29,8 +29,8 @@ import org.apache.axiom.om.OMDataSource;
import org.apache.axiom.om.OMException;
import org.apache.axiom.om.OMMetaFactory;
import org.apache.axiom.om.OMXMLBuilderFactory;
-import org.apache.axiom.om.impl.builder.CustomBuilder;
-import org.apache.axiom.om.impl.builder.CustomBuilderSupport;
+import org.apache.axiom.om.ds.custombuilder.CustomBuilder;
+import org.apache.axiom.om.ds.custombuilder.CustomBuilderSupport;
import org.apache.axiom.soap.SOAPBody;
import org.apache.axiom.soap.SOAPEnvelope;
import org.apache.axiom.soap.SOAPModelBuilder;
@@ -60,7 +60,7 @@ public abstract class FirstElementNameWi
if (supportsOptimization) {
// To detect if the child element is instantiated or not, we register a custom
// builder that throws an exception.
- ((CustomBuilderSupport)builder).registerCustomBuilderForPayload(new CustomBuilder() {
+ ((CustomBuilderSupport)builder).registerCustomBuilder(CustomBuilder.Selector.PAYLOAD, new CustomBuilder() {
public OMDataSource create(XMLStreamReader reader) throws OMException {
throw new AssertionFailedError("Custom builder called.");
}
Modified: webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/builder/TestRegisterCustomBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/builder/TestRegisterCustomBuilder.java?rev=1730260&r1=1730259&r2=1730260&view=diff
==============================================================================
--- webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/builder/TestRegisterCustomBuilder.java (original)
+++ webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/builder/TestRegisterCustomBuilder.java Sat Feb 13 19:10:18 2016
@@ -20,11 +20,11 @@ package org.apache.axiom.ts.soap.builder
import java.util.ArrayList;
-import javax.xml.namespace.QName;
-
+import org.apache.axiom.om.OMContainer;
import org.apache.axiom.om.OMMetaFactory;
import org.apache.axiom.om.ds.custombuilder.ByteArrayCustomBuilder;
-import org.apache.axiom.om.impl.builder.CustomBuilderSupport;
+import org.apache.axiom.om.ds.custombuilder.CustomBuilder;
+import org.apache.axiom.om.ds.custombuilder.CustomBuilderSupport;
import org.apache.axiom.soap.SOAPHeader;
import org.apache.axiom.soap.SOAPHeaderBlock;
import org.apache.axiom.soap.SOAPModelBuilder;
@@ -41,7 +41,15 @@ public class TestRegisterCustomBuilder e
@Override
protected void runTest() throws Throwable {
SOAPModelBuilder builder = SOAPSampleSet.WSA.getMessage(spec).getAdapter(SOAPSampleAdapter.class).getBuilder(metaFactory);
- ((CustomBuilderSupport)builder).registerCustomBuilder(new QName("http://www.w3.org/2005/08/addressing", "To"), 3,
+ ((CustomBuilderSupport)builder).registerCustomBuilder(
+ new CustomBuilder.Selector() {
+ @Override
+ public boolean accepts(OMContainer parent, int depth, String namespaceURI, String localName) {
+ return depth == 3
+ && namespaceURI.equals("http://www.w3.org/2005/08/addressing")
+ && localName.equals("To");
+ }
+ },
new ByteArrayCustomBuilder("utf-8"));
SOAPHeader header = builder.getSOAPEnvelope().getHeader();
ArrayList al = header.getHeaderBlocksWithNSURI("http://www.w3.org/2005/08/addressing");
Modified: webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/builder/TestRegisterCustomBuilderForPayload.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/builder/TestRegisterCustomBuilderForPayload.java?rev=1730260&r1=1730259&r2=1730260&view=diff
==============================================================================
--- webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/builder/TestRegisterCustomBuilderForPayload.java (original)
+++ webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/builder/TestRegisterCustomBuilderForPayload.java Sat Feb 13 19:10:18 2016
@@ -33,7 +33,8 @@ import org.apache.axiom.om.OMSourcedElem
import org.apache.axiom.om.ds.ByteArrayDataSource;
import org.apache.axiom.om.ds.ByteArrayDataSource.ByteArray;
import org.apache.axiom.om.ds.custombuilder.ByteArrayCustomBuilder;
-import org.apache.axiom.om.impl.builder.CustomBuilderSupport;
+import org.apache.axiom.om.ds.custombuilder.CustomBuilder;
+import org.apache.axiom.om.ds.custombuilder.CustomBuilderSupport;
import org.apache.axiom.soap.SOAPFault;
import org.apache.axiom.soap.SOAPModelBuilder;
import org.apache.axiom.ts.AxiomTestCase;
@@ -53,7 +54,7 @@ public class TestRegisterCustomBuilderFo
@Override
protected void runTest() throws Throwable {
SOAPModelBuilder builder = message.getAdapter(SOAPSampleAdapter.class).getBuilder(metaFactory);
- ((CustomBuilderSupport)builder).registerCustomBuilderForPayload(new ByteArrayCustomBuilder("utf-8") {
+ ((CustomBuilderSupport)builder).registerCustomBuilder(CustomBuilder.Selector.PAYLOAD, new ByteArrayCustomBuilder("utf-8") {
@Override
public OMDataSource create(XMLStreamReader reader) throws OMException {
if (reader.getName().equals(message.getSOAPSpec().getFaultQName())) {
Modified: webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/builder/TestRegisterCustomBuilderForPayloadAfterSOAPFaultCheck.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/builder/TestRegisterCustomBuilderForPayloadAfterSOAPFaultCheck.java?rev=1730260&r1=1730259&r2=1730260&view=diff
==============================================================================
--- webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/builder/TestRegisterCustomBuilderForPayloadAfterSOAPFaultCheck.java (original)
+++ webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/builder/TestRegisterCustomBuilderForPayloadAfterSOAPFaultCheck.java Sat Feb 13 19:10:18 2016
@@ -22,8 +22,8 @@ import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMMetaFactory;
import org.apache.axiom.om.OMSourcedElement;
import org.apache.axiom.om.ds.custombuilder.ByteArrayCustomBuilder;
-import org.apache.axiom.om.impl.builder.CustomBuilder;
-import org.apache.axiom.om.impl.builder.CustomBuilderSupport;
+import org.apache.axiom.om.ds.custombuilder.CustomBuilder;
+import org.apache.axiom.om.ds.custombuilder.CustomBuilderSupport;
import org.apache.axiom.soap.SOAPBody;
import org.apache.axiom.soap.SOAPEnvelope;
import org.apache.axiom.soap.SOAPModelBuilder;
@@ -52,7 +52,7 @@ public class TestRegisterCustomBuilderFo
// Do the registration here...this simulates when it could occure in the engine
// (After the fault check and during phase processing...probably dispatch phase)
- ((CustomBuilderSupport)builder).registerCustomBuilderForPayload(new ByteArrayCustomBuilder("utf-8"));
+ ((CustomBuilderSupport)builder).registerCustomBuilder(CustomBuilder.Selector.PAYLOAD, new ByteArrayCustomBuilder("utf-8"));
OMElement bodyElement = envelope.getBody().getFirstElement();
assertTrue(bodyElement instanceof OMSourcedElement);
Modified: webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap11/misc/TestElementPullStreamAndOMExpansion.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap11/misc/TestElementPullStreamAndOMExpansion.java?rev=1730260&r1=1730259&r2=1730260&view=diff
==============================================================================
--- webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap11/misc/TestElementPullStreamAndOMExpansion.java (original)
+++ webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap11/misc/TestElementPullStreamAndOMExpansion.java Sat Feb 13 19:10:18 2016
@@ -28,7 +28,8 @@ import org.apache.axiom.om.OMSourcedElem
import org.apache.axiom.om.OMXMLBuilderFactory;
import org.apache.axiom.om.OMXMLParserWrapper;
import org.apache.axiom.om.ds.custombuilder.ByteArrayCustomBuilder;
-import org.apache.axiom.om.impl.builder.CustomBuilderSupport;
+import org.apache.axiom.om.ds.custombuilder.CustomBuilder;
+import org.apache.axiom.om.ds.custombuilder.CustomBuilderSupport;
import org.apache.axiom.om.impl.serialize.StreamingOMSerializer;
import org.apache.axiom.om.util.StAXUtils;
import org.apache.axiom.soap.SOAPBody;
@@ -58,7 +59,7 @@ public class TestElementPullStreamAndOME
ByteArrayCustomBuilder customBuilder = new ByteArrayCustomBuilder("utf-8");
// Register the custom builder on the builder so that they body payload is stored as bytes
- ((CustomBuilderSupport)builder).registerCustomBuilderForPayload(customBuilder);
+ ((CustomBuilderSupport)builder).registerCustomBuilder(CustomBuilder.Selector.PAYLOAD, customBuilder);
// Create an output stream
Modified: webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap11/misc/TestElementPullStreamAndOMExpansion2.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap11/misc/TestElementPullStreamAndOMExpansion2.java?rev=1730260&r1=1730259&r2=1730260&view=diff
==============================================================================
--- webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap11/misc/TestElementPullStreamAndOMExpansion2.java (original)
+++ webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap11/misc/TestElementPullStreamAndOMExpansion2.java Sat Feb 13 19:10:18 2016
@@ -28,7 +28,8 @@ import org.apache.axiom.om.OMSourcedElem
import org.apache.axiom.om.OMXMLBuilderFactory;
import org.apache.axiom.om.OMXMLParserWrapper;
import org.apache.axiom.om.ds.custombuilder.ByteArrayCustomBuilder;
-import org.apache.axiom.om.impl.builder.CustomBuilderSupport;
+import org.apache.axiom.om.ds.custombuilder.CustomBuilder;
+import org.apache.axiom.om.ds.custombuilder.CustomBuilderSupport;
import org.apache.axiom.om.impl.serialize.StreamingOMSerializer;
import org.apache.axiom.om.util.StAXUtils;
import org.apache.axiom.soap.SOAPBody;
@@ -58,7 +59,7 @@ public class TestElementPullStreamAndOME
ByteArrayCustomBuilder customBuilder = new ByteArrayCustomBuilder("utf-8");
// Register the custom builder on the builder so that they body payload is stored as bytes
- ((CustomBuilderSupport)builder).registerCustomBuilderForPayload(customBuilder);
+ ((CustomBuilderSupport)builder).registerCustomBuilder(CustomBuilder.Selector.PAYLOAD, customBuilder);
// Create an output stream
Modified: webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap11/misc/TestElementPullStreamAndOMExpansion3.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap11/misc/TestElementPullStreamAndOMExpansion3.java?rev=1730260&r1=1730259&r2=1730260&view=diff
==============================================================================
--- webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap11/misc/TestElementPullStreamAndOMExpansion3.java (original)
+++ webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap11/misc/TestElementPullStreamAndOMExpansion3.java Sat Feb 13 19:10:18 2016
@@ -28,7 +28,8 @@ import org.apache.axiom.om.OMSourcedElem
import org.apache.axiom.om.OMXMLBuilderFactory;
import org.apache.axiom.om.OMXMLParserWrapper;
import org.apache.axiom.om.ds.custombuilder.ByteArrayCustomBuilder;
-import org.apache.axiom.om.impl.builder.CustomBuilderSupport;
+import org.apache.axiom.om.ds.custombuilder.CustomBuilder;
+import org.apache.axiom.om.ds.custombuilder.CustomBuilderSupport;
import org.apache.axiom.om.impl.serialize.StreamingOMSerializer;
import org.apache.axiom.om.util.StAXUtils;
import org.apache.axiom.soap.SOAPBody;
@@ -58,7 +59,7 @@ public class TestElementPullStreamAndOME
ByteArrayCustomBuilder customBuilder = new ByteArrayCustomBuilder("utf-8");
// Register the custom builder on the builder so that they body payload is stored as bytes
- ((CustomBuilderSupport)builder).registerCustomBuilderForPayload(customBuilder);
+ ((CustomBuilderSupport)builder).registerCustomBuilder(CustomBuilder.Selector.PAYLOAD, customBuilder);
// Create an output stream