Author: veithen
Date: Fri May 14 20:27:29 2010
New Revision: 944448
URL: http://svn.apache.org/viewvc?rev=944448&view=rev
Log:
WSCOMMONS-518: Generalized the getOMAttachmentAccessorXMLStreamReader method so
that XMLStreamReader wrappers of arbitrary type can be looked up; this also
removes the dependency on the core Axiom API and breaks cyclic package
dependencies.
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/util/stax/XMLStreamReaderUtils.java
webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/mtom/MTOMStAXSOAPModelBuilderTest.java
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/util/stax/XMLStreamReaderUtils.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/util/stax/XMLStreamReaderUtils.java?rev=944448&r1=944447&r2=944448&view=diff
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/util/stax/XMLStreamReaderUtils.java
(original)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/util/stax/XMLStreamReaderUtils.java
Fri May 14 20:27:29 2010
@@ -26,7 +26,6 @@ import javax.xml.stream.XMLStreamReader;
import org.apache.axiom.attachments.ByteArrayDataSource;
import org.apache.axiom.ext.stax.datahandler.DataHandlerReader;
-import org.apache.axiom.om.OMAttachmentAccessor;
import org.apache.axiom.util.base64.Base64Utils;
import org.apache.axiom.util.stax.wrapper.XMLStreamReaderContainer;
import org.apache.commons.logging.Log;
@@ -143,17 +142,22 @@ public class XMLStreamReaderUtils {
}
/**
- * Searches the wrapper and delegate classes to find an XMLStreamReader
- * that implements the OMAttachmentAccessor
+ * Searches the wrapper and delegate classes to find an
+ * {...@link XMLStreamReader} of a given type.
+ *
* @param parser
- * @return XMLStreamREader that implements OMAttachmentAccessor or null
+ * the object to extract the wrapped reader from
+ * @param type
+ * the type of reader to search for
+ * @return the first {...@link XMLStreamReader} of the given type in the
chain
+ * of wrappers, or <code>null</code> if no such reader was found
*/
- public static XMLStreamReader
getOMAttachmentAccessorXMLStreamReader(XMLStreamReader parser) {
+ public static XMLStreamReader getWrappedXMLStreamReader(XMLStreamReader
parser, Class type) {
if (log.isDebugEnabled()) {
String clsName = (parser != null) ? parser.getClass().toString() :
"null";
- log.debug("Entry getOMAttachmentAccessorXMLStreamReader: " +
clsName);
+ log.debug("Entry getWrappedXMLStreamReader: " + clsName);
}
- while (!(parser instanceof OMAttachmentAccessor) &&
+ while (!type.isInstance(parser) &&
(parser instanceof XMLStreamReaderContainer)) {
parser = ((XMLStreamReaderContainer) parser).getParent();
if (log.isDebugEnabled()) {
@@ -161,12 +165,12 @@ public class XMLStreamReaderUtils {
log.debug(" parent: " + clsName);
}
}
- if (!(parser instanceof OMAttachmentAccessor)) {
+ if (!type.isInstance(parser)) {
parser = null;
}
if (log.isDebugEnabled()) {
String clsName = (parser != null) ? parser.getClass().toString() :
"null";
- log.debug("Exit getOMAttachmentAccessorXMLStreamReader: " +
clsName);
+ log.debug("Exit getWrappedXMLStreamReader: " + clsName);
}
return parser;
}
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/mtom/MTOMStAXSOAPModelBuilderTest.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/mtom/MTOMStAXSOAPModelBuilderTest.java?rev=944448&r1=944447&r2=944448&view=diff
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/mtom/MTOMStAXSOAPModelBuilderTest.java
(original)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/mtom/MTOMStAXSOAPModelBuilderTest.java
Fri May 14 20:27:29 2010
@@ -115,7 +115,7 @@ public class MTOMStAXSOAPModelBuilderTes
// The streaming parser will not have access to the attachments. Thus
this will
// return null
XMLStreamReader attachmentAccessor =
-
XMLStreamReaderUtils.getOMAttachmentAccessorXMLStreamReader(reader);
+ XMLStreamReaderUtils.getWrappedXMLStreamReader(reader,
OMAttachmentAccessor.class);
assertTrue(attachmentAccessor == null);
@@ -131,7 +131,7 @@ public class MTOMStAXSOAPModelBuilderTes
assertTrue(original instanceof OMStAXWrapper);
XMLStreamReader attachmentAccessor =
-
XMLStreamReaderUtils.getOMAttachmentAccessorXMLStreamReader(reader);
+ XMLStreamReaderUtils.getWrappedXMLStreamReader(reader,
OMAttachmentAccessor.class);
// Thus the attachmentAccessor should also be the OMStaXWrapper
assertTrue(attachmentAccessor instanceof OMStAXWrapper);