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: package org.apache.axis2.databinding;
021:
022: import org.apache.axiom.soap.SOAPConstants;
023: import org.apache.axiom.soap.SOAPEnvelope;
024: import org.apache.axiom.soap.SOAPFactory;
025: import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder;
026: import org.apache.axis2.util.StreamWrapper;
027:
028: import javax.xml.namespace.QName;
029: import javax.xml.stream.XMLStreamReader;
030:
031: /** Builds a SOAPEnvelope around an ADB pull parser */
032: public class ADBSOAPModelBuilder extends StAXSOAPModelBuilder {
033:
034: public ADBSOAPModelBuilder(XMLStreamReader parser,
035: SOAPFactory factory) {
036: super (new Envelope(parser).getPullParser(new QName(factory
037: .getSoapVersionURI(),
038: SOAPConstants.SOAPENVELOPE_LOCAL_NAME,
039: SOAPConstants.SOAP_DEFAULT_NAMESPACE_PREFIX)), factory,
040: factory.getSoapVersionURI());
041: }
042:
043: public SOAPEnvelope getEnvelope() {
044: return getSOAPEnvelope();
045: }
046:
047: public static class Envelope implements
048: org.apache.axis2.databinding.ADBBean {
049: Body body;
050:
051: Envelope(XMLStreamReader parser) {
052: body = new Body(parser);
053: }
054:
055: public javax.xml.stream.XMLStreamReader getPullParser(
056: javax.xml.namespace.QName qName) {
057: java.util.ArrayList elementList = new java.util.ArrayList();
058: elementList.add(new QName(qName.getNamespaceURI(),
059: "Header", SOAPConstants.BODY_NAMESPACE_PREFIX));
060: elementList.add(new Header());
061: elementList.add(new QName(qName.getNamespaceURI(), "Body",
062: SOAPConstants.BODY_NAMESPACE_PREFIX));
063: elementList.add(body);
064: return new StreamWrapper(
065: new org.apache.axis2.databinding.utils.reader.ADBXMLStreamReaderImpl(
066: qName, elementList.toArray(), null));
067: }
068: }
069:
070: protected void identifySOAPVersion(
071: String soapVersionURIFromTransport) {
072: //Do nothing
073: }
074:
075: public static class Body implements
076: org.apache.axis2.databinding.ADBBean {
077: Child child;
078:
079: Body(XMLStreamReader parser) {
080: child = new Child(parser);
081: }
082:
083: public javax.xml.stream.XMLStreamReader getPullParser(
084: javax.xml.namespace.QName qName) {
085: java.util.ArrayList elementList = new java.util.ArrayList();
086: elementList.add(qName);
087: elementList.add(child);
088: return new org.apache.axis2.databinding.utils.reader.ADBXMLStreamReaderImpl(
089: qName, elementList.toArray(), null);
090: }
091: }
092:
093: public static class Header implements
094: org.apache.axis2.databinding.ADBBean {
095: public javax.xml.stream.XMLStreamReader getPullParser(
096: javax.xml.namespace.QName qName) {
097: java.util.ArrayList elementList = new java.util.ArrayList();
098: return new org.apache.axis2.databinding.utils.reader.ADBXMLStreamReaderImpl(
099: qName, elementList.toArray(), null);
100: }
101: }
102:
103: public static class Child implements
104: org.apache.axis2.databinding.ADBBean {
105: XMLStreamReader parser;
106:
107: Child(XMLStreamReader parser) {
108: this .parser = parser;
109: }
110:
111: public javax.xml.stream.XMLStreamReader getPullParser(
112: javax.xml.namespace.QName qName) {
113: return parser;
114: }
115: }
116: }
|