📄 operationdesc.java
字号:
/* * Copyright 2002-2004 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.apache.axis.description;import org.apache.axis.components.logger.LogFactory;import org.apache.axis.constants.Style;import org.apache.axis.constants.Use;import org.apache.commons.logging.Log;import javax.xml.namespace.QName;import javax.wsdl.OperationType;import java.io.Serializable;import java.io.IOException;import java.lang.reflect.Method;import java.util.ArrayList;import java.util.Iterator;import java.util.Map;import java.util.HashMap;/** * An OperationDesc is an abstract description of an operation on a service. * * !!! WORK IN PROGRESS * * @author Glen Daniels (gdaniels@apache.org) */public class OperationDesc implements Serializable { // Constants for "message style" operation patterns. If this OperationDesc // is message style, the Java method will have one of these signatures: // public SOAPBodyElement [] method(SOAPBodyElement []) public static final int MSG_METHOD_BODYARRAY = 1; // public void method(SOAPEnvelope, SOAPEnvelope) public static final int MSG_METHOD_SOAPENVELOPE = 2; // public Element [] method(Element []) public static final int MSG_METHOD_ELEMENTARRAY = 3; // public Document method(Document) public static final int MSG_METHOD_DOCUMENT = 4; public static final int MSG_METHOD_NONCONFORMING = -4; public static Map mepStrings = new HashMap(); static { mepStrings.put("request-response", OperationType.REQUEST_RESPONSE); mepStrings.put("oneway", OperationType.ONE_WAY); mepStrings.put("solicit-response", OperationType.SOLICIT_RESPONSE); mepStrings.put("notification", OperationType.NOTIFICATION); } protected static Log log = LogFactory.getLog(OperationDesc.class.getName()); /** The service we're a part of */ private ServiceDesc parent; /** Parameter list */ private ArrayList parameters = new ArrayList(); /** The operation name (String, or QName?) */ private String name; /** An XML QName which should dispatch to this method */ private QName elementQName; /** The actual Java method associated with this operation, if known */ private transient Method method; /** This operation's style/use. If null, we default to our parent's */ private Style style = null; private Use use = null; /** The number of "in" params (i.e. IN or INOUT) for this operation */ private int numInParams = 0; /** The number of "out" params (i.e. OUT or INOUT) for this operation */ private int numOutParams = 0; /** A unique SOAPAction value for this operation */ private String soapAction = null; /** Faults for this operation */ private ArrayList faults = null; private ParameterDesc returnDesc = new ParameterDesc(); /** If we're a message-style operation, what's our signature? */ private int messageOperationStyle = -1; /** The documentation for the operation */ private String documentation = null; /** The MEP for this Operation - uses the WSDL4J OperationType for now * but we might want to have our own extensible enum for WSDL 2.0 */ private OperationType mep = OperationType.REQUEST_RESPONSE; /** * Default constructor. */ public OperationDesc() { returnDesc.setMode(ParameterDesc.OUT); returnDesc.setIsReturn(true); } /** * "Complete" constructor */ public OperationDesc(String name, ParameterDesc [] parameters, QName returnQName) { this.name = name; returnDesc.setQName(returnQName); returnDesc.setMode(ParameterDesc.OUT); returnDesc.setIsReturn(true); for (int i = 0; i < parameters.length; i++) { addParameter(parameters[i]); } } /** * Return the operation's name */ public String getName() { return name; } /** * Set the operation's name */ public void setName(String name) { this.name = name; } /** * get the documentation for the operation */ public String getDocumentation() { return documentation; } /** * set the documentation for the operation */ public void setDocumentation(String documentation) { this.documentation = documentation; } public QName getReturnQName() { return returnDesc.getQName(); } public void setReturnQName(QName returnQName) { returnDesc.setQName(returnQName); } public QName getReturnType() { return returnDesc.getTypeQName(); } public void setReturnType(QName returnType) { log.debug("@" + Integer.toHexString(hashCode()) + "setReturnType(" + returnType +")"); returnDesc.setTypeQName(returnType); } public Class getReturnClass() { return returnDesc.getJavaType(); } public void setReturnClass(Class returnClass) { returnDesc.setJavaType(returnClass); } public QName getElementQName() { return elementQName; } public void setElementQName(QName elementQName) { this.elementQName = elementQName; } public ServiceDesc getParent() { return parent; } public void setParent(ServiceDesc parent) { this.parent = parent; } public String getSoapAction() { return soapAction; } public void setSoapAction(String soapAction) { this.soapAction = soapAction; } public void setStyle(Style style) { this.style = style; } /** * Return the style of the operation, defaulting to the parent * ServiceDesc's style if we don't have one explicitly set. */ public Style getStyle() { if (style == null) { if (parent != null) { return parent.getStyle(); } return Style.DEFAULT; // Default } return style; } public void setUse(Use use) { this.use = use; } /** * Return the use of the operation, defaulting to the parent * ServiceDesc's use if we don't have one explicitly set. */ public Use getUse() { if (use == null) { if (parent != null) { return parent.getUse(); } return Use.DEFAULT; // Default } return use; } public void addParameter(ParameterDesc param) { // Should we enforce adding INs then INOUTs then OUTs? param.setOrder(getNumParams()); parameters.add(param); if ((param.getMode() == ParameterDesc.IN) || (param.getMode() == ParameterDesc.INOUT)) { numInParams++; } if ((param.getMode() == ParameterDesc.OUT) || (param.getMode() == ParameterDesc.INOUT)) { numOutParams++; } log.debug("@" + Integer.toHexString(hashCode()) + " added parameter >" + param + "@" + Integer.toHexString(param.hashCode()) + "<total parameters:" +getNumParams()); } public void addParameter(QName paramName, QName xmlType, Class javaType, byte parameterMode, boolean inHeader, boolean outHeader) { ParameterDesc param = new ParameterDesc(paramName, parameterMode, xmlType, javaType, inHeader, outHeader); addParameter(param); } public ParameterDesc getParameter(int i) { if (parameters.size() <= i) return null; return (ParameterDesc)parameters.get(i); } public ArrayList getParameters() { return parameters; } /** * Set the parameters wholesale. * * @param newParameters an ArrayList of ParameterDescs */ public void setParameters(ArrayList newParameters) { parameters = new ArrayList(); //Keep numInParams correct. numInParams = 0; numOutParams = 0; for( java.util.ListIterator li= newParameters.listIterator(); li.hasNext(); ){ addParameter((ParameterDesc) li.next()); } } public int getNumInParams() { return numInParams; } public int getNumOutParams() {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -