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 2015/08/05 00:21:45 UTC
svn commit: r1694118 - in /webservices/axiom/trunk:
aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/
aspects/om-aspects/src/main/java/org/apache/axiom/soap/impl/common/
implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/d...
Author: veithen
Date: Tue Aug 4 22:21:44 2015
New Revision: 1694118
URL: http://svn.apache.org/r1694118
Log:
Eliminate duplicate code in the OMDocument implementations.
Added:
webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/soap/impl/common/AxiomSOAPMessageSupport.aj (with props)
Removed:
webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/OMDocumentHelper.java
Modified:
webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomDocumentSupport.aj
webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentImpl.java
webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/SOAPMessageImpl.java
webservices/axiom/trunk/implementations/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMDocumentImpl.java
webservices/axiom/trunk/implementations/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPMessageImpl.java
Modified: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomDocumentSupport.aj
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomDocumentSupport.aj?rev=1694118&r1=1694117&r2=1694118&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomDocumentSupport.aj (original)
+++ webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomDocumentSupport.aj Tue Aug 4 22:21:44 2015
@@ -19,9 +19,59 @@
package org.apache.axiom.om.impl.common;
import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMNode;
+import org.apache.axiom.om.OMOutputFormat;
+import org.apache.axiom.om.impl.common.serializer.push.OutputException;
+import org.apache.axiom.om.impl.common.serializer.push.Serializer;
public aspect AxiomDocumentSupport {
public final OMElement AxiomDocument.getOMDocumentElement() {
return (OMElement)coreGetDocumentElement();
}
+
+ public final void AxiomDocument.setOMDocumentElement(OMElement documentElement) {
+ if (documentElement == null) {
+ throw new IllegalArgumentException("documentElement must not be null");
+ }
+ OMElement existingDocumentElement = getOMDocumentElement();
+ if (existingDocumentElement == null) {
+ addChild(documentElement);
+ } else {
+ OMNode nextSibling = existingDocumentElement.getNextOMSibling();
+ existingDocumentElement.detach();
+ if (nextSibling == null) {
+ addChild(documentElement);
+ } else {
+ nextSibling.insertSiblingBefore(documentElement);
+ }
+ }
+ }
+
+ public final void AxiomDocument.internalSerialize(Serializer serializer, OMOutputFormat format, boolean cache) throws OutputException {
+ internalSerialize(serializer, format, cache, !format.isIgnoreXMLDeclaration());
+ }
+
+ // Overridden in AxiomSOAPMessageSupport
+ public void AxiomDocument.internalSerialize(Serializer serializer, OMOutputFormat format,
+ boolean cache, boolean includeXMLDeclaration) throws OutputException {
+ if (includeXMLDeclaration) {
+ //Check whether the OMOutput char encoding and OMDocument char
+ //encoding matches, if not use char encoding of OMOutput
+ String encoding = format.getCharSetEncoding();
+ if (encoding == null || "".equals(encoding)) {
+ encoding = getCharsetEncoding();
+ }
+ String version = getXMLVersion();
+ if (version == null) {
+ version = "1.0";
+ }
+ if (encoding == null) {
+ serializer.writeStartDocument(version);
+ } else {
+ serializer.writeStartDocument(encoding, version);
+ }
+ }
+ serializer.serializeChildren(this, format, cache);
+ serializer.writeEndDocument();
+ }
}
Added: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/soap/impl/common/AxiomSOAPMessageSupport.aj
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/soap/impl/common/AxiomSOAPMessageSupport.aj?rev=1694118&view=auto
==============================================================================
--- webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/soap/impl/common/AxiomSOAPMessageSupport.aj (added)
+++ webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/soap/impl/common/AxiomSOAPMessageSupport.aj Tue Aug 4 22:21:44 2015
@@ -0,0 +1,32 @@
+/*
+ * 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.soap.impl.common;
+
+import org.apache.axiom.om.OMOutputFormat;
+import org.apache.axiom.om.impl.common.AxiomElement;
+import org.apache.axiom.om.impl.common.serializer.push.OutputException;
+import org.apache.axiom.om.impl.common.serializer.push.Serializer;
+
+public aspect AxiomSOAPMessageSupport {
+ // TODO: this violates OO design principles and should disappear in a future Axiom version
+ public final void AxiomSOAPMessage.internalSerialize(Serializer serializer, OMOutputFormat format,
+ boolean cache, boolean includeXMLDeclaration) throws OutputException {
+ ((AxiomElement)getOMDocumentElement()).internalSerialize(serializer, format, cache);
+ }
+}
Propchange: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/soap/impl/common/AxiomSOAPMessageSupport.aj
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentImpl.java?rev=1694118&r1=1694117&r2=1694118&view=diff
==============================================================================
--- webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentImpl.java (original)
+++ webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentImpl.java Tue Aug 4 22:21:44 2015
@@ -31,12 +31,8 @@ import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMException;
import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMNode;
-import org.apache.axiom.om.OMOutputFormat;
import org.apache.axiom.om.impl.common.AxiomDocument;
-import org.apache.axiom.om.impl.common.OMDocumentHelper;
import org.apache.axiom.om.impl.common.OMNamespaceImpl;
-import org.apache.axiom.om.impl.common.serializer.push.OutputException;
-import org.apache.axiom.om.impl.common.serializer.push.Serializer;
import org.w3c.dom.Attr;
import org.w3c.dom.Comment;
import org.w3c.dom.DOMException;
@@ -69,10 +65,6 @@ public class DocumentImpl extends Parent
super(factory);
}
- public void internalSerialize(Serializer serializer, OMOutputFormat format, boolean cache) throws OutputException {
- internalSerialize(serializer, format, cache, !format.isIgnoreXMLDeclaration());
- }
-
// /org.w3c.dom.Document methods
// /
@@ -263,24 +255,6 @@ public class DocumentImpl extends Parent
this.charEncoding = charsetEncoding;
}
- public void setOMDocumentElement(OMElement documentElement) {
- if (documentElement == null) {
- throw new IllegalArgumentException("documentElement must not be null");
- }
- OMElement existingDocumentElement = getOMDocumentElement();
- if (existingDocumentElement == null) {
- addChild(documentElement);
- } else {
- OMNode nextSibling = existingDocumentElement.getNextOMSibling();
- existingDocumentElement.detach();
- if (nextSibling == null) {
- addChild(documentElement);
- } else {
- nextSibling.insertSiblingBefore(documentElement);
- }
- }
- }
-
public void setStandalone(String isStandalone) {
this.xmlStandalone = "yes".equalsIgnoreCase(isStandalone);
}
@@ -381,11 +355,6 @@ public class DocumentImpl extends Parent
setXMLVersion(version);
}
- protected void internalSerialize(Serializer serializer, OMOutputFormat format,
- boolean cache, boolean includeXMLDeclaration) throws OutputException {
- OMDocumentHelper.internalSerialize(this, serializer, format, cache, includeXMLDeclaration);
- }
-
ParentNode shallowClone(OMCloneOptions options, ParentNode targetParent, boolean namespaceRepairing) {
DocumentImpl clone;
if (options.isPreserveModel()) {
Modified: webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/SOAPMessageImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/SOAPMessageImpl.java?rev=1694118&r1=1694117&r2=1694118&view=diff
==============================================================================
--- webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/SOAPMessageImpl.java (original)
+++ webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/SOAPMessageImpl.java Tue Aug 4 22:21:44 2015
@@ -22,10 +22,6 @@ package org.apache.axiom.soap.impl.dom;
import org.apache.axiom.om.OMCloneOptions;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMException;
-import org.apache.axiom.om.OMOutputFormat;
-import org.apache.axiom.om.impl.common.AxiomElement;
-import org.apache.axiom.om.impl.common.serializer.push.OutputException;
-import org.apache.axiom.om.impl.common.serializer.push.Serializer;
import org.apache.axiom.om.impl.dom.DocumentImpl;
import org.apache.axiom.soap.SOAPEnvelope;
import org.apache.axiom.soap.SOAPFactory;
@@ -51,11 +47,6 @@ public class SOAPMessageImpl extends Doc
}
}
- protected void internalSerialize(Serializer serializer, OMOutputFormat format,
- boolean cache, boolean includeXMLDeclaration) throws OutputException {
- ((AxiomElement)getDocumentElement()).internalSerialize(serializer, format, cache);
- }
-
protected DocumentImpl createClone(OMCloneOptions options) {
return new SOAPMessageImpl((SOAPFactory)getOMFactory());
}
Modified: webservices/axiom/trunk/implementations/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMDocumentImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/implementations/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMDocumentImpl.java?rev=1694118&r1=1694117&r2=1694118&view=diff
==============================================================================
--- webservices/axiom/trunk/implementations/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMDocumentImpl.java (original)
+++ webservices/axiom/trunk/implementations/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMDocumentImpl.java Tue Aug 4 22:21:44 2015
@@ -26,11 +26,7 @@ import org.apache.axiom.om.OMException;
import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMInformationItem;
import org.apache.axiom.om.OMNode;
-import org.apache.axiom.om.OMOutputFormat;
import org.apache.axiom.om.impl.common.AxiomDocument;
-import org.apache.axiom.om.impl.common.OMDocumentHelper;
-import org.apache.axiom.om.impl.common.serializer.push.OutputException;
-import org.apache.axiom.om.impl.common.serializer.push.Serializer;
import java.util.Iterator;
@@ -55,24 +51,6 @@ public class OMDocumentImpl extends OMSe
super(factory);
}
- public void setOMDocumentElement(OMElement documentElement) {
- if (documentElement == null) {
- throw new IllegalArgumentException("documentElement must not be null");
- }
- OMElement existingDocumentElement = getOMDocumentElement();
- if (existingDocumentElement == null) {
- addChild(documentElement);
- } else {
- OMNode nextSibling = existingDocumentElement.getNextOMSibling();
- existingDocumentElement.detach();
- if (nextSibling == null) {
- addChild(documentElement);
- } else {
- nextSibling.insertSiblingBefore(documentElement);
- }
- }
- }
-
public void setComplete(boolean complete) {
coreSetState(complete ? COMPLETE : INCOMPLETE);
}
@@ -122,15 +100,6 @@ public class OMDocumentImpl extends OMSe
this.xmlEncoding = encoding;
}
- public void internalSerialize(Serializer serializer, OMOutputFormat format, boolean cache) throws OutputException {
- internalSerialize(serializer, format, cache, !format.isIgnoreXMLDeclaration());
- }
-
- protected void internalSerialize(Serializer serializer, OMOutputFormat format,
- boolean cache, boolean includeXMLDeclaration) throws OutputException {
- OMDocumentHelper.internalSerialize(this, serializer, format, cache, includeXMLDeclaration);
- }
-
void notifyChildComplete() {
if (getState() == INCOMPLETE && getBuilder() == null) {
Iterator iterator = getChildren();
Modified: webservices/axiom/trunk/implementations/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPMessageImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/implementations/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPMessageImpl.java?rev=1694118&r1=1694117&r2=1694118&view=diff
==============================================================================
--- webservices/axiom/trunk/implementations/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPMessageImpl.java (original)
+++ webservices/axiom/trunk/implementations/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPMessageImpl.java Tue Aug 4 22:21:44 2015
@@ -23,11 +23,7 @@ import org.apache.axiom.om.OMCloneOption
import org.apache.axiom.om.OMDocument;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMException;
-import org.apache.axiom.om.OMOutputFormat;
-import org.apache.axiom.om.impl.common.serializer.push.OutputException;
-import org.apache.axiom.om.impl.common.serializer.push.Serializer;
import org.apache.axiom.om.impl.llom.OMDocumentImpl;
-import org.apache.axiom.om.impl.llom.OMNodeImpl;
import org.apache.axiom.soap.SOAPEnvelope;
import org.apache.axiom.soap.SOAPFactory;
import org.apache.axiom.soap.SOAPProcessingException;
@@ -52,11 +48,6 @@ public class SOAPMessageImpl extends OMD
}
}
- protected void internalSerialize(Serializer serializer, OMOutputFormat format,
- boolean cache, boolean includeXMLDeclaration) throws OutputException {
- ((OMNodeImpl)getOMDocumentElement()).internalSerialize(serializer, format, cache);
- }
-
protected OMDocument createClone(OMCloneOptions options) {
// Note: we need to use getOMFactory here (instead of the factory attribute)
// directly because the factory for a SOAPMessage may be determined lazily.