001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one
003: * or more contributor license agreements. See the NOTICE file
004: * distributed with this work for additional information
005: * regarding copyright ownership. The ASF licenses this file
006: * to you under the Apache License, Version 2.0 (the
007: * "License"); you may not use this file except in compliance
008: * with the License. You may obtain a copy of the License at
009: *
010: * http://www.apache.org/licenses/LICENSE-2.0
011: *
012: * Unless required by applicable law or agreed to in writing,
013: * software distributed under the License is distributed on an
014: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015: * KIND, either express or implied. See the License for the
016: * specific language governing permissions and limitations
017: * under the License.
018: */
019:
020: /**
021: *
022: */package org.apache.axis2.jaxws.message.databinding.impl;
023:
024: import org.apache.axiom.om.OMElement;
025: import org.apache.axis2.jaxws.message.Message;
026: import org.apache.axis2.jaxws.message.databinding.SOAPEnvelopeBlock;
027: import org.apache.axis2.jaxws.message.factory.BlockFactory;
028: import org.apache.axis2.jaxws.message.factory.MessageFactory;
029: import org.apache.axis2.jaxws.message.impl.BlockImpl;
030: import org.apache.axis2.jaxws.message.util.SOAPElementReader;
031: import org.apache.axis2.jaxws.registry.FactoryRegistry;
032:
033: import javax.xml.namespace.QName;
034: import javax.xml.soap.SOAPElement;
035: import javax.xml.soap.SOAPEnvelope;
036: import javax.xml.stream.XMLStreamException;
037: import javax.xml.stream.XMLStreamReader;
038: import javax.xml.stream.XMLStreamWriter;
039: import javax.xml.ws.WebServiceException;
040:
041: /**
042: *
043: *
044: */
045: public class SOAPEnvelopeBlockImpl extends BlockImpl implements
046: SOAPEnvelopeBlock {
047:
048: /**
049: * Called by SOAPEnvelopeBlockFactory
050: *
051: * @param busObject
052: * @param busContext
053: * @param qName
054: * @param factory
055: */
056: public SOAPEnvelopeBlockImpl(Object busObject, Object busContext,
057: QName qName, BlockFactory factory) {
058: super (busObject, busContext,
059: (qName == null) ? getQName((SOAPEnvelope) busObject)
060: : qName, factory);
061: }
062:
063: /**
064: * Called by SOAPEnvelopeBlockFactory
065: *
066: * @param omElement
067: * @param busContext
068: * @param qName
069: * @param factory
070: */
071: public SOAPEnvelopeBlockImpl(OMElement omElement,
072: Object busContext, QName qName, BlockFactory factory) {
073: super (omElement, busContext, qName, factory);
074: }
075:
076: /* (non-Javadoc)
077: * @see org.apache.axis2.jaxws.message.impl.BlockImpl#_getBOFromReader(javax.xml.stream.XMLStreamReader, java.lang.Object)
078: */
079: @Override
080: protected Object _getBOFromReader(XMLStreamReader reader,
081: Object busContext) throws XMLStreamException,
082: WebServiceException {
083: MessageFactory mf = (MessageFactory) FactoryRegistry
084: .getFactory(MessageFactory.class);
085: Message message = mf.createFrom(reader, null);
086: SOAPEnvelope env = message.getAsSOAPEnvelope();
087: this .setQName(getQName(env));
088: return env;
089: }
090:
091: /* (non-Javadoc)
092: * @see org.apache.axis2.jaxws.message.impl.BlockImpl#_getReaderFromBO(java.lang.Object, java.lang.Object)
093: */
094: @Override
095: protected XMLStreamReader _getReaderFromBO(Object busObj,
096: Object busContext) throws XMLStreamException,
097: WebServiceException {
098: return new SOAPElementReader((SOAPElement) busObj);
099: }
100:
101: /* (non-Javadoc)
102: * @see org.apache.axis2.jaxws.message.impl.BlockImpl#_outputFromBO(java.lang.Object, java.lang.Object, javax.xml.stream.XMLStreamWriter)
103: */
104: @Override
105: protected void _outputFromBO(Object busObject, Object busContext,
106: XMLStreamWriter writer) throws XMLStreamException,
107: WebServiceException {
108: XMLStreamReader reader = _getReaderFromBO(busObject, busContext);
109: _outputFromReader(reader, writer);
110: }
111:
112: /**
113: * Get the QName of the envelope
114: *
115: * @param env
116: * @return QName
117: */
118: private static QName getQName(SOAPEnvelope env) {
119: return new QName(env.getNamespaceURI(), env.getLocalName(), env
120: .getPrefix());
121: }
122:
123: public boolean isElementData() {
124: return true;
125: }
126: }
|