You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by sc...@apache.org on 2006/07/11 21:33:22 UTC

svn commit: r420955 [4/8] - in /webservices/axis2/trunk/java/modules/jaxws: ./ src/javax/jws/ src/javax/xml/ws/handler/ src/org/apache/axis2/jaxws/ src/org/apache/axis2/jaxws/binding/ src/org/apache/axis2/jaxws/client/ src/org/apache/axis2/jaxws/core/ ...

Added: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/XMLPartBase.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/XMLPartBase.java?rev=420955&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/XMLPartBase.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/XMLPartBase.java Tue Jul 11 12:33:12 2006
@@ -0,0 +1,347 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ * Copyright 2006 International Business Machines Corp.
+ *
+ * Licensed 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.axis2.jaxws.message.impl;
+
+import javax.xml.namespace.QName;
+import javax.xml.soap.SOAPEnvelope;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.soap.SOAP11Constants;
+import org.apache.axiom.soap.SOAP12Constants;
+import org.apache.axis2.jaxws.message.Block;
+import org.apache.axis2.jaxws.message.MessageException;
+import org.apache.axis2.jaxws.message.MessageInternalException;
+import org.apache.axis2.jaxws.message.Protocol;
+import org.apache.axis2.jaxws.message.XMLPart;
+import org.apache.axis2.jaxws.message.factory.BlockFactory;
+
+/**
+ * XMLPartBase class for an XMLPart
+ * An XMLPart is an abstraction of the xml portion of the message.
+ * The actual representation can be in one of three different forms:
+ *    * An OM tree
+ *    * A SAAJ SOAPEnvelope
+ *    * An XMLSpine (an optimized representation of the message)
+ * The representation is stored in the private variable (content)
+ * 
+ * The representation changes as the Message flows through the JAX-WS 
+ * framework.  For example, here is a typical flow on the inbound case:
+ *    a) Message is built from OM                           (representation: OM)
+ *    b) Message flows into SOAP Handler chain              (representation: OM->SOAPEnvelope)
+ *    c) Message flows out of the SOAP Handler chain 
+ *    d) Message flows into the logical dispatch processing (representation: SOAPEnvelope->XMLSpine)
+ * 
+ * The key to performance is the implementation of the transformations between 
+ * OM, SAAJ SOAPEnvelope and XMLSpine.   This base class defines all of the methods
+ * that are required on an XMLPart, the actual transformations are provided by the 
+ * derived class.  This division of work allows the derived class to concentrate on the
+ * optimization of the transformations.  For example, the derived class may implement
+ * XMLSpine -> OM using OMObjectWrapperElement constructs...thus avoid expensive parsing.
+ * 
+ * Here are the methods that the derived XMLPart should implement. 
+ *   OMElement _convertSE2OM(SOAPEnvelope se)
+ *   OMElement _convertSpine2OM(XMLSpine spine)
+ *   SOAPEnvelope _convertOM2SE(OMElement om)
+ *   SOAPEnvelope _convertSpine2SE(XMLSpine spine)
+ *   XMLSpine _convertOM2Spine(OMElement om)
+ *   XMLSpine _convertSE2Spine(SOAPEnvelope se)
+ *   XMLSpine _createSpine(Protocol protocol)
+ * 
+ * @see org.apache.axis2.jaxws.message.XMLPart
+ * @see org.apache.axis2.jaxws.message.impl.XMLPartImpl
+ * 
+ */
+public abstract class XMLPartBase implements XMLPart {
+
+	Protocol protocol = Protocol.unknown;  // Protocol defaults to unknown
+	
+	// The actual xml representation is always one of the following
+	//   OM if the content is an OM tree
+	//   SOAPENVELOPE if the content is a SOAPEnvelope
+	//   SPINE if the content is a OM "spine" + Blocks
+	Object content = null;
+	int contentType = UNKNOWN;
+	
+	static final int UNKNOWN = 0;
+	static final int OM = 1;
+	static final int SOAPENVELOPE = 2;
+	static final int SPINE = 3;
+	boolean consumed = false;
+	
+	
+	/**
+	 * XMLPart should be constructed via the XMLPartFactory.
+	 * This constructor constructs an empty XMLPart with the specified protocol
+	 * @param protocol
+	 * @throws MessageException
+	 */
+	XMLPartBase(Protocol protocol) throws MessageException {
+		super();
+		this.protocol = protocol;
+		if (protocol.equals(Protocol.unknown)) {
+			// TODO NLS
+			throw new MessageException("Protocol unknown is not supported");
+		} else if (protocol.equals(Protocol.rest)) {
+			// TODO NLS
+			throw new MessageException("Protocol rest is not supported");
+		}
+		content = _createSpine(protocol);
+		contentType = SPINE;
+	}
+	
+	/**
+	 * XMLPart should be constructed via the XMLPartFactory.
+	 * This constructor creates an XMLPart from the specified root.
+	 * @param root
+	 * @throws MessageException
+	 */
+	XMLPartBase(OMElement root) throws MessageException {
+		content = root;
+		contentType = OM;
+		QName qName = root.getQName();
+		if (qName.getNamespaceURI().equals(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI)) {
+			protocol = Protocol.soap11;
+		} else if (qName.getNamespaceURI().equals(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI)) {
+			protocol = Protocol.soap12;
+		} else {
+			throw new MessageException("Protocol rest is not supported");
+		}
+	}
+	
+	private void setContent(Object content, int contentType) {
+		this.content = content;
+		this.contentType = contentType;
+	}
+	
+	private OMElement getContentAsOMElement() throws MessageException {
+		OMElement om = null;
+		switch (contentType) {
+		case (OM):
+		 	om = (OMElement) content;
+			break;
+		case (SPINE):
+			om = _convertSpine2OM((XMLSpine) content);
+			break;
+		case (SOAPENVELOPE):
+			om = _convertSE2OM((SOAPEnvelope) content);
+			break;
+		default:
+			// TODO NLS
+			throw new MessageInternalException("Unknown type");
+		}
+		setContent(om, OM);
+		return om;
+	}
+		
+	private SOAPEnvelope getContentAsSOAPEnvelope() throws MessageException {
+		SOAPEnvelope se = null;
+		switch (contentType) {
+		case (SOAPENVELOPE):
+		 	se = (SOAPEnvelope) content;
+			break;
+		case (SPINE):
+			se = _convertSpine2SE((XMLSpine) content);
+			break;
+		case (OM):
+			se = _convertOM2SE((OMElement) content);
+			break;
+		default:
+			// TODO NLS
+			throw new MessageInternalException("Unknown type");
+		}
+		setContent(se, SOAPENVELOPE);
+		return se;
+	}
+	
+	private XMLSpine getContentAsXMLSpine() throws MessageException {
+		XMLSpine spine = null;
+		switch (contentType) {
+		case (SPINE):
+		 	spine = (XMLSpine) content;
+			break;
+		case (SOAPENVELOPE):
+			spine = _convertSE2Spine((SOAPEnvelope) content);
+			break;
+		case (OM):
+			spine = _convertOM2Spine((OMElement) content);
+			break;
+		default:
+			// TODO NLS
+			throw new MessageInternalException("Unknown type");
+		}
+		setContent(spine, SPINE);
+		return spine;
+	}
+	
+	public OMElement getAsOMElement() throws MessageException {
+		return getContentAsOMElement();
+	}
+
+	public SOAPEnvelope getAsSOAPEnvelope() throws MessageException {
+		return getContentAsSOAPEnvelope();
+	}
+
+	public Protocol getProtocol() {
+		return protocol;
+	}
+
+	public XMLStreamReader getXMLStreamReader(boolean consume) throws MessageException {
+		if (consumed) {
+			// TODO NLS
+			throw new MessageException("Already consumed");
+		}
+		XMLStreamReader reader = null;
+		if (contentType == SPINE) {
+			reader = getContentAsXMLSpine().getXMLStreamReader(consume);
+		} else {
+			OMElement omElement = getContentAsOMElement();
+			if (consume) {
+				reader = omElement.getXMLStreamReaderWithoutCaching();
+			} else {
+				reader = omElement.getXMLStreamReader();
+			}
+		}
+		consumed = consume;
+		return reader;
+	}
+
+	public boolean isConsumed() {
+		return consumed;
+	}
+
+	public void outputTo(XMLStreamWriter writer, boolean consume) throws XMLStreamException, MessageException {
+		if (consumed) {
+			// TODO NLS
+			throw new MessageException("Already consumed");
+		}
+		if (contentType == SPINE) {
+			getContentAsXMLSpine().outputTo(writer, consume);
+		} else {
+			OMElement omElement = getContentAsOMElement();
+			if (consume) {
+				omElement.serializeAndConsume(writer);
+			} else {
+				omElement.serialize(writer);
+			}
+		}
+		consumed = consume;
+		return;
+		
+	}
+
+	public String traceString(String indent) {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	public Block getBodyBlock(int index, Object context, BlockFactory blockFactory) throws MessageException {
+		return getContentAsXMLSpine().getBodyBlock(index, context, blockFactory);
+	}
+
+	public Block getHeaderBlock(String namespace, String localPart, Object context, BlockFactory blockFactory) throws MessageException {
+		return getContentAsXMLSpine().getHeaderBlock(namespace, localPart, context, blockFactory);
+	}
+
+	public int getNumBodyBlocks() throws MessageException {
+		return getContentAsXMLSpine().getNumBodyBlocks();
+	}
+
+	public int getNumHeaderBlocks() throws MessageException {
+		return getContentAsXMLSpine().getNumHeaderBlocks();
+	}
+
+	public void removeBodyBlock(int index) throws MessageException {
+		getContentAsXMLSpine().removeBodyBlock(index);
+	}
+
+	public void removeHeaderBlock(String namespace, String localPart) throws MessageException {
+		getContentAsXMLSpine().removeHeaderBlock(namespace, localPart);
+	}
+
+	public void setBodyBlock(int index, Block block) throws MessageException {
+		getContentAsXMLSpine().setBodyBlock(index, block);
+	}
+
+	public void setHeaderBlock(String namespace, String localPart, Block block) throws MessageException {
+		getContentAsXMLSpine().setHeaderBlock(namespace, localPart, block);
+	}
+
+	/**
+	 * Convert SOAPEnvelope into an OM tree
+	 * @param se SOAPEnvelope
+	 * @return OM
+	 * @throws MessageException
+	 */
+	protected abstract OMElement _convertSE2OM(SOAPEnvelope se) throws MessageException;
+	
+	/**
+	 * Convert XMLSpine into an OM tree
+	 * @param spine XMLSpine
+	 * @return OM
+	 * @throws MessageException
+	 */
+	protected abstract OMElement _convertSpine2OM(XMLSpine spine) throws MessageException;
+	
+	/**
+	 * Convert OM tree into a SOAPEnvelope
+	 * @param om
+	 * @return SOAPEnvelope
+	 * @throws MessageException
+	 */
+	protected abstract SOAPEnvelope _convertOM2SE(OMElement om) throws MessageException;
+	
+	/**
+	 * Convert XMLSpine into a SOAPEnvelope
+	 * @param spine
+	 * @return SOAPEnvelope
+	 * @throws MessageException
+	 */
+	protected abstract SOAPEnvelope _convertSpine2SE(XMLSpine spine) throws MessageException;
+	
+	/**
+	 * Convert OM into XMLSpine
+	 * @param om
+	 * @return
+	 * @throws MessageException
+	 */
+	protected abstract XMLSpine _convertOM2Spine(OMElement om) throws MessageException;
+	
+	/**
+	 * Convert SOAPEnvelope into XMLSPine
+	 * @param SOAPEnvelope
+	 * @return XMLSpine
+	 * @throws MessageException
+	 */
+	protected abstract XMLSpine _convertSE2Spine(SOAPEnvelope se) throws MessageException;
+	
+	/**
+	 * Create an empty, default spine for the specificed protocol
+	 * @param protocol
+	 * @return 
+	 * @throws MessageException
+	 */
+	protected XMLSpine _createSpine(Protocol protocol) throws MessageException {
+		// Default implementation is to simply construct the spine. 
+		// Devived classes may wish to construct a different kind of XMLSpine
+		return new XMLSpineImpl(protocol);
+	}
+	
+	
+}

Added: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/XMLPartFactoryImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/XMLPartFactoryImpl.java?rev=420955&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/XMLPartFactoryImpl.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/XMLPartFactoryImpl.java Tue Jul 11 12:33:12 2006
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ * Copyright 2006 International Business Machines Corp.
+ *
+ * Licensed 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.axis2.jaxws.message.impl;
+
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder;
+import org.apache.axis2.jaxws.message.MessageException;
+import org.apache.axis2.jaxws.message.Protocol;
+import org.apache.axis2.jaxws.message.XMLPart;
+import org.apache.axis2.jaxws.message.factory.XMLPartFactory;
+
+/**
+ * MessageFactoryImpl
+ */
+public class XMLPartFactoryImpl implements XMLPartFactory {
+
+	/**
+	 * Default Constructor required for Factory 
+	 */
+	public XMLPartFactoryImpl() {
+		super();
+	}
+
+	/* (non-Javadoc)
+	 * @see org.apache.axis2.jaxws.message.factory.XMLPartFactory#createFrom(javax.xml.stream.XMLStreamReader)
+	 */
+	public XMLPart createFrom(XMLStreamReader reader) throws XMLStreamException, MessageException {
+		StAXSOAPModelBuilder builder = new StAXSOAPModelBuilder(reader, null);  // Pass null has the version to trigger autodetection
+		SOAPEnvelope omEnvelope = builder.getSOAPEnvelope();
+		return createFrom(omEnvelope);
+	}
+
+	/* (non-Javadoc)
+	 * @see org.apache.axis2.jaxws.message.MessageFactory#createFrom(org.apache.axiom.om.OMElement)
+	 */
+	public XMLPart createFrom(OMElement omElement) throws XMLStreamException, MessageException {
+		return new XMLPartImpl(omElement);
+	}
+
+	/* (non-Javadoc)
+	 * @see org.apache.axis2.jaxws.message.MessageFactory#create(org.apache.axis2.jaxws.message.Protocol)
+	 */
+	public XMLPart create(Protocol protocol) throws XMLStreamException, MessageException {
+		return new XMLPartImpl(protocol);
+	}
+
+}

Added: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/XMLPartImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/XMLPartImpl.java?rev=420955&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/XMLPartImpl.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/XMLPartImpl.java Tue Jul 11 12:33:12 2006
@@ -0,0 +1,117 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ * Copyright 2006 International Business Machines Corp.
+ *
+ * Licensed 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.axis2.jaxws.message.impl;
+
+import javax.xml.soap.SOAPEnvelope;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder;
+import org.apache.axis2.jaxws.message.MessageException;
+import org.apache.axis2.jaxws.message.Protocol;
+import org.apache.axis2.jaxws.message.factory.SAAJConverterFactory;
+import org.apache.axis2.jaxws.message.util.SAAJConverter;
+import org.apache.axis2.jaxws.registry.FactoryRegistry;
+
+/**
+ * XMLPartImpl
+ * 
+ * This class extends the implementation of the XMLPartBase so that it 
+ * can define the transformations between OM, SAAJ SOAPEnvelope and XMLSpine.
+ * @see org.apache.axis2.jaxws.impl.XMLPartBase
+ * 
+ */
+public class XMLPartImpl extends  XMLPartBase {
+
+	SAAJConverter converter = null;
+	
+	/**
+	 * XMLPart should be constructed via the XMLPartFactory.
+	 * This constructor constructs an empty XMLPart with the specified protocol
+	 * @param protocol
+	 * @throws MessageException
+	 */
+	XMLPartImpl(Protocol protocol) throws MessageException {
+		super(protocol);
+	}
+	
+	/**
+	 * XMLPart should be constructed via the XMLPartFactory.
+	 * This constructor creates an XMLPart from the specified root.
+	 * @param root
+	 * @throws MessageException
+	 */
+	XMLPartImpl(OMElement root) throws MessageException {
+		super(root);
+	}
+	
+	@Override
+	protected OMElement _convertSE2OM(SOAPEnvelope se) throws MessageException {
+		return getSAAJConverter().toOM(se);
+	}
+
+	@Override
+	protected OMElement _convertSpine2OM(XMLSpine spine) throws MessageException {
+		// Get an XMLStreamReader that consumes the spine object
+		XMLStreamReader reader = spine.getXMLStreamReader(true);
+		// Get a SOAP OM Builder.  Passing null causes the version to be automatically triggered
+		StAXSOAPModelBuilder builder = new StAXSOAPModelBuilder(reader, null);  
+		// Create and return the OM Envelope
+		org.apache.axiom.soap.SOAPEnvelope omEnvelope = builder.getSOAPEnvelope();
+		return omEnvelope;
+	}
+
+	@Override
+	protected SOAPEnvelope _convertOM2SE(OMElement om) throws MessageException {
+		return getSAAJConverter().toSAAJ((org.apache.axiom.soap.SOAPEnvelope) om);
+	}
+
+	@Override
+	protected SOAPEnvelope _convertSpine2SE(XMLSpine spine) throws MessageException {
+		return _convertOM2SE(_convertSpine2OM(spine));
+	}
+
+	@Override
+	protected XMLSpine _convertOM2Spine(OMElement om) throws MessageException {
+		return new XMLSpineImpl((org.apache.axiom.soap.SOAPEnvelope) om);
+	}
+
+	@Override
+	protected XMLSpine _convertSE2Spine(SOAPEnvelope se) throws MessageException {
+		return _convertOM2Spine(_convertSE2OM(se));
+	}
+
+	@Override
+	protected XMLSpine _createSpine(Protocol protocol) throws MessageException {
+		// Use the default implementation provided in XMLPartBase
+		return super._createSpine(protocol);
+	}
+	
+	/**
+	 * Load the SAAJConverter
+	 * @return SAAJConverter
+	 */
+	protected SAAJConverter getSAAJConverter() {
+		if (converter == null) {
+			SAAJConverterFactory factory = (
+						SAAJConverterFactory)FactoryRegistry.getFactory(SAAJConverterFactory.class);
+			converter = factory.getSAAJConverter();
+		}
+		return converter;
+	}
+	
+}

Added: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/XMLPartOptimizedImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/XMLPartOptimizedImpl.java?rev=420955&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/XMLPartOptimizedImpl.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/XMLPartOptimizedImpl.java Tue Jul 11 12:33:12 2006
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ * Copyright 2006 International Business Machines Corp.
+ *
+ * Licensed 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.axis2.jaxws.message.impl;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axis2.jaxws.message.MessageException;
+import org.apache.axis2.jaxws.message.Protocol;
+
+/**
+ * XMLPartOptimizedImpl
+ * 
+ * This class extends the implementation of the XMLPartBase so that it 
+ * can define the transformations between OM, SAAJ SOAPEnvelope and XMLSpine.
+ * 
+ * This class uses OMObjectWrapperElement constructs to speed up the transformations.
+ * 
+ * @see org.apache.axis2.jaxws.impl.XMLPartBase
+ * 
+ */
+public class XMLPartOptimizedImpl extends  XMLPartImpl {
+
+	// TODO Add custom transformations that take advantage of OMObjectWrapperElement
+	
+	/**
+	 * XMLPart should be constructed via the XMLPartFactory.
+	 * This constructor constructs an empty XMLPart with the specified protocol
+	 * @param protocol
+	 * @throws MessageException
+	 */
+	XMLPartOptimizedImpl(Protocol protocol) throws MessageException {
+		super(protocol);
+	}
+	
+	/**
+	 * XMLPart should be constructed via the XMLPartFactory.
+	 * This constructor creates an XMLPart from the specified root.
+	 * @param root
+	 * @throws MessageException
+	 */
+	XMLPartOptimizedImpl(OMElement root) throws MessageException {
+		super(root);
+	}
+	
+}

Added: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/XMLSpine.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/XMLSpine.java?rev=420955&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/XMLSpine.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/XMLSpine.java Tue Jul 11 12:33:12 2006
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ * Copyright 2006 International Business Machines Corp.
+ *
+ * Licensed 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.axis2.jaxws.message.impl;
+
+import org.apache.axis2.jaxws.message.XMLPart;
+
+/**
+ * XMLSpine
+ * 
+ * An XMLSpine is an optimized form of the xml part of the message.
+ * Currently there is only one implementation (XMLSpineImpl).
+ * @see org.apache.axis2.jaxws.message.impl.XMLSpineImpl for more details
+ *
+ */
+interface XMLSpine extends XMLPart {
+
+}

Added: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/XMLSpineImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/XMLSpineImpl.java?rev=420955&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/XMLSpineImpl.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/XMLSpineImpl.java Tue Jul 11 12:33:12 2006
@@ -0,0 +1,316 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ * Copyright 2006 International Business Machines Corp.
+ *
+ * Licensed 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.axis2.jaxws.message.impl;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMNode;
+import org.apache.axiom.soap.SOAP11Constants;
+import org.apache.axiom.soap.SOAP12Constants;
+import org.apache.axiom.soap.SOAPBody;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.soap.SOAPFactory;
+import org.apache.axiom.soap.SOAPHeader;
+import org.apache.axiom.soap.impl.llom.soap11.SOAP11Factory;
+import org.apache.axis2.jaxws.message.Block;
+import org.apache.axis2.jaxws.message.MessageException;
+import org.apache.axis2.jaxws.message.MessageInternalException;
+import org.apache.axis2.jaxws.message.Protocol;
+import org.apache.axis2.jaxws.message.factory.BlockFactory;
+import org.apache.axis2.jaxws.message.factory.OMBlockFactory;
+import org.apache.axis2.jaxws.message.util.Reader2Writer;
+import org.apache.axis2.jaxws.registry.FactoryRegistry;
+
+/**
+ * XMLSpineImpl
+ * 
+ * An XMLSpine consists of an OM SOAPEnvelope which defines the "spine" of the message
+ * (i.e. the SOAPEnvelope element, the SOAPHeader element, the SOAPBody element and
+ * perhaps the SOAPFault element).  The real payload portions of the message are 
+ * contained in Block object (headerBlocks, bodyBlocks, detailBlocks).
+ * 
+ * This "shortened" OM tree allows the JAX-WS implementation to process the message
+ * without creating fully populated OM trees.
+ *
+ */
+class XMLSpineImpl implements XMLSpine {
+	
+	private static OMBlockFactory obf = (OMBlockFactory) FactoryRegistry.getFactory(OMBlockFactory.class);
+	
+	private Protocol protocol = Protocol.unknown;
+	private SOAPEnvelope root = null;
+	private SOAPFactory soapFactory = null;
+	private List<Block> headerBlocks = new ArrayList<Block>();
+	private List<Block> bodyBlocks   = new ArrayList<Block>();
+	private List<Block> detailBlocks = new ArrayList<Block>();
+	private boolean consumed = false;
+	private Iterator bodyIterator = null;
+
+	/**
+	 * Create a lightweight representation of this protocol
+	 * (i.e. the Envelope, Header and Body)
+	 */
+	public XMLSpineImpl(Protocol protocol) {
+		super();
+		this.protocol = protocol;
+		soapFactory = getFactory(protocol);
+		root = createEmptyEnvelope(protocol, soapFactory);
+	}
+	
+	/**
+	 * Create spine from an existing OM tree
+	 * @param envelope
+	 * @throws MessageException
+	 */
+	public XMLSpineImpl(SOAPEnvelope envelope) throws MessageException {
+		super();
+		init(envelope);
+		if (root.getNamespace().getName().equals(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI)) {
+			protocol = Protocol.soap11;
+		} else if (root.getNamespace().getName().equals(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI)) {
+			protocol = Protocol.soap12;
+		} else {
+			// TODO NLS
+			throw new MessageInternalException("unrecognized protocol");
+		}
+	} 
+
+	private void init(SOAPEnvelope envelope) throws MessageException {
+		root = envelope;
+		headerBlocks.clear();
+		bodyBlocks.clear();
+		detailBlocks.clear();
+		bodyIterator = null;
+		
+		
+		// Create an OMBlock for each header element
+		// This advances the StAX parser past the header end tag
+		SOAPHeader header = root.getHeader();
+		Iterator it = header.getChildren();
+		advanceIterator(it, headerBlocks, true);
+		
+		SOAPBody body = root.getBody();
+		if (!body.hasFault()) {
+			// Normal processing
+			// Only create the first body block, this ensures that the StAX 
+			// cursor is not advanced beyond the tag of the first element
+			bodyIterator = body.getChildren();
+			advanceIterator(bodyIterator, bodyBlocks, false);
+		} else {
+			// Process the Fault
+			// TODO NLS
+			throw new MessageException("Not Implemented Yet");
+		}
+		return;
+	}
+	
+	/**
+	 * Utility method to advance the iterator and populate the blocks
+	 * @param it Iterator
+	 * @param blocks List<Block> to update
+	 * @param toEnd if true, iterator is advanced to the end, otherwise it is advanced one Element
+	 * @throws MessageException
+	 */
+	private  void advanceIterator(Iterator it, List<Block> blocks, boolean toEnd) throws MessageException {
+		
+		// TODO This code must be reworked.  The OM Iterator causes the entire OMElement to be 
+		// parsed when it.next() is invoked.  I will need to fix this to gain performance.  (scheu)
+		
+		boolean found = false;
+		boolean first = true;
+		while (it.hasNext() && (!found && !toEnd)) {
+			// Remove the nodes as they are converted into blocks
+			if (!first) {
+				it.remove();
+			}
+			first = true;
+			
+			OMNode node = (OMNode) it.next();
+			if (node instanceof OMElement) {
+				// Elements are converted into Blocks
+				Block block = null;
+				try { 
+					block = obf.createFrom((OMElement) node, null, null);
+				} catch (XMLStreamException xse) {
+					throw new MessageException(xse);
+				}
+				blocks.add(block);
+			} else {
+				// Non-elements are ignored
+			}
+		}
+	}
+	
+	private static SOAPFactory getFactory(Protocol protocol) {
+		SOAPFactory soapFactory;
+		if (protocol == Protocol.soap11) {
+			soapFactory = new SOAP11Factory();
+		} else if (protocol == Protocol.soap12) {
+			soapFactory = new SOAP11Factory();
+		} else {
+			// TODO NLS
+			throw new MessageInternalException("unsupported protocol");
+		}
+		return soapFactory;
+	}
+	private static SOAPEnvelope createEmptyEnvelope(Protocol protocol, SOAPFactory factory) {
+		SOAPEnvelope env = factory.createSOAPEnvelope();
+		// Add an empty body and header
+		factory.createSOAPBody(env);
+		factory.createSOAPHeader(env);
+
+		return env;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.apache.axis2.jaxws.message.XMLPart#getProtocol()
+	 */
+	public Protocol getProtocol() {
+		return protocol;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.apache.axis2.jaxws.message.XMLPart#outputTo(javax.xml.stream.XMLStreamWriter, boolean)
+	 */
+	public void outputTo(XMLStreamWriter writer, boolean consume) throws XMLStreamException, MessageException {
+		Reader2Writer r2w = new Reader2Writer(getXMLStreamReader(consume));
+		r2w.outputTo(writer);
+	}
+
+	public XMLStreamReader getXMLStreamReader(boolean consume) throws MessageException {
+		return new XMLStreamReaderForXMLSpine(root, protocol,
+					headerBlocks, bodyBlocks, detailBlocks, consume);
+	}
+
+	public boolean isConsumed() {
+		return consumed;
+	}
+
+	public javax.xml.soap.SOAPEnvelope getAsSOAPEnvelope() throws MessageException {
+		// TODO NLS
+		throw new MessageInternalException("Should never be called");
+	}
+
+	public OMElement getAsOMElement() throws MessageException {
+		// TODO NLS
+		throw new MessageInternalException("Should never be called");
+	}
+
+	/* (non-Javadoc)
+	 * @see org.apache.axis2.jaxws.message.XMLPart#getNumBodyBlocks()
+	 */
+	public int getNumBodyBlocks() throws MessageException {
+		if (bodyIterator != null) {
+			advanceIterator(bodyIterator, bodyBlocks, true);
+		}
+		return bodyBlocks.size();
+	}
+
+	public Block getBodyBlock(int index, Object context, BlockFactory blockFactory) throws MessageException {
+		if (index >= bodyBlocks.size() && bodyIterator != null) {
+			advanceIterator(bodyIterator, bodyBlocks, true);
+		}
+		try {
+			Block oldBlock = bodyBlocks.get(index);
+		
+			// Convert to new Block
+			Block newBlock = blockFactory.createFrom(oldBlock, blockFactory);
+			if (newBlock != oldBlock) {
+				bodyBlocks.set(index, newBlock);
+			}
+			return newBlock;
+		} catch (XMLStreamException xse) {
+			throw new MessageException(xse);
+		}
+	}
+
+	public void setBodyBlock(int index, Block block) throws MessageException {
+		if (index >= bodyBlocks.size() && bodyIterator != null) {
+			advanceIterator(bodyIterator, bodyBlocks, true);
+		}
+		bodyBlocks.add(index, block);
+	}
+
+	public void removeBodyBlock(int index) throws MessageException {
+		if (index >= bodyBlocks.size() && bodyIterator != null) {
+			advanceIterator(bodyIterator, bodyBlocks, true);
+		}
+		bodyBlocks.remove(index);
+	}
+
+	public int getNumHeaderBlocks() throws MessageException {
+		return headerBlocks.size();
+	}
+
+	public Block getHeaderBlock(String namespace, String localPart, Object context, BlockFactory blockFactory) throws MessageException {
+		int index = getHeaderBlockIndex(namespace, localPart);
+		try {
+			Block oldBlock = bodyBlocks.get(index);
+		
+			// Convert to new Block
+			Block newBlock = blockFactory.createFrom(oldBlock, blockFactory);
+			if (newBlock != oldBlock) {
+				headerBlocks.set(index, newBlock);
+			}
+			return newBlock;
+		} catch (XMLStreamException xse) {
+			throw new MessageException(xse);
+		}
+	}
+
+	public void setHeaderBlock(String namespace, String localPart, Block block) throws MessageException {
+		int index = getHeaderBlockIndex(namespace, localPart);
+		headerBlocks.set(index, block);
+	}
+
+	/**
+	 * Utility method to locate header block
+	 * @param namespace
+	 * @param localPart
+	 * @return index of header block or -1
+	 * @throws MessageException
+	 */
+	private int getHeaderBlockIndex(String namespace, String localPart) throws MessageException {
+		for (int i=0; i<headerBlocks.size(); i++) {
+			Block block = headerBlocks.get(i);
+			QName qName = block.getQName();
+			if (qName.getNamespaceURI().equals(namespace) &&
+				qName.getLocalPart().equals(localPart)) {
+				return i;
+			}
+		}
+		return -1;
+	}
+	public void removeHeaderBlock(String namespace, String localPart) throws MessageException {
+		int index = getHeaderBlockIndex(namespace, localPart);
+		headerBlocks.remove(index);
+	}
+
+	public String traceString(String indent) {
+		// TODO Auto-generated method stub
+		return null;
+	}
+	
+}

Added: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/XMLStreamReaderForXMLSpine.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/XMLStreamReaderForXMLSpine.java?rev=420955&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/XMLStreamReaderForXMLSpine.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/XMLStreamReaderForXMLSpine.java Tue Jul 11 12:33:12 2006
@@ -0,0 +1,165 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ * Copyright 2006 International Business Machines Corp.
+ *
+ * Licensed 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.axis2.jaxws.message.impl;
+
+import java.util.List;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axis2.jaxws.message.Block;
+import org.apache.axis2.jaxws.message.MessageException;
+import org.apache.axis2.jaxws.message.Protocol;
+import org.apache.axis2.jaxws.message.util.StackableReader;
+import org.apache.axis2.jaxws.message.util.XMLStreamReaderFilter;
+
+/**
+ * XMLStreamReaderForXMLSpine
+ * 
+ * An XMLSpine is composed of many different parts: a sparse OM tree, 
+ * header blocks, body blocks, etc.
+ * 
+ * The XMLStreamReaderForXMLSpine provides an XMLStreamReader that
+ * over all of these combined objects (without building a full OM tree).
+ * It does this by using a StackableXMLStreamReader for the underlying implementation and 
+ * pushing the XMLStreamReaders for the blocks onto the stack at the appropriate points in 
+ * the message.
+ */
+public class XMLStreamReaderForXMLSpine extends XMLStreamReaderFilter {
+
+	// Components of an XMLSpine
+	OMElement root;
+	private List<Block> headerBlocks = null;
+	private List<Block> bodyBlocks   = null;
+	private List<Block> detailBlocks = null;
+	private boolean consume = false;
+	Protocol protocol = null;
+	
+	// Local Constants
+	private static final String BODY = "Body";
+	private static final String HEADER = "Header";
+	private static final String FAULT = "Fault";
+	private static final String DETAIL11 = "detail";
+	private static final String DETAIL12 = "Detail";
+	
+	boolean inFault = false;
+	private List<Block> insertBlocks = null;
+	
+	/**
+	 * @param root of the XMLSpine
+	 * @param headerBlocks 
+	 * @param bodyBocks
+	 * @param detailBlocks
+	 * @param consume
+	 */
+	public XMLStreamReaderForXMLSpine(OMElement root, 
+			Protocol protocol,
+			List<Block> headerBlocks, 
+			List<Block> bodyBlocks, 
+			List<Block> detailBlocks, 
+			boolean consume) {
+		// Create a stackable reader and prime it with the root om tree
+		// The XMLStreamReader's for the blocks will be pushed onto the
+		// stack as the message is processed.
+		super(new StackableReader(root.getXMLStreamReader()));
+		this.root = root;
+		this.protocol = protocol;
+		this.headerBlocks = headerBlocks;
+		this.bodyBlocks = bodyBlocks;
+		this.detailBlocks = detailBlocks;
+		this.consume = consume;
+	}
+
+	@Override
+	public int next() throws XMLStreamException {
+		// The next method is overridden so that we can push
+		// the block's XMLStreamReaders onto the stack at the 
+		// appropriate places in the message (pretty slick).
+		
+		// Insert pending blocks onto the stack
+		if (insertBlocks != null) {
+			pushBlocks(insertBlocks, consume);
+			insertBlocks = null;
+			
+		}
+		
+		// Get the next event
+		int event = super.next();
+		
+		// If this is a start element event, then we may need to insert
+		// the blocks prior to the next event
+		if (isStartElement()) {
+			QName qName = super.getName();
+			// Insert body blocks after the Body
+			if (qName.getLocalPart().equals(BODY) &&
+				qName.getNamespaceURI().equals(root.getNamespace().getName())) {
+				if (bodyBlocks != null) {
+					insertBlocks = bodyBlocks;
+					bodyBlocks = null;
+				}
+			} 
+			// Insert header blocks after the header
+			else if (qName.getLocalPart().equals(HEADER) &&
+					qName.getNamespaceURI().equals(root.getNamespace().getName())) {
+				if (headerBlocks != null) {
+					insertBlocks = headerBlocks;
+					headerBlocks = null;
+				}
+			}
+			else if (qName.getLocalPart().equals(FAULT) &&
+					qName.getNamespaceURI().equals(root.getNamespace().getName())) {
+				inFault = true;
+			} 
+			// Insert Detail blocks afger the detail...note that
+			// the detail name is different in SOAP 1.1 and SOAP 1.2
+			else if (inFault) {
+				if (qName.getLocalPart().equals(DETAIL11) &&
+				    protocol.equals(Protocol.soap11) ||
+				    qName.getLocalPart().equals(DETAIL12) &&
+				    protocol.equals(Protocol.soap12)) {
+					if (detailBlocks != null) {
+						insertBlocks = detailBlocks;
+						detailBlocks = null;
+					}
+				}
+			}
+		}
+		return event;
+	}
+
+	/**
+	 * Push the XMLStreamReaders for the blocks
+	 * @param blocks
+	 */
+	private void pushBlocks(List<Block> blocks, boolean consume) throws XMLStreamException{
+		// Push the XMLStreamReaders for the blocks onto the 
+		// delegate.  This is done in reverse order of the blocks so that the 
+		// first  block's xmlstreamreader is ontop of the stack.
+		try {
+			StackableReader sr = (StackableReader) delegate;
+			for (int i=blocks.size()-1; i>=0; i--) {
+				Block block = blocks.get(i);
+				if (block != null) {
+					sr.push(block.getXMLStreamReader(consume));
+				}
+			}
+		} catch (MessageException me) {
+			throw new XMLStreamException(me);
+		}
+	}
+}

Added: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/util/DOMReader.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/util/DOMReader.java?rev=420955&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/util/DOMReader.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/util/DOMReader.java Tue Jul 11 12:33:12 2006
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ * Copyright 2006 International Business Machines Corp.
+ *
+ * Licensed 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.axis2.jaxws.message.util;
+
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.axis2.jaxws.message.util.impl.XMLStreamReaderFromDOM;
+import org.w3c.dom.Element;
+
+/**
+ * DOMReader
+ * Creates an XMLStreamReader backed by a DOM tree.
+ */
+public class DOMReader extends Reader {
+
+	Element element;
+	
+	/**
+	 * @param reader
+	 * @param resettable
+	 */
+	public DOMReader(Element element) {
+		super(_newReader(element), true);
+		
+		this.element = element;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.apache.axis2.jaxws.message.util.Reader#newReader()
+	 */
+	@Override
+	protected XMLStreamReader newReader() {
+		return _newReader(element);
+	}
+
+	/**
+	 * Utility method to get the stream reader
+	 * @param element
+	 * @return
+	 */
+	private static XMLStreamReader _newReader(Element element) {
+		// Construct a reader from an element
+		return new XMLStreamReaderFromDOM(element);
+	}
+}

Added: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/util/Reader.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/util/Reader.java?rev=420955&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/util/Reader.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/util/Reader.java Tue Jul 11 12:33:12 2006
@@ -0,0 +1,257 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ * Copyright 2006 International Business Machines Corp.
+ *
+ * Licensed 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.axis2.jaxws.message.util;
+
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.namespace.QName;
+import javax.xml.stream.Location;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.axis2.jaxws.message.MessageInternalException;
+
+
+/**
+ * Reader
+ * In many situations, you want the ability to reset an XMLStreamReader.
+ * (Or at least ask if the XMLStreamReader is resettable).
+ * 
+ * The Reader abstract class:
+ *    - accepts an XMLStreamReader
+ *    - provides reset() and isResettable() methods
+ * Adds support resettable support to XMLStreamReader
+ * 
+ * Derived classes must pass the initial reader to the constructor and indicate if it
+ * is resettable.
+ * Derived classes must also provide an implementation of the newReader() method if 
+ * resettable.
+ */
+public abstract class Reader implements XMLStreamReader {
+	protected XMLStreamReader reader;
+	private final boolean resettable;
+	/**
+	 * @param reader
+	 * @param resettable
+	 */
+	Reader(XMLStreamReader reader, boolean resettable) {
+		this.reader = reader;
+		this.resettable = resettable;
+	}
+	
+	/**
+	 * Get a newReader from the Object
+	 * @return XMLStreamReader
+	 */
+	protected abstract XMLStreamReader newReader();
+	
+	/**
+	 * isResettable
+	 * @return true or false
+	 */
+	public boolean isResettable() {
+		return resettable;
+	}
+	
+	public void reset() throws MessageInternalException {
+		if (!resettable) {
+			// TODO NLS
+			throw new MessageInternalException("Can't reset non-resettable XMLStreamReader");
+		}
+		reader = newReader();
+	}
+
+	public void close() throws XMLStreamException {
+		reader.close();
+	}
+
+	public int getAttributeCount() {
+		return reader.getAttributeCount();
+	}
+
+	public String getAttributeLocalName(int arg0) {
+		return reader.getAttributeLocalName(arg0);
+	}
+
+	public QName getAttributeName(int arg0) {
+		return reader.getAttributeName(arg0);
+	}
+
+	public String getAttributeNamespace(int arg0) {
+		return reader.getAttributeNamespace(arg0);
+	}
+
+	public String getAttributePrefix(int arg0) {
+		return reader.getAttributePrefix(arg0);
+	}
+
+	public String getAttributeType(int arg0) {
+		return reader.getAttributeType(arg0);
+	}
+
+	public String getAttributeValue(int arg0) {
+		return reader.getAttributeValue(arg0);
+	}
+
+	public String getAttributeValue(String arg0, String arg1) {
+		return reader.getAttributeValue(arg0, arg1);
+	}
+
+	public String getCharacterEncodingScheme() {
+		return reader.getCharacterEncodingScheme();
+	}
+
+	public String getElementText() throws XMLStreamException {
+		return reader.getElementText();
+	}
+
+	public String getEncoding() {
+		return reader.getEncoding();
+	}
+
+	public int getEventType() {
+		return reader.getEventType();
+	}
+
+	public String getLocalName() {
+		return reader.getLocalName();
+	}
+
+	public Location getLocation() {
+		return reader.getLocation();
+	}
+
+	public QName getName() {
+		return reader.getName();
+	}
+
+	public NamespaceContext getNamespaceContext() {
+		return reader.getNamespaceContext();
+	}
+
+	public int getNamespaceCount() {
+		return reader.getNamespaceCount();
+	}
+
+	public String getNamespacePrefix(int arg0) {
+		return reader.getNamespacePrefix(arg0);
+	}
+
+	public String getNamespaceURI() {
+		return reader.getNamespaceURI();
+	}
+
+	public String getNamespaceURI(int arg0) {
+		return reader.getNamespaceURI(arg0);
+	}
+
+	public String getNamespaceURI(String arg0) {
+		return reader.getNamespaceURI(arg0);
+	}
+
+	public String getPIData() {
+		return reader.getPIData();
+	}
+
+	public String getPITarget() {
+		return reader.getPITarget();
+	}
+
+	public String getPrefix() {
+		return reader.getPrefix();
+	}
+
+	public Object getProperty(String arg0) throws IllegalArgumentException {
+		return reader.getProperty(arg0);
+	}
+
+	public String getText() {
+		return reader.getText();
+	}
+
+	public char[] getTextCharacters() {
+		return reader.getTextCharacters();
+	}
+
+	public int getTextCharacters(int arg0, char[] arg1, int arg2, int arg3) throws XMLStreamException {
+		return reader.getTextCharacters(arg0, arg1, arg2, arg3);
+	}
+
+	public int getTextLength() {
+		return reader.getTextLength();
+	}
+
+	public int getTextStart() {
+		return reader.getTextStart();
+	}
+
+	public String getVersion() {
+		return reader.getVersion();
+	}
+
+	public boolean hasName() {
+		return reader.hasName();
+	}
+
+	public boolean hasNext() throws XMLStreamException {
+		return reader.hasNext();
+	}
+
+	public boolean hasText() {
+		return reader.hasText();
+	}
+
+	public boolean isAttributeSpecified(int arg0) {
+		return reader.isAttributeSpecified(arg0);
+	}
+
+	public boolean isCharacters() {
+		return reader.isCharacters();
+	}
+
+	public boolean isEndElement() {
+		return reader.isEndElement();
+	}
+
+	public boolean isStandalone() {
+		return reader.isStandalone();
+	}
+
+	public boolean isStartElement() {
+		return reader.isStartElement();
+	}
+
+	public boolean isWhiteSpace() {
+		return reader.isWhiteSpace();
+	}
+
+	public int next() throws XMLStreamException {
+		return reader.next();
+	}
+
+	public int nextTag() throws XMLStreamException {
+		return reader.nextTag();
+	}
+
+	public void require(int arg0, String arg1, String arg2) throws XMLStreamException {
+		reader.require(arg0, arg1, arg2);
+	}
+
+	public boolean standaloneSet() {
+		return reader.standaloneSet();
+	}
+	
+}

Added: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/util/Reader2Writer.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/util/Reader2Writer.java?rev=420955&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/util/Reader2Writer.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/util/Reader2Writer.java Tue Jul 11 12:33:12 2006
@@ -0,0 +1,82 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ * Copyright 2006 International Business Machines Corp.
+ *
+ * Licensed 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.axis2.jaxws.message.util;
+
+import java.io.StringWriter;
+import java.util.Iterator;
+
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.axiom.om.OMDocument;
+import org.apache.axiom.om.OMNode;
+import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+
+/**
+ * Reader2Writer
+ * This is a simple converter that is constructed with an XMLStreamReader
+ * and allows you to write the contents to an XMLStreamWriter.
+ */
+public class Reader2Writer {
+
+	private XMLStreamReader reader;
+	private static XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
+	
+	/**
+	 * Construct from a Reader
+	 * @param reader -- the input to the converter
+	 */
+	public Reader2Writer(XMLStreamReader reader) {
+		this.reader = reader;
+	}
+
+	/**
+	 * outputTo the writer.
+	 * @param writer -- the output of the converter
+	 */
+	public void outputTo(XMLStreamWriter writer) throws XMLStreamException {
+		// Using OM to convert the reader to a writer.  This seems to be
+		// the safest way to make the conversion, and it promotes code re-use.
+		StAXOMBuilder builder = new StAXOMBuilder(reader);  
+		OMDocument omDocument = builder.getDocument();
+		Iterator it = omDocument.getChildren();
+		while(it.hasNext()) {
+			OMNode omNode = (OMNode) it.next();
+			omNode.serializeAndConsume(writer);
+		}
+	}
+	
+	/**
+	 * Utility method to write the reader contents to a String
+	 * @return String
+	 */
+	public String getAsString() throws XMLStreamException {
+		StringWriter sw = new StringWriter();
+		XMLStreamWriter writer = outputFactory.createXMLStreamWriter(sw);
+		
+		// Write the reader to the writer
+		outputTo(writer);
+		
+		// Flush the writer and get the String
+		writer.flush();
+		sw.flush();
+		String str = sw.toString();
+		return str;
+	}
+}

Added: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/util/ResettableReader.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/util/ResettableReader.java?rev=420955&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/util/ResettableReader.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/util/ResettableReader.java Tue Jul 11 12:33:12 2006
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ * Copyright 2006 International Business Machines Corp.
+ *
+ * Licensed 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.axis2.jaxws.message.util;
+
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+
+/**
+ * ResettableReader
+ * A resettable XMLStreamReader.  
+ * @see org.apache.axis2.jaxws.util.Reader
+ */
+public class ResettableReader extends Reader {
+
+	OMElement omElement = null;
+	
+	/** 
+	 * Create resettable XMLStreamReader
+	 * @param reader
+	 * @param resettable
+	 */
+	public ResettableReader(XMLStreamReader reader) {
+		super(reader, true);
+		StAXOMBuilder builder = new StAXOMBuilder(reader);  
+		omElement = builder.getDocumentElement();
+		reset();
+	}
+
+	/* (non-Javadoc)
+	 * @see org.apache.axis2.jaxws.message.util.Reader#newReader()
+	 */
+	@Override
+	protected XMLStreamReader newReader() {
+		return omElement.getXMLStreamReader();
+	}
+
+}

Added: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/util/SAAJConverter.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/util/SAAJConverter.java?rev=420955&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/util/SAAJConverter.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/util/SAAJConverter.java Tue Jul 11 12:33:12 2006
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ * Copyright 2006 International Business Machines Corp.
+ *
+ * Licensed 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.axis2.jaxws.message.util;
+
+import javax.xml.soap.SOAPElement;
+import javax.xml.soap.SOAPEnvelope;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axis2.jaxws.message.MessageException;
+
+
+/**
+ * SAAJConverter
+ * Provides Conversion between SAAJ and OM
+ * Constructed via the SAAJConverterFactory
+ */
+public interface SAAJConverter {
+	/**
+	 * Convert OM SOAPEnvleope to SAAJ SOAPEnvelope
+	 * @param omElement
+	 * @return SOAPEnvelope
+	 * @throws MessageException
+	 */
+	public SOAPEnvelope toSAAJ(org.apache.axiom.soap.SOAPEnvelope omElement)
+		throws MessageException;
+
+	/**
+	 * Convert SAAJ SOAPEnvelope to OM SOAPEnvelope
+	 * @param saajEnvelope
+	 * @return OM Envelope
+	 * @throws MessageException
+	 */
+	public org.apache.axiom.soap.SOAPEnvelope toOM(SOAPEnvelope saajEnvelope)
+		throws MessageException;
+	
+	/**
+	 * Convert SOAPElement into an OMElement
+	 * @param soapElement
+	 * @return OMElement
+	 * @throws MessageException
+	 */
+	public OMElement toOM(SOAPElement soapElement) 
+		throws MessageException;
+	
+	/**
+	 * Convert omElement into a SOAPElement and add it to the parent SOAPElement
+	 * @param omElement
+	 * @param parent SOAPElement
+	 * @return SOAPElement that was added to the parent.
+	 * @throws MessageException
+	 */
+	public SOAPElement toSAAJ(OMElement omElement, SOAPElement parent)
+		throws MessageException;
+}

Added: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/util/SOAPElementReader.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/util/SOAPElementReader.java?rev=420955&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/util/SOAPElementReader.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/util/SOAPElementReader.java Tue Jul 11 12:33:12 2006
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ * Copyright 2006 International Business Machines Corp.
+ *
+ * Licensed 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.axis2.jaxws.message.util;
+
+import javax.xml.soap.SOAPElement;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.axis2.jaxws.message.util.impl.XMLStreamReaderFromDOM;
+
+/**
+ * SOAPElementReader
+ * Creates an XMLStreamReader backed by a SOAPElement tree.
+ */
+public class SOAPElementReader extends Reader {
+
+	SOAPElement element;
+	
+	/**
+	 * @param reader
+	 * @param resettable
+	 */
+	public SOAPElementReader(SOAPElement element) {
+		super(_newReader(element), true);
+		
+		this.element = element;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.apache.axis2.jaxws.message.util.Reader#newReader()
+	 */
+	@Override
+	protected XMLStreamReader newReader() {
+		return _newReader(element);
+	}
+
+	/**
+	 * Utility method to get the stream reader
+	 * @param element
+	 * @return
+	 */
+	private static XMLStreamReader _newReader(SOAPElement element) {
+		// Construct a reader from an element
+		return new XMLStreamReaderFromDOM(element);
+	}
+}

Added: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/util/StackableReader.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/util/StackableReader.java?rev=420955&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/util/StackableReader.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/util/StackableReader.java Tue Jul 11 12:33:12 2006
@@ -0,0 +1,275 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ * Copyright 2006 International Business Machines Corp.
+ *
+ * Licensed 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.axis2.jaxws.message.util;
+
+import java.util.Stack;
+
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.namespace.QName;
+import javax.xml.stream.Location;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+/**
+ * StackableReader
+ * A StackableStreamReader provides an additional method
+ * push(XMLStreamReader)
+ * 
+ * You can call push(...) to add a new XMLStreamReader.  The
+ * next event will use the pushed stream reader.
+ * After the XMLStreamReader is consumed, it is automatically popped off 
+ * of the stack.
+ * 
+ * Note the information returned by the StackableReader is only
+ * applicable for the topmost XMLStreamReader.  For example the NamespaceContext
+ * that is returned is not a combination of all the namespace contexts on the stack.
+ */
+public class StackableReader implements XMLStreamReader {
+
+	Stack<XMLStreamReader> stack = new Stack<XMLStreamReader>();
+	XMLStreamReader current = null;
+	
+	/**
+	 * Create a stackable reader with the initial reader
+	 * @param first
+	 */
+	public StackableReader(XMLStreamReader first) {
+		current = first;
+	}
+	
+	/**
+	 * Push a new StreamReader
+	 * @param streamReader
+	 */
+	public void push(XMLStreamReader streamReader) throws XMLStreamException {
+		// Push the current reader if it is not consumed
+		if (current != null &&
+		    current.hasNext()) {
+			stack.push(current);
+		}
+		current = streamReader;
+	}
+
+	public void close() throws XMLStreamException {
+		current.close();
+	}
+
+	public int getAttributeCount() {
+		return current.getAttributeCount();
+	}
+
+	public String getAttributeLocalName(int arg0) {
+		return current.getAttributeLocalName(arg0);
+	}
+
+	public QName getAttributeName(int arg0) {
+		return current.getAttributeName(arg0);
+	}
+
+	public String getAttributeNamespace(int arg0) {
+		return current.getAttributeNamespace(arg0);
+	}
+
+	public String getAttributePrefix(int arg0) {
+		return current.getAttributePrefix(arg0);
+	}
+
+	public String getAttributeType(int arg0) {
+		return current.getAttributeType(arg0);
+	}
+
+	public String getAttributeValue(int arg0) {
+		return current.getAttributeValue(arg0);
+	}
+
+	public String getAttributeValue(String arg0, String arg1) {
+		return current.getAttributeValue(arg0, arg1);
+	}
+
+	public String getCharacterEncodingScheme() {
+		return current.getCharacterEncodingScheme();
+	}
+
+	public String getElementText() throws XMLStreamException {
+		return current.getElementText();
+	}
+
+	public String getEncoding() {
+		return current.getEncoding();
+	}
+
+	public int getEventType() {
+		return current.getEventType();
+	}
+
+	public String getLocalName() {
+		return current.getLocalName();
+	}
+
+	public Location getLocation() {
+		return current.getLocation();
+	}
+
+	public QName getName() {
+		return current.getName();
+	}
+
+	public NamespaceContext getNamespaceContext() {
+		return current.getNamespaceContext();
+	}
+
+	public int getNamespaceCount() {
+		return current.getNamespaceCount();
+	}
+
+	public String getNamespacePrefix(int arg0) {
+		return current.getNamespacePrefix(arg0);
+	}
+
+	public String getNamespaceURI() {
+		return current.getNamespaceURI();
+	}
+
+	public String getNamespaceURI(int arg0) {
+		return current.getNamespaceURI(arg0);
+	}
+
+	public String getNamespaceURI(String arg0) {
+		return current.getNamespaceURI(arg0);
+	}
+
+	public String getPIData() {
+		return current.getPIData();
+	}
+
+	public String getPITarget() {
+		return current.getPITarget();
+	}
+
+	public String getPrefix() {
+		return current.getPrefix();
+	}
+
+	public Object getProperty(String arg0) throws IllegalArgumentException {
+		return current.getProperty(arg0);
+	}
+
+	public String getText() {
+		return current.getText();
+	}
+
+	public char[] getTextCharacters() {
+		return current.getTextCharacters();
+	}
+
+	public int getTextCharacters(int arg0, char[] arg1, int arg2, int arg3) throws XMLStreamException {
+		return current.getTextCharacters(arg0, arg1, arg2, arg3);
+	}
+
+	public int getTextLength() {
+		return current.getTextLength();
+	}
+
+	public int getTextStart() {
+		return current.getTextStart();
+	}
+
+	public String getVersion() {
+		return current.getVersion();
+	}
+
+	public boolean hasName() {
+		return current.hasName();
+	}
+
+	public boolean hasNext() throws XMLStreamException {
+		// This code assumes that the stack only contains readers that are not consumed
+		if (!current.hasNext() &&
+			!stack.isEmpty()) {
+			return stack.peek().hasNext();
+		}
+		return current.hasNext();
+	}
+
+	public boolean hasText() {
+		return current.hasText();
+	}
+
+	public boolean isAttributeSpecified(int arg0) {
+		return current.isAttributeSpecified(arg0);
+	}
+
+	public boolean isCharacters() {
+		return current.isCharacters();
+	}
+
+	public boolean isEndElement() {
+		return current.isEndElement();
+	}
+
+	public boolean isStandalone() {
+		return current.isStandalone();
+	}
+
+	public boolean isStartElement() {
+		return current.isStartElement();
+	}
+
+	public boolean isWhiteSpace() {
+		return current.isWhiteSpace();
+	}
+
+	public int next() throws XMLStreamException {
+		// Only next is allowed to pop the stack
+		if (!current.hasNext() &&
+		    !stack.isEmpty()) {
+			current = stack.pop();
+		}
+		// The assumption is that the event on the stream reader was processed
+		// prior to pushing a new xmlstreamreader.  thus we proceed to the next
+		// event in all cases
+		int tag = current.next();
+		
+		// Skip start document and end document events for 
+		// stacked stream readers
+		if ((tag == this.START_DOCUMENT || 
+		    tag == this.END_DOCUMENT) &&
+		    !stack.isEmpty()) {
+			tag = next();
+		}
+		
+		return tag;
+	}
+
+	public int nextTag() throws XMLStreamException {
+		if (!current.hasNext() &&
+			!stack.isEmpty()) {
+			return stack.peek().nextTag();
+		}
+		return current.nextTag();
+	}
+
+	public void require(int arg0, String arg1, String arg2) throws XMLStreamException {
+		current.require(arg0, arg1, arg2);
+	}
+
+	public boolean standaloneSet() {
+		return current.standaloneSet();
+	}
+	
+	
+}

Added: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/util/XMLStreamReaderFilter.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/util/XMLStreamReaderFilter.java?rev=420955&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/util/XMLStreamReaderFilter.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/util/XMLStreamReaderFilter.java Tue Jul 11 12:33:12 2006
@@ -0,0 +1,222 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ * Copyright 2006 International Business Machines Corp.
+ *
+ * Licensed 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.axis2.jaxws.message.util;
+
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.namespace.QName;
+import javax.xml.stream.Location;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+/**
+ * XMLStreamReaderFilter
+ * Abstract class that simply delegates to the initial reader.
+ * This class is useful for building filters
+ */
+public abstract class XMLStreamReaderFilter implements XMLStreamReader {
+
+	protected XMLStreamReader delegate;
+	
+	/**
+	 * Construct a Filter 
+	 * @param reader XMLStreamReader that is filtered.
+	 */
+	public XMLStreamReaderFilter(XMLStreamReader reader) {
+		delegate = reader;
+	}
+
+	public void close() throws XMLStreamException {
+		delegate.close();
+	}
+
+	public int getAttributeCount() {
+		return delegate.getAttributeCount();
+	}
+
+	public String getAttributeLocalName(int arg0) {
+		return delegate.getAttributeLocalName(arg0);
+	}
+
+	public QName getAttributeName(int arg0) {
+		return delegate.getAttributeName(arg0);
+	}
+
+	public String getAttributeNamespace(int arg0) {
+		return delegate.getAttributeNamespace(arg0);
+	}
+
+	public String getAttributePrefix(int arg0) {
+		return delegate.getAttributePrefix(arg0);
+	}
+
+	public String getAttributeType(int arg0) {
+		return delegate.getAttributeType(arg0);
+	}
+
+	public String getAttributeValue(int arg0) {
+		return delegate.getAttributeValue(arg0);
+	}
+
+	public String getAttributeValue(String arg0, String arg1) {
+		return delegate.getAttributeValue(arg0, arg1);
+	}
+
+	public String getCharacterEncodingScheme() {
+		return delegate.getCharacterEncodingScheme();
+	}
+
+	public String getElementText() throws XMLStreamException {
+		return delegate.getElementText();
+	}
+
+	public String getEncoding() {
+		return delegate.getEncoding();
+	}
+
+	public int getEventType() {
+		return delegate.getEventType();
+	}
+
+	public String getLocalName() {
+		return delegate.getLocalName();
+	}
+
+	public Location getLocation() {
+		return delegate.getLocation();
+	}
+
+	public QName getName() {
+		return delegate.getName();
+	}
+
+	public NamespaceContext getNamespaceContext() {
+		return delegate.getNamespaceContext();
+	}
+
+	public int getNamespaceCount() {
+		return delegate.getNamespaceCount();
+	}
+
+	public String getNamespacePrefix(int arg0) {
+		return delegate.getNamespacePrefix(arg0);
+	}
+
+	public String getNamespaceURI() {
+		return delegate.getNamespaceURI();
+	}
+
+	public String getNamespaceURI(int arg0) {
+		return delegate.getNamespaceURI(arg0);
+	}
+
+	public String getNamespaceURI(String arg0) {
+		return delegate.getNamespaceURI(arg0);
+	}
+
+	public String getPIData() {
+		return delegate.getPIData();
+	}
+
+	public String getPITarget() {
+		return delegate.getPITarget();
+	}
+
+	public String getPrefix() {
+		return delegate.getPrefix();
+	}
+
+	public Object getProperty(String arg0) throws IllegalArgumentException {
+		return delegate.getProperty(arg0);
+	}
+
+	public String getText() {
+		return delegate.getText();
+	}
+
+	public char[] getTextCharacters() {
+		return delegate.getTextCharacters();
+	}
+
+	public int getTextCharacters(int arg0, char[] arg1, int arg2, int arg3) throws XMLStreamException {
+		return delegate.getTextCharacters(arg0, arg1, arg2, arg3);
+	}
+
+	public int getTextLength() {
+		return delegate.getTextLength();
+	}
+
+	public int getTextStart() {
+		return delegate.getTextStart();
+	}
+
+	public String getVersion() {
+		return delegate.getVersion();
+	}
+
+	public boolean hasName() {
+		return delegate.hasName();
+	}
+
+	public boolean hasNext() throws XMLStreamException {
+		return delegate.hasNext();
+	}
+
+	public boolean hasText() {
+		return delegate.hasText();
+	}
+
+	public boolean isAttributeSpecified(int arg0) {
+		return delegate.isAttributeSpecified(arg0);
+	}
+
+	public boolean isCharacters() {
+		return delegate.isCharacters();
+	}
+
+	public boolean isEndElement() {
+		return delegate.isEndElement();
+	}
+
+	public boolean isStandalone() {
+		return delegate.isStandalone();
+	}
+
+	public boolean isStartElement() {
+		return delegate.isStartElement();
+	}
+
+	public boolean isWhiteSpace() {
+		return delegate.isWhiteSpace();
+	}
+
+	public int next() throws XMLStreamException {
+		return delegate.next();
+	}
+
+	public int nextTag() throws XMLStreamException {
+		return delegate.nextTag();
+	}
+
+	public void require(int arg0, String arg1, String arg2) throws XMLStreamException {
+		delegate.require(arg0, arg1, arg2);
+	}
+
+	public boolean standaloneSet() {
+		return delegate.standaloneSet();
+	}
+
+}
\ No newline at end of file

Added: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/util/XMLStreamReaderSplitter.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/util/XMLStreamReaderSplitter.java?rev=420955&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/util/XMLStreamReaderSplitter.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/util/XMLStreamReaderSplitter.java Tue Jul 11 12:33:12 2006
@@ -0,0 +1,153 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ * Copyright 2006 International Business Machines Corp.
+ *
+ * Licensed 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.axis2.jaxws.message.util;
+
+
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+/**
+ * XMLStreamReaderSplitter
+ * An XMLStreamReaderSplitter wraps an existing XMLStreamReader and makes it 
+ * appear that the XMLStreamReader is for a single element tree.
+ * Once the element tree is consumed, the getNextReader method may be called to 
+ * get the next element tree.
+ * 
+ * For example, suppose the input xml is the following:
+ * 
+ * spurious text 1
+ * <data>
+ *   <a>a data</a>
+ *   <b>b data</b>
+ * </data>
+ * spurious text 2
+ * <data2>
+ *   <a2>a data</a2>
+ *   <b2>b data</b2>
+ * </data2>
+ * 
+ * The XMLStreamReaderSplitter will only return the events for:
+ * <data>
+ *   <a>a data</a>
+ *   <b>b data</b>
+ * </data>
+ * 
+ * Once these events are consumed, the nextStreamReader method can be called, which
+ * will return:
+ * <data2>
+ *   <a2>a data</a2>
+ *   <b2>b data</b2>
+ * </data2>
+ * 
+ * Note that the spurious text and comments between the elements are ignored.
+ * 
+ */
+public class XMLStreamReaderSplitter extends XMLStreamReaderFilter {
+
+	int depth = 0;
+	boolean start = true;
+	/**
+	 * Split the input reader into multiple element trees
+	 * @param reader XMLStreamReader
+	 */
+	public XMLStreamReaderSplitter(XMLStreamReader reader) {
+		super(reader);
+		init();
+	}
+	
+	/**
+	 * Reset for a new element tree
+	 */
+	private void init() {
+		depth = 0;
+		start = true;
+	}
+	
+	public int next() throws XMLStreamException {
+		// If starting a new tree, ignore all of the 
+		// events until the first start element is found.
+		if (start) {
+			start = false; 
+			depth = 1;
+			int event = super.next();
+			
+			while (event != START_ELEMENT) {
+				if (event == START_ELEMENT) {
+					return event;
+				} else if (this.hasNext()) {
+					event = super.next();
+				} else {
+					return event;
+				}
+			}	
+			return event;
+		} else {
+			// Processing a tree.  Adjust the 
+			// depth as the tags are encountered.
+			if (depth == 0) {
+				// Some consumers expect an END_DOCUMENT to end their processing (some consumers will trigger the end of processing using hasNext())
+				return END_DOCUMENT;
+			}
+			int event = super.next();
+			if (event == START_ELEMENT) {
+				depth++;
+			} else if (event == END_ELEMENT) {
+				depth--;
+			} 
+			return event;
+		}
+	}
+	
+	@Override
+	public boolean hasNext() throws XMLStreamException {
+		if (depth == 0) {
+			// If this element tree is consumed return false
+			if (start) {
+				return super.hasNext();
+			} else {
+				return false;
+			}
+		} else {
+			return super.hasNext();
+		}
+	}
+
+	
+	/**
+	 * getStreamReader
+	 * @return XMLStreamReader for the next element tree.
+	 * If the prior stream reader is not consumed, this method will return null.
+	 * (Use hasNext() to see if the prior stream reader is consumed)
+	 * @throws XMLStreamReader
+	 */
+	public XMLStreamReader getNextReader() throws XMLStreamException {
+		if (!hasNext()) {
+			init();
+			if (hasNext()) {
+				// Return newly initialized reader
+				return this;
+			} else {
+				// Return null indicating no reader is available
+				return null;
+			}
+		} else {
+			// Return null if the current reader is still be read
+			return null;
+		}
+			
+	}
+}

Added: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/util/impl/NamespaceContextFromDOM.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/util/impl/NamespaceContextFromDOM.java?rev=420955&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/util/impl/NamespaceContextFromDOM.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/util/impl/NamespaceContextFromDOM.java Tue Jul 11 12:33:12 2006
@@ -0,0 +1,108 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ * Copyright 2006 International Business Machines Corp.
+ *
+ * Licensed 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.axis2.jaxws.message.util.impl;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import javax.xml.namespace.NamespaceContext;
+
+import org.w3c.dom.Attr;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+
+
+/**
+ * Namespace information available at the current scope.
+ * Utility class for XMLStreamReaderFromDOM
+ * @see org.apache.axis2.jaxws.message.util.impl.XMLStreamReaderFromDOM
+ */
+public class NamespaceContextFromDOM implements NamespaceContext {
+
+	private Element element;
+	/**
+	 * @param element representing the current scope
+	 */
+	NamespaceContextFromDOM(Element element) {
+		this.element = element;
+	}
+
+	/* (non-Javadoc)
+	 * @see javax.xml.namespace.NamespaceContext#getPrefix(java.lang.String)
+	 */
+	public String getPrefix(String namespaceURI) {
+		return element.lookupPrefix(namespaceURI);
+	}
+
+	/* (non-Javadoc)
+	 * @see javax.xml.namespace.NamespaceContext#getPrefixes(java.lang.String)
+	 */
+	public Iterator getPrefixes(String namespaceURI) {
+		if (element instanceof javax.xml.soap.SOAPElement) {
+			Iterator it = ((javax.xml.soap.SOAPElement)element).getVisibleNamespacePrefixes();
+			ArrayList list = new ArrayList();
+			while (it.hasNext()) {
+				String prefix = (String) it.next();
+				if (getNamespaceURI(prefix).equals(namespaceURI)) {
+					if (prefix != null && prefix.length() == 0) {
+						prefix = null;
+					}
+					list.add(prefix);
+				}
+			}
+			return list.iterator();
+		} else {
+			ArrayList list = new ArrayList();
+			Node node = element;
+			while (node != null) {
+				if (node instanceof Element) {
+					// Walk the attributes looking for namespace declarations
+					NamedNodeMap attrs =((Element) node).getAttributes();
+					for (int i=0; i<attrs.getLength(); i++) {
+						Attr attr = (Attr) attrs.item(i);
+						if (attr.getNodeValue().equals(namespaceURI)) {
+							String name = attr.getNodeName();
+							
+							if (name.startsWith("xmlns")) {
+								String prefix = "";
+								if (name.startsWith("xmlns:")) {
+									prefix = name.substring(6);
+								}
+								// Found a namespace declaration with the prefix.
+								// Make sure this is not overridden by a declaration 
+								// in a closer scope.
+								if (!list.contains(prefix) &&
+										getNamespaceURI(prefix).equals(namespaceURI)) {
+									list.add(prefix);
+								}
+							}
+						}
+					}
+				}
+				// Pop up to the parent node
+				node = node.getParentNode();
+			}
+			return list.iterator();
+		}
+	}
+
+	public String getNamespaceURI(String prefix) {
+		return element.lookupNamespaceURI(prefix);
+	}
+
+}

Added: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/util/impl/SAAJConverterFactoryImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/util/impl/SAAJConverterFactoryImpl.java?rev=420955&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/util/impl/SAAJConverterFactoryImpl.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/util/impl/SAAJConverterFactoryImpl.java Tue Jul 11 12:33:12 2006
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ * Copyright 2006 International Business Machines Corp.
+ *
+ * Licensed 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.axis2.jaxws.message.util.impl;
+
+import org.apache.axis2.jaxws.message.factory.SAAJConverterFactory;
+import org.apache.axis2.jaxws.message.util.SAAJConverter;
+
+/**
+ * SAAJConverterFactoryImpl
+ * Get the default SAAJConverter implementation.
+ * Obtain this factory from the FactoryRegistry
+ */
+public class SAAJConverterFactoryImpl implements SAAJConverterFactory {
+
+	SAAJConverterImpl converter = new SAAJConverterImpl();
+	
+	/**
+	 * Required for Factory instantiation
+	 */
+	public SAAJConverterFactoryImpl() {
+		super();
+	}
+
+	/* (non-Javadoc)
+	 * @see org.apache.axis2.jaxws.message.factory.SAAJConverterFactory#getSAAJConverter()
+	 */
+	public SAAJConverter getSAAJConverter() {
+		return converter;
+	}
+
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org