Author: scheu
Date: Mon Feb 4 13:46:24 2008
New Revision: 618452
URL: http://svn.apache.org/viewvc?rev=618452&view=rev
Log:
WSCOMMONS-301
Contributor:Rich Scheuerle
Quick Fix and test for OMSourcedElement.buildWithAttachments() to avoid
unnecessary expansion.
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java
webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/OMSourcedElementTest.java
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java?rev=618452&r1=618451&r2=618452&view=diff
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java
(original)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java
Mon Feb 4 13:46:24 2008
@@ -920,13 +920,23 @@
* @see org.apache.axiom.om.OMNode#buildAll()
*/
public void buildWithAttachments() {
+
+ // If not done, force the parser to build the elements
if (!done) {
this.build();
}
- Iterator iterator = getChildren();
- while (iterator.hasNext()) {
- OMNode node = (OMNode) iterator.next();
- node.buildWithAttachments();
+
+ // If the OMSourcedElement is in in expanded form, then
+ // walk the descendents to make sure they are built.
+ // If the OMSourcedElement is backed by a OMDataSource,
+ // we don't want to walk the children (because this will result
+ // in an unnecessary translation from OMDataSource to a full OM tree).
+ if (isExpanded()) {
+ Iterator iterator = getChildren();
+ while (iterator.hasNext()) {
+ OMNode node = (OMNode) iterator.next();
+ node.buildWithAttachments();
+ }
}
}
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/OMSourcedElementTest.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/OMSourcedElementTest.java?rev=618452&r1=618451&r2=618452&view=diff
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/OMSourcedElementTest.java
(original)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/OMSourcedElementTest.java
Mon Feb 4 13:46:24 2008
@@ -123,6 +123,13 @@
output.indexOf(payload1) > 0);
assertTrue("OMSourcedElement is expanded. This is unexpected",
!child.isExpanded());
+ // If a consumer calls build or buildWithAttachments on the tree, the
+ // tree should not be expanded.
+ soapBody.build();
+ assertTrue("OMSourcedElement is expanded after build(). This is
unexpected", !child.isExpanded());
+ soapBody.buildWithAttachments();
+ assertTrue("OMSourcedElement is expanded after buildWithAttachments().
This is unexpected", !child.isExpanded());
+
// Test getting the raw bytes from the ByteArrayDataSource.
OMDataSourceExt ds = (OMDataSourceExt) child.getDataSource();
byte[] bytes = ds.getXMLBytes("UTF-16"); // Get the bytes as UTF-16
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]