001: /**
002: * $Id: BindingDescriptorImpl.java,v 1.6 2003/06/03 10:49:23 sy131129 Exp $
003: * Copyright 2002-2003 Sun Microsystems, Inc. All
004: * rights reserved. Use of this product is subject
005: * to license terms. Federal Acquisitions:
006: * Commercial Software -- Government Users
007: * Subject to Standard License Terms and
008: * Conditions.
009: *
010: * Sun, Sun Microsystems, the Sun logo, and Sun ONE
011: * are trademarks or registered trademarks of Sun Microsystems,
012: * Inc. in the United States and other countries.
013: */package com.sun.portal.providers.simplewebservice.wsdl.impl;
014:
015: import java.util.List;
016: import java.util.ArrayList;
017: import java.util.Iterator;
018:
019: import com.sun.portal.providers.simplewebservice.wsdl.BindingDescriptor;
020: import com.sun.portal.providers.simplewebservice.wsdl.BindingOperationDescriptor;
021: import com.sun.portal.providers.simplewebservice.wsdl.BindingOperationInputDescriptor;
022: import com.sun.portal.providers.simplewebservice.wsdl.BindingOperationOutputDescriptor;
023:
024: /**
025: * This class represents a port type BindingDescriptor and describes the
026: * protocol required for using operations in a port type.
027: *
028: */
029: public class BindingDescriptorImpl implements BindingDescriptor {
030:
031: private String name = null;
032: private String portTypeDescriptorName = null;
033: private List bindingOperationDescriptors = new ArrayList();
034: private String soapBindingStyle = null;
035: private String soapBindingTransport = null;
036:
037: /**
038: * Default Constructor.
039: *
040: * @param name the name of the BindingDescriptor.
041: * @param portTypeDescriptorName the name of the PortTypeDescriptor that is part of the BindingDescriptor.
042: * @param bindingOperationDescriptors the BindingOperationDescriptors that are part of the BindingDescriptor.
043: * @param soapBindingStyle the style for this SOAP Binding.
044: * @param soapBindingTransport the transport for this SOAP Binding.
045: */
046: public BindingDescriptorImpl(String name,
047: String portTypeDescriptorName,
048: List bindingOperationDescriptors, String soapBindingStyle,
049: String soapBindingTransport) {
050: this .name = name;
051: this .portTypeDescriptorName = portTypeDescriptorName;
052: this .bindingOperationDescriptors = bindingOperationDescriptors;
053: this .soapBindingStyle = soapBindingStyle;
054: this .soapBindingTransport = soapBindingTransport;
055: }
056:
057: /**
058: * Get the name of this BindingDescriptor.
059: *
060: * @return the BindingDescriptor name
061: */
062: public String getName() {
063: return name;
064: }
065:
066: /**
067: * Get the name of the PortTypeDescriptor associated with this
068: * BindingDescriptor.
069: *
070: * @return the name of the associated port type
071: */
072: public String getPortTypeDescriptorName() {
073: return portTypeDescriptorName;
074: }
075:
076: /**
077: * Get the specified BindingOperationDescriptor. Note that operation
078: * names can be overloaded within a PortType. In case of overloading, the
079: * names of the input and output messages can be used to further
080: * refine the search.
081: *
082: * @param name the name of the desired BindingOperationDescriptor.
083: * @param inputName the name of the BindingInputDescriptor; if this is null
084: * it will be ignored.
085: * @param outputName the name of the BindingOutputDescriptor; if this is null
086: * it will be ignored.
087: *
088: * @return the corresponding BindingOperationDescriptor, or null if there wasn't
089: * any matching BindingOperationDescriptor.
090: */
091: public BindingOperationDescriptor getBindingOperationDescriptor(
092: String name, String inputName, String outputName) {
093: // @@ further verify this logic
094:
095: Iterator bindingOperationDescriptorIterator = bindingOperationDescriptors
096: .iterator();
097:
098: while (bindingOperationDescriptorIterator.hasNext()) {
099: BindingOperationDescriptor bindingOperationDescriptor = (BindingOperationDescriptor) bindingOperationDescriptorIterator
100: .next();
101: String opName = bindingOperationDescriptor.getName();
102:
103: if (name != null && opName != null) {
104: if (!name.equals(opName)) {
105: bindingOperationDescriptor = null;
106: }
107: } else if (name != null || opName != null) {
108: bindingOperationDescriptor = null;
109: }
110:
111: if (bindingOperationDescriptor != null && inputName != null) {
112: BindingOperationInputDescriptor inputDescriptor = bindingOperationDescriptor
113: .getBindingOperationInputDescriptor();
114:
115: if (inputDescriptor != null) {
116: String opInputName = inputDescriptor.getName();
117:
118: if (opInputName == null
119: || !opInputName.equals(inputName)) {
120: bindingOperationDescriptor = null;
121: }
122: } else {
123: bindingOperationDescriptor = null;
124: }
125: }
126:
127: if (bindingOperationDescriptor != null
128: && outputName != null) {
129: BindingOperationOutputDescriptor outputDescriptor = bindingOperationDescriptor
130: .getBindingOperationOutputDescriptor();
131:
132: if (outputDescriptor != null) {
133: String opOutputName = outputDescriptor.getName();
134:
135: if (opOutputName == null
136: || !opOutputName.equals(outputName)) {
137: bindingOperationDescriptor = null;
138: }
139: } else {
140: bindingOperationDescriptor = null;
141: }
142: }
143:
144: if (bindingOperationDescriptor != null) {
145: return bindingOperationDescriptor;
146: }
147: }
148:
149: return null;
150: }
151:
152: /**
153: * Get all the BindingOperationDescriptors defined here.
154: *
155: * @return the BindingOperationDescriptors.
156: */
157: public List getBindingOperationDescriptors() {
158: return bindingOperationDescriptors;
159: }
160:
161: /**
162: * Get the SOAP Binding Style for this BindingDescriptor.
163: *
164: * @return the BindingDescriptor SOAP Binding Style.
165: */
166: public String getSOAPBindingStyle() {
167: return soapBindingStyle;
168: }
169:
170: /**
171: * Get the SOAP Binding Transport for this BindingDescriptor.
172: *
173: * @return the BindingDescriptor SOAP Binding Transport.
174: */
175: public String getSOAPBindingTransport() {
176: return soapBindingTransport;
177: }
178:
179: /**
180: * Get the String representation of this BindingDescriptor.
181: *
182: * @return the String representation of this BindingDescriptor.
183: */
184: public String toString() {
185: StringBuffer strBuf = new StringBuffer();
186:
187: strBuf.append("\nBindingDescriptor: name=" + name);
188:
189: if (portTypeDescriptorName != null) {
190: strBuf.append("\ntype=" + portTypeDescriptorName);
191: }
192:
193: if (soapBindingStyle != null) {
194: strBuf.append("\nSOAP Binding Style=" + soapBindingStyle);
195: }
196:
197: if (soapBindingTransport != null) {
198: strBuf.append("\nSOAP Binding Transport="
199: + soapBindingTransport);
200: }
201:
202: if (bindingOperationDescriptors != null) {
203: Iterator bindingOperationDescriptorIterator = bindingOperationDescriptors
204: .iterator();
205:
206: while (bindingOperationDescriptorIterator.hasNext()) {
207: strBuf.append("\n"
208: + bindingOperationDescriptorIterator.next());
209: }
210: }
211:
212: return strBuf.toString();
213: }
214: }
|