001: /*
002: * Portions Copyright 2006 Sun Microsystems, Inc. All Rights Reserved.
003: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004: *
005: * This code is free software; you can redistribute it and/or modify it
006: * under the terms of the GNU General Public License version 2 only, as
007: * published by the Free Software Foundation. Sun designates this
008: * particular file as subject to the "Classpath" exception as provided
009: * by Sun in the LICENSE file that accompanied this code.
010: *
011: * This code is distributed in the hope that it will be useful, but WITHOUT
012: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014: * version 2 for more details (a copy is included in the LICENSE file that
015: * accompanied this code).
016: *
017: * You should have received a copy of the GNU General Public License version
018: * 2 along with this work; if not, write to the Free Software Foundation,
019: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020: *
021: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022: * CA 95054 USA or visit www.sun.com if you need additional information or
023: * have any questions.
024: */
025: package com.sun.xml.internal.ws.wsdl.parser;
026:
027: import com.sun.xml.internal.ws.model.ParameterBinding;
028: import com.sun.xml.internal.ws.model.Mode;
029:
030: import javax.xml.ws.Response;
031: import java.util.HashMap;
032: import java.util.Map;
033:
034: public class BindingOperation {
035: private String name;
036:
037: // map of wsdl:part to the binding
038: private Map<String, ParameterBinding> inputParts;
039: private Map<String, ParameterBinding> outputParts;
040: private Map<String, String> inputMimeTypes;
041: private Map<String, String> outputMimeTypes;
042:
043: private boolean explicitInputSOAPBodyParts = false;
044: private boolean explicitOutputSOAPBodyParts = false;
045:
046: private Boolean emptyInputBody;
047: private Boolean emptyOutputBody;
048:
049: private Map<String, Part> inParts;
050: private Map<String, Part> outParts;
051:
052: /**
053: *
054: * @param name wsdl:operation name qualified value
055: */
056: public BindingOperation(String name) {
057: this .name = name;
058: inputParts = new HashMap<String, ParameterBinding>();
059: outputParts = new HashMap<String, ParameterBinding>();
060: inputMimeTypes = new HashMap<String, String>();
061: outputMimeTypes = new HashMap<String, String>();
062: inParts = new HashMap<String, Part>();
063: outParts = new HashMap<String, Part>();
064: }
065:
066: public String getName() {
067: return name;
068: }
069:
070: public Part getPart(String partName, Mode mode) {
071: if (mode.equals(Mode.IN)) {
072: return inParts.get(partName);
073: } else if (mode.equals(Mode.OUT)) {
074: return outParts.get(partName);
075: }
076: return null;
077: }
078:
079: public void addPart(Part part, Mode mode) {
080: if (mode.equals(Mode.IN))
081: inParts.put(part.getName(), part);
082: else if (mode.equals(Mode.OUT))
083: outParts.put(part.getName(), part);
084: }
085:
086: public Map<String, ParameterBinding> getInputParts() {
087: return inputParts;
088: }
089:
090: public Map<String, ParameterBinding> getOutputParts() {
091: return outputParts;
092: }
093:
094: public Map<String, String> getInputMimeTypes() {
095: return inputMimeTypes;
096: }
097:
098: public Map<String, String> getOutputMimeTypes() {
099: return outputMimeTypes;
100: }
101:
102: public ParameterBinding getInputBinding(String part) {
103: if (emptyInputBody == null) {
104: if (inputParts.get(" ") != null)
105: emptyInputBody = true;
106: else
107: emptyInputBody = false;
108: }
109: ParameterBinding block = inputParts.get(part);
110: if (block == null) {
111: if (explicitInputSOAPBodyParts || emptyInputBody)
112: return ParameterBinding.UNBOUND;
113: return ParameterBinding.BODY;
114: }
115:
116: return block;
117: }
118:
119: public ParameterBinding getOutputBinding(String part) {
120: if (emptyOutputBody == null) {
121: if (outputParts.get(" ") != null)
122: emptyOutputBody = true;
123: else
124: emptyOutputBody = false;
125: }
126: ParameterBinding block = outputParts.get(part);
127: if (block == null) {
128: if (explicitOutputSOAPBodyParts || emptyOutputBody)
129: return ParameterBinding.UNBOUND;
130: return ParameterBinding.BODY;
131: }
132:
133: return block;
134: }
135:
136: public String getMimeTypeForInputPart(String part) {
137: return inputMimeTypes.get(part);
138: }
139:
140: public String getMimeTypeForOutputPart(String part) {
141: return outputMimeTypes.get(part);
142: }
143:
144: public void setInputExplicitBodyParts(boolean b) {
145: explicitInputSOAPBodyParts = b;
146: }
147:
148: public void setOutputExplicitBodyParts(boolean b) {
149: explicitOutputSOAPBodyParts = b;
150: }
151:
152: String reqNamespace;
153: String respNamespace;
154:
155: /**
156: * For rpclit gives namespace value on soapbinding:body@namespace
157: *
158: * @return non-null for rpclit and null for doclit
159: * @see com.sun.xml.internal.ws.modeler.RuntimeModeler#processRpcMethod(com.sun.xml.internal.ws.model.JavaMethod, String, javax.jws.WebMethod, String, java.lang.reflect.Method, javax.jws.WebService)
160: */
161: public String getRequestNamespace() {
162: return reqNamespace;
163: }
164:
165: /**
166: * For rpclit gives namespace value on soapbinding:body@namespace
167: *
168: * @return non-null for rpclit and null for doclit
169: * * @see com.sun.xml.internal.ws.modeler.RuntimeModeler#processRpcMethod(com.sun.xml.internal.ws.model.JavaMethod, String, javax.jws.WebMethod, String, java.lang.reflect.Method, javax.jws.WebService)
170: */
171: public String getResponseNamespace() {
172: return respNamespace;
173: }
174: }
|