FileDocCategorySizeDatePackage
OperationDesc.javaAPI DocApache Axis 1.418171Sat Apr 22 18:57:26 BST 2006org.apache.axis.description

OperationDesc

public class OperationDesc extends Object implements Serializable
An OperationDesc is an abstract description of an operation on a service. !!! WORK IN PROGRESS
author
Glen Daniels (gdaniels@apache.org)

Fields Summary
public static final int
MSG_METHOD_BODYARRAY
public static final int
MSG_METHOD_SOAPENVELOPE
public static final int
MSG_METHOD_ELEMENTARRAY
public static final int
MSG_METHOD_DOCUMENT
public static final int
MSG_METHOD_NONCONFORMING
public static Map
mepStrings
protected static Log
log
private ServiceDesc
parent
The service we're a part of
private ArrayList
parameters
Parameter list
private String
name
The operation name (String, or QName?)
private QName
elementQName
An XML QName which should dispatch to this method
private transient Method
method
The actual Java method associated with this operation, if known
private org.apache.axis.constants.Style
style
This operation's style/use. If null, we default to our parent's
private org.apache.axis.constants.Use
use
private int
numInParams
The number of "in" params (i.e. IN or INOUT) for this operation
private int
numOutParams
The number of "out" params (i.e. OUT or INOUT) for this operation
private String
soapAction
A unique SOAPAction value for this operation
private ArrayList
faults
Faults for this operation
private ParameterDesc
returnDesc
private int
messageOperationStyle
If we're a message-style operation, what's our signature?
private String
documentation
The documentation for the operation
private javax.wsdl.OperationType
mep
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
Constructors Summary
public OperationDesc()
Default constructor.


           
      
        returnDesc.setMode(ParameterDesc.OUT);
        returnDesc.setIsReturn(true);
    
public OperationDesc(String name, ParameterDesc[] parameters, QName returnQName)
"Complete" constructor

        this.name = name;
        returnDesc.setQName(returnQName);
        returnDesc.setMode(ParameterDesc.OUT);
        returnDesc.setIsReturn(true);
        for (int i = 0; i < parameters.length; i++) {
            addParameter(parameters[i]);
        }
    
Methods Summary
public voidaddFault(FaultDesc fault)

        if (faults == null)
            faults = new ArrayList();
        faults.add(fault);
    
public voidaddParameter(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 voidaddParameter(javax.xml.namespace.QName paramName, javax.xml.namespace.QName xmlType, java.lang.Class javaType, byte parameterMode, boolean inHeader, boolean outHeader)

        ParameterDesc param =
                new ParameterDesc(paramName, parameterMode, xmlType,
                                  javaType, inHeader, outHeader);
        addParameter(param);
    
public java.util.ArrayListgetAllInParams()
Return a list of ALL "in" params (including INOUTs) Note: if we were sure the order went IN->INOUT->OUT, we could optimize this.

return

        ArrayList result = new ArrayList();
        for (Iterator i = parameters.iterator(); i.hasNext();) {
            ParameterDesc desc = (ParameterDesc) i.next();
            if (desc.getMode() != ParameterDesc.OUT) {
                result.add(desc);
            }
        }
        return result;
    
public java.util.ArrayListgetAllOutParams()
Return a list of ALL "out" params (including INOUTs) Note: if we were sure the order went IN->INOUT->OUT, we could optimize this.

return

        ArrayList result = new ArrayList();
        for (Iterator i = parameters.iterator(); i.hasNext();) {
            ParameterDesc desc = (ParameterDesc) i.next();
            if (desc.getMode() != ParameterDesc.IN) {
                result.add(desc);
            }
        }
        return result;        
    
public java.lang.StringgetDocumentation()
get the documentation for the operation

    	return documentation; 
    
public javax.xml.namespace.QNamegetElementQName()

        return elementQName;
    
public FaultDescgetFaultByClass(java.lang.Class cls)
Returns the FaultDesc for the fault class given. Returns null if not found.

        if (faults == null || cls == null) {
            return null;
        }

        while (cls != null) {
            // Check each class in the inheritance hierarchy, stopping at
            // java.* or javax.* classes.

            for (Iterator iterator = faults.iterator(); iterator.hasNext();) {
                FaultDesc desc = (FaultDesc) iterator.next();
                if (cls.getName().equals(desc.getClassName())) {
                    return desc;
                }
            }

            cls = cls.getSuperclass();
            if (cls != null && (cls.getName().startsWith("java.") ||
                    cls.getName().startsWith("javax."))) {
                cls = null;
            }
        }

        return null;
    
public FaultDescgetFaultByClass(java.lang.Class cls, boolean checkParents)
Returns the FaultDesc for the fault class given. Returns null if not found.

        if (checkParents) {
            return getFaultByClass(cls);
        } 
        
        if (faults == null || cls == null) {
            return null;
        }
        
        for (Iterator iterator = faults.iterator(); iterator.hasNext();) {
            FaultDesc desc = (FaultDesc) iterator.next();
            if (cls.getName().equals(desc.getClassName())) {
                return desc;
            }
        }
        
        return null;
    
public FaultDescgetFaultByQName(javax.xml.namespace.QName qname)
Returns the FaultDesc for a QName (which is typically found in the details element of a SOAP fault). Returns null if not found.

        if (faults != null) {
            for (Iterator iterator = faults.iterator(); iterator.hasNext();) {
                FaultDesc desc = (FaultDesc) iterator.next();
                if (qname.equals(desc.getQName())) {
                    return desc;
                }
            }
        }
        return null;
    
public FaultDescgetFaultByXmlType(javax.xml.namespace.QName xmlType)
Returns the FaultDesc for an XMLType. Returns null if not found.

        if (faults != null) {
            for (Iterator iterator = faults.iterator(); iterator.hasNext();) {
                FaultDesc desc = (FaultDesc) iterator.next();
                if (xmlType.equals(desc.getXmlType())) {
                    return desc;
                }
            }
        }
        return null;
    
public java.util.ArrayListgetFaults()

        return faults;
    
public ParameterDescgetInputParamByQName(javax.xml.namespace.QName qname)

        ParameterDesc param = null;

        param = getParamByQName(qname);

        if ((param == null) || (param.getMode() == ParameterDesc.OUT)) {
            param = null;
        }

        return param;
    
public javax.wsdl.OperationTypegetMep()

        return mep;
    
public intgetMessageOperationStyle()

        return messageOperationStyle;
    
public java.lang.reflect.MethodgetMethod()

        return method;
    
public java.lang.StringgetName()
Return the operation's name

        return name;
    
public intgetNumInParams()

        return numInParams;
    
public intgetNumOutParams()

        return numOutParams;
    
public intgetNumParams()

        return parameters.size();
    
public java.util.ArrayListgetOutParams()
Returns an ordered list of out params (NOT inouts)

        ArrayList result = new ArrayList();
        for (Iterator i = parameters.iterator(); i.hasNext();) {
            ParameterDesc desc = (ParameterDesc) i.next();
            if (desc.getMode() == ParameterDesc.OUT) {
                result.add(desc);
            }
        }
        return result;
    
public ParameterDescgetOutputParamByQName(javax.xml.namespace.QName qname)

        ParameterDesc param = null;

        for (Iterator i = parameters.iterator(); i.hasNext();) {
            ParameterDesc pnext = (ParameterDesc)i.next();
            if (pnext.getQName().equals(qname) &&
                    pnext.getMode() != ParameterDesc.IN) {
                param = pnext;
                break;
            }
        }

        if (param == null) {
            if (null == returnDesc.getQName() ){
                param= new ParameterDesc( returnDesc); //Create copy
                param.setQName(qname);
            }
            else if ( qname.equals(returnDesc.getQName())) {
                param = returnDesc;
            }
        }

        return param;
    
public ParameterDescgetParamByQName(javax.xml.namespace.QName qname)

        for (Iterator i = parameters.iterator(); i.hasNext();) {
            ParameterDesc param = (ParameterDesc) i.next();
            if (param.getQName().equals(qname))
                return param;
        }

        return null;
    
public ParameterDescgetParameter(int i)

        if (parameters.size() <= i)
            return null;

        return (ParameterDesc)parameters.get(i);
    
public java.util.ArrayListgetParameters()

        return parameters;
    
public ServiceDescgetParent()

        return parent;
    
public java.lang.ClassgetReturnClass()

        return returnDesc.getJavaType();
    
public ParameterDescgetReturnParamDesc()

        return returnDesc;
    
public javax.xml.namespace.QNamegetReturnQName()

        return returnDesc.getQName();
    
public javax.xml.namespace.QNamegetReturnType()

        return returnDesc.getTypeQName();
    
public java.lang.StringgetSoapAction()

        return soapAction;
    
public org.apache.axis.constants.StylegetStyle()
Return the style of the operation, defaulting to the parent ServiceDesc's style if we don't have one explicitly set.

        if (style == null) {
            if (parent != null) {
                return parent.getStyle();
            }
            return Style.DEFAULT; // Default
        }

        return style;
    
public org.apache.axis.constants.UsegetUse()
Return the use of the operation, defaulting to the parent ServiceDesc's use if we don't have one explicitly set.

        if (use == null) {
            if (parent != null) {
                return parent.getUse();
            }
            return Use.DEFAULT; // Default
        }

        return use;
    
public booleanisReturnHeader()
Is the return value in the header of the response message?

        return returnDesc.isOutHeader();
    
private voidreadObject(java.io.ObjectInputStream in)

        in.defaultReadObject();
        Class clazz = (Class) in.readObject();
        if (clazz != null){
            String methodName = (String) in.readObject();
            Class[] parameterTypes = (Class[]) in.readObject();
            try {
                method = clazz.getMethod(methodName, parameterTypes);
            } catch (NoSuchMethodException e) {
                throw new IOException("Unable to deserialize the operation's method: "+ methodName);
            }
        }
    
public voidsetDocumentation(java.lang.String documentation)
set the documentation for the operation

    	this.documentation = documentation;
    
public voidsetElementQName(javax.xml.namespace.QName elementQName)

        this.elementQName = elementQName;
    
public voidsetMep(javax.wsdl.OperationType mep)

        this.mep = mep;
    
public voidsetMep(java.lang.String mepString)
Set the MEP using a string like "request-response"

param
mepString

        OperationType newMep = (OperationType)mepStrings.get(mepString);
        if (newMep != null) {
            mep = newMep;
        }
    
public voidsetMessageOperationStyle(int messageOperationStyle)

        this.messageOperationStyle = messageOperationStyle;
    
public voidsetMethod(java.lang.reflect.Method method)

        this.method = method;
    
public voidsetName(java.lang.String name)
Set the operation's name

        this.name = name;
    
public voidsetParameters(java.util.ArrayList newParameters)
Set the parameters wholesale.

param
newParameters an ArrayList of ParameterDescs

        parameters = new ArrayList(); //Keep numInParams correct.
        numInParams = 0;
        numOutParams = 0;
        
        for( java.util.ListIterator li= newParameters.listIterator();
             li.hasNext(); ){
            addParameter((ParameterDesc) li.next());
        }
    
public voidsetParent(ServiceDesc parent)

        this.parent = parent;
    
public voidsetReturnClass(java.lang.Class returnClass)

        returnDesc.setJavaType(returnClass);
    
public voidsetReturnHeader(boolean value)
Set whether the return value is in the response message.

        returnDesc.setOutHeader(value);
    
public voidsetReturnQName(javax.xml.namespace.QName returnQName)

        returnDesc.setQName(returnQName);
    
public voidsetReturnType(javax.xml.namespace.QName returnType)

        log.debug("@" + Integer.toHexString(hashCode())  + "setReturnType(" + returnType +")");
        returnDesc.setTypeQName(returnType);
    
public voidsetSoapAction(java.lang.String soapAction)

        this.soapAction = soapAction;
    
public voidsetStyle(org.apache.axis.constants.Style style)

        this.style = style;
    
public voidsetUse(org.apache.axis.constants.Use use)

        this.use = use;
    
public java.lang.StringtoString()

        return toString("");
    
public java.lang.StringtoString(java.lang.String indent)

        String text ="";
        text+=indent+"name:        " + getName() + "\n";
        text+=indent+"returnQName: " + getReturnQName() + "\n";
        text+=indent+"returnType:  " + getReturnType() + "\n";
        text+=indent+"returnClass: " + getReturnClass() + "\n";
        text+=indent+"elementQName:" + getElementQName() + "\n";
        text+=indent+"soapAction:  " + getSoapAction() + "\n";
        text+=indent+"style:       " + getStyle().getName() + "\n";
        text+=indent+"use:         " + getUse().getName() + "\n";
        text+=indent+"numInParams: " + getNumInParams() + "\n";
        text+=indent+"method:" + getMethod() + "\n";
        for (int i=0; i<parameters.size(); i++) {
            text+=indent+" ParameterDesc[" + i + "]:\n";
            text+=indent+ ((ParameterDesc)parameters.get(i)).toString("  ") + "\n";
        }
        if (faults != null) {
            for (int i=0; i<faults.size(); i++) {
                text+=indent+" FaultDesc[" + i + "]:\n";
                text+=indent+ ((FaultDesc)faults.get(i)).toString("  ") + "\n";
            }
        }
        return text;
    
private voidwriteObject(java.io.ObjectOutputStream out)

        out.defaultWriteObject();
        if (method != null){
            out.writeObject(method.getDeclaringClass());
            out.writeObject(method.getName());
            out.writeObject(method.getParameterTypes());
        } else {
            out.writeObject(null);
        }