001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common Development
008: * and Distribution License("CDDL") (collectively, the "License"). You
009: * may not use this file except in compliance with the License. You can obtain
010: * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
011: * or glassfish/bootstrap/legal/LICENSE.txt. See the License for the specific
012: * language governing permissions and limitations under the License.
013: *
014: * When distributing the software, include this License Header Notice in each
015: * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
016: * Sun designates this particular file as subject to the "Classpath" exception
017: * as provided by Sun in the GPL Version 2 section of the License file that
018: * accompanied this code. If applicable, add the following below the License
019: * Header, with the fields enclosed by brackets [] replaced by your own
020: * identifying information: "Portions Copyrighted [year]
021: * [name of copyright owner]"
022: *
023: * Contributor(s):
024: *
025: * If you wish your version of this file to be governed by only the CDDL or
026: * only the GPL Version 2, indicate your decision by adding "[Contributor]
027: * elects to include this software in this distribution under the [CDDL or GPL
028: * Version 2] license." If you don't indicate a single choice of license, a
029: * recipient has the option to distribute your version of this file under
030: * either the CDDL, the GPL Version 2 or to extend the choice of license to
031: * its licensees as provided above. However, if you add GPL Version 2 code
032: * and therefore, elected the GPL Version 2 license, then the option applies
033: * only if the new code is made subject to such option by the copyright
034: * holder.
035: */
036:
037: package com.sun.xml.ws.wsdl.parser;
038:
039: import com.sun.xml.ws.api.addressing.AddressingVersion;
040: import com.sun.xml.ws.developer.MemberSubmissionAddressingFeature;
041: import com.sun.xml.ws.api.model.wsdl.WSDLBoundOperation;
042: import com.sun.xml.ws.api.model.wsdl.WSDLBoundPortType;
043: import com.sun.xml.ws.api.model.wsdl.WSDLFeaturedObject;
044: import com.sun.xml.ws.api.model.wsdl.WSDLOperation;
045: import com.sun.xml.ws.api.model.wsdl.WSDLPort;
046: import com.sun.xml.ws.model.wsdl.WSDLBoundPortTypeImpl;
047: import com.sun.xml.ws.model.wsdl.WSDLOperationImpl;
048: import com.sun.xml.ws.streaming.XMLStreamReaderUtil;
049:
050: import javax.xml.namespace.QName;
051: import javax.xml.stream.XMLStreamReader;
052:
053: /**
054: * Member Submission WS-Addressing Runtime WSDL parser extension
055: *
056: * @author Arun Gupta
057: */
058: public class MemberSubmissionAddressingWSDLParserExtension extends
059: W3CAddressingWSDLParserExtension {
060: @Override
061: public boolean bindingElements(WSDLBoundPortType binding,
062: XMLStreamReader reader) {
063: return addressibleElement(reader, binding);
064: }
065:
066: @Override
067: public boolean portElements(WSDLPort port, XMLStreamReader reader) {
068: return addressibleElement(reader, port);
069: }
070:
071: private boolean addressibleElement(XMLStreamReader reader,
072: WSDLFeaturedObject binding) {
073: QName ua = reader.getName();
074: if (ua.equals(AddressingVersion.MEMBER.wsdlExtensionTag)) {
075: String required = reader.getAttributeValue(
076: WSDLConstants.NS_WSDL, "required");
077: binding.addFeature(new MemberSubmissionAddressingFeature(
078: Boolean.parseBoolean(required)));
079: XMLStreamReaderUtil.skipElement(reader);
080: return true; // UsingAddressing is consumed
081: }
082:
083: return false;
084: }
085:
086: @Override
087: public boolean bindingOperationElements(
088: WSDLBoundOperation operation, XMLStreamReader reader) {
089: return false;
090: }
091:
092: @Override
093: public boolean portTypeOperationInput(WSDLOperation o,
094: XMLStreamReader reader) {
095: WSDLOperationImpl impl = (WSDLOperationImpl) o;
096:
097: String action = ParserUtil.getAttribute(reader,
098: AddressingVersion.MEMBER.wsdlActionTag);
099: if (action != null) {
100: impl.getInput().setAction(action);
101: impl.getInput().setDefaultAction(false);
102: }
103:
104: return false;
105: }
106:
107: @Override
108: public boolean portTypeOperationOutput(WSDLOperation o,
109: XMLStreamReader reader) {
110: WSDLOperationImpl impl = (WSDLOperationImpl) o;
111:
112: String action = ParserUtil.getAttribute(reader,
113: AddressingVersion.MEMBER.wsdlActionTag);
114: if (action != null) {
115: impl.getOutput().setAction(action);
116: }
117:
118: return false;
119: }
120:
121: @Override
122: public boolean portTypeOperationFault(WSDLOperation o,
123: XMLStreamReader reader) {
124: WSDLOperationImpl impl = (WSDLOperationImpl) o;
125:
126: String action = ParserUtil.getAttribute(reader,
127: AddressingVersion.MEMBER.wsdlActionTag);
128: if (action != null) {
129: String name = ParserUtil.getMandatoryNonEmptyAttribute(
130: reader, "name");
131: impl.getFaultActionMap().put(name, action);
132: }
133:
134: return false;
135: }
136:
137: @Override
138: protected void patchAnonymousDefault(WSDLBoundPortTypeImpl binding) {
139: }
140:
141: @Override
142: protected String getNamespaceURI() {
143: return AddressingVersion.MEMBER.wsdlNsUri;
144: }
145: }
|