1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292
|
/*
* JBoss, Home of Professional Open Source
* Copyright 2005, JBoss Inc., and individual contributors as indicated
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.ws.metadata.wsdl;
import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.Map;
import javax.xml.namespace.QName;
import org.jboss.ws.Constants;
import org.jboss.ws.WSException;
import org.jboss.ws.metadata.wsdl.WSDLRPCSignatureItem.Direction;
// $Id: WSDLInterfaceOperation.java 5471 2008-01-15 18:14:04Z alessio.soldano@jboss.com $
/**
* An Interface Operation component describes an operation that a given interface supports. An operation is
* an interaction with the service consisting of a set (ordinary and fault) messages exchanged between the
* service and the other roles involved in the interaction, in particular the service requester. The sequencing
* and cardinality of the messages involved in a particular interaction is governed by the message exchange
* pattern used by the operation (see {message exchange pattern} property).
*
* @author Thomas.Diesler@jboss.org
* @author <a href="mailto:jason.greene@jboss.com>Jason T. Greene</a>
* @since 10-Oct-2004
*/
public class WSDLInterfaceOperation extends Extendable implements Comparable
{
private static final long serialVersionUID = -5014918078197942626L;
// The parent interface
private WSDLInterface wsdlInterface;
private final QName name;
/** The OPTIONAL pattern attribute information item identifies the message exchange pattern a given operation uses.
*/
private String pattern;
/** The OPTIONAL style attribute information item indicates the rules that were used to construct the {element}
* properties of the Message Reference components which are members of the {message references}
* property of the [owner] operation.
*/
private String style = Constants.URI_STYLE_RPC;
/** The OPTIONAL safe attribute information item indicates whether the operation is safe or not.
*/
private boolean safe;
/** Zero or more input element information items */
private Map<QName, WSDLInterfaceOperationInput> inputs = new LinkedHashMap<QName, WSDLInterfaceOperationInput>();
/** Zero or more output element information items */
private Map<QName, WSDLInterfaceOperationOutput> outputs = new LinkedHashMap<QName, WSDLInterfaceOperationOutput>();
/** Zero or more infault element information items */
private ArrayList<WSDLInterfaceOperationInfault> infaults = new ArrayList<WSDLInterfaceOperationInfault>();
/** Zero or more outfault element information items */
private ArrayList<WSDLInterfaceOperationOutfault> outfaults = new ArrayList<WSDLInterfaceOperationOutfault>();
/** Zero or more signature items */
private LinkedHashMap<String, WSDLRPCSignatureItem> rpcSignatureItems = new LinkedHashMap<String, WSDLRPCSignatureItem>();
private WSDLDocumentation documentationElement;
public WSDLInterfaceOperation(WSDLInterface wsdlInterface, QName name)
{
this.name = name;
this.wsdlInterface = wsdlInterface;
}
public WSDLInterfaceOperation(WSDLInterface wsdlInterface, String localName)
{
this.wsdlInterface = wsdlInterface;
name = new QName(wsdlInterface.getName().getNamespaceURI(), localName);
}
public WSDLInterface getWsdlInterface()
{
return wsdlInterface;
}
public QName getName()
{
return name;
}
public String getPattern()
{
return pattern;
}
public void setPattern(String pattern)
{
this.pattern = pattern;
}
public String getStyle()
{
return style;
}
public void setStyle(String style)
{
this.style = style;
}
public boolean isSafe()
{
return safe;
}
public void setSafe(boolean safe)
{
this.safe = safe;
}
public WSDLInterfaceOperationInput[] getInputs()
{
WSDLInterfaceOperationInput[] arr = new WSDLInterfaceOperationInput[inputs.size()];
new ArrayList<WSDLInterfaceOperationInput>(inputs.values()).toArray(arr);
return arr;
}
public void addInput(WSDLInterfaceOperationInput input)
{
QName xmlName = input.getElement();
if (inputs.get(xmlName) != null)
throw new WSException("Attempt to map multiple operation inputs to: " + xmlName);
inputs.put(xmlName, input);
}
public WSDLInterfaceOperationInput getInput(QName qname)
{
WSDLInterfaceOperationInput opInput = (WSDLInterfaceOperationInput)inputs.get(qname);
return opInput;
}
public void removeInput(QName element)
{
inputs.remove(element);
}
public WSDLInterfaceOperationInput getInputByPartName(String partName)
{
WSDLInterfaceOperationInput opInput = null;
for (WSDLInterfaceOperationInput auxInput : inputs.values())
{
WSDLProperty property = auxInput.getProperty(Constants.WSDL_PROPERTY_PART_NAME);
if (property != null && property.getValue().equals(partName))
opInput = auxInput;
}
return opInput;
}
public WSDLInterfaceOperationOutput[] getOutputs()
{
WSDLInterfaceOperationOutput[] arr = new WSDLInterfaceOperationOutput[outputs.size()];
new ArrayList<WSDLInterfaceOperationOutput>(outputs.values()).toArray(arr);
return arr;
}
public void addOutput(WSDLInterfaceOperationOutput output)
{
QName xmlName = output.getElement();
if (outputs.get(xmlName) != null)
throw new WSException("Attempt to map multiple operation outputs to: " + xmlName);
outputs.put(xmlName, output);
}
public WSDLInterfaceOperationOutput getOutput(QName qname)
{
WSDLInterfaceOperationOutput opOutput = (WSDLInterfaceOperationOutput)outputs.get(qname);
return opOutput;
}
public void removeOutput(QName element)
{
outputs.remove(element);
}
public WSDLInterfaceOperationOutput getOutputByPartName(String partName)
{
WSDLInterfaceOperationOutput opOutput = null;
for (WSDLInterfaceOperationOutput auxOutput : outputs.values())
{
WSDLProperty property = auxOutput.getProperty(Constants.WSDL_PROPERTY_PART_NAME);
if (property != null && property.getValue().equals(partName))
opOutput = auxOutput;
}
return opOutput;
}
public WSDLInterfaceOperationInfault[] getInfaults()
{
WSDLInterfaceOperationInfault[] arr = new WSDLInterfaceOperationInfault[infaults.size()];
infaults.toArray(arr);
return arr;
}
public void addInfault(WSDLInterfaceOperationInfault infault)
{
infaults.add(infault);
}
public WSDLInterfaceOperationOutfault[] getOutfaults()
{
WSDLInterfaceOperationOutfault[] arr = new WSDLInterfaceOperationOutfault[outfaults.size()];
outfaults.toArray(arr);
return arr;
}
public void addOutfault(WSDLInterfaceOperationOutfault outfault)
{
outfaults.add(outfault);
}
public Collection<WSDLRPCSignatureItem> getRpcSignatureItems()
{
return rpcSignatureItems.values();
}
public void addRpcSignatureItem(WSDLRPCSignatureItem item)
{
if (item.getDirection() != Direction.RETURN)
item.setPosition(rpcSignatureItems.size());
rpcSignatureItems.put(item.getName(), item);
}
public WSDLRPCSignatureItem getRpcSignatureitem(String name)
{
return rpcSignatureItems.get(name);
}
/**
* Attempts to locate a binding operation for this interface operation.
*
* @return the binding operation, or null if not found;
*/
public WSDLBindingOperation getBindingOperation()
{
WSDLInterface wsdlInterface = getWsdlInterface();
WSDLBinding binding = wsdlInterface.getWsdlDefinitions().getBindingByInterfaceName(wsdlInterface.getName());
if (binding == null)
return null;
WSDLBindingOperation bindingOperation = binding.getOperationByRef(getName());
return bindingOperation;
}
public int compareTo(Object o)
{
int c = -1;
if (o instanceof WSDLInterfaceOperation)
{
WSDLInterfaceOperation w = (WSDLInterfaceOperation)o;
String oname = w.getName().getLocalPart();
String myname = name.getLocalPart();
c = myname.compareTo(oname);
}
return c;
}
public WSDLDocumentation getDocumentationElement()
{
return documentationElement;
}
public void setDocumentationElement(WSDLDocumentation documentationElement)
{
this.documentationElement = documentationElement;
}
}
|