methoddescriptioncomposite.java

来自「开源的axis2框架的源码。用于开发WEBSERVER」· Java 代码 · 共 456 行 · 第 1/2 页

JAVA
456
字号
/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements. See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership. The ASF licenses this file
 * to you 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.axis2.jaxws.description.builder;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class MethodDescriptionComposite implements TMAnnotationComposite, TMFAnnotationComposite {

    //Method reflective information
    private String methodName;    //a public method name in this class
    private String returnType;    //Methods return type
    private String[] exceptions;
    private String declaringClass; //the class/interface that actually declares this method

    boolean oneWayAnnotated;
	// boolean that indicates if an @XmlList annotation was found on the method
	private boolean 				isListType = false;
    private WebMethodAnnot webMethodAnnot;
    private WebResultAnnot webResultAnnot;
    private WebServiceContextAnnot webServiceContextAnnot;
    private HandlerChainAnnot handlerChainAnnot;
    private SoapBindingAnnot soapBindingAnnot;
    private WebServiceRefAnnot webServiceRefAnnot;
    private WebEndpointAnnot webEndpointAnnot;
    private RequestWrapperAnnot requestWrapperAnnot; //TODO EDIT CHECK: only on methods of SEI
    private ResponseWrapperAnnot responseWrapperAnnot;//TODO EDIT CHECK: only on methods of SEI
    private List<ParameterDescriptionComposite> parameterDescriptions;//TODO EDIT CHECK: only on methods of SEI

    private DescriptionBuilderComposite parentDBC;

    /*
      * Default Constructor
      */
    public MethodDescriptionComposite() {
        parameterDescriptions = new ArrayList<ParameterDescriptionComposite>();
    }

    public MethodDescriptionComposite(
            String methodName,
            String returnType,
            WebMethodAnnot webMethodAnnot,
            WebResultAnnot webResultAnnot,
            boolean oneWayAnnotated,
            HandlerChainAnnot handlerChainAnnot,
            SoapBindingAnnot soapBindingAnnot,
            WebServiceRefAnnot webServiceRefAnnot,
            WebEndpointAnnot webEndpointAnnot,
            RequestWrapperAnnot requestWrapperAnnot,
            ResponseWrapperAnnot responseWrapperAnnot,
            WebServiceContextAnnot webServiceContextAnnot
    ) {

        this.methodName = methodName;
        this.returnType = returnType;
        this.webMethodAnnot = webMethodAnnot;
        this.webResultAnnot = webResultAnnot;
        this.oneWayAnnotated = oneWayAnnotated;
        this.handlerChainAnnot = handlerChainAnnot;
        this.soapBindingAnnot = soapBindingAnnot;
        this.webServiceRefAnnot = webServiceRefAnnot;
        this.webEndpointAnnot = webEndpointAnnot;
        this.requestWrapperAnnot = requestWrapperAnnot;
        this.responseWrapperAnnot = responseWrapperAnnot;
        this.webServiceContextAnnot = webServiceContextAnnot;
    }

    /** @return Returns the methodName */
    public String getMethodName() {
        return methodName;
    }

    /**
     * Returns the String descrbing this method result type.  Note that this string is unparsed.  For
     * example, if it represents a java.util.List<my.package.Foo>, then that excact string will be
     * returned, i.e. "java.util.List<my.package.Foo>".  You can use other methods on this object to
     * retrieve parsed values for Generics and Holders.
     *
     * @return Returns the returnType
     */
    public String getReturnType() {
        return returnType;
    }

    /**
     * Returns the class associated with the method result type.  Note that if the resturn type a
     * generic (such as java.util.List<my.package.Foo>) then the class associated with the raw type is
     * returned (i.e. java.util.List).
     * <p/>
     * There are other methods that return the class for the actual type for certain JAX-WS specific
     * generics such as Response<T>
     *
     * @return Returns the parameterTypeClass.
     */
    public Class getReturnTypeClass() {
        Class returnTypeClass = null;
        String fullReturnType = getReturnType();
        if (fullReturnType != null) {
            returnTypeClass = DescriptionBuilderUtils.getPrimitiveClass(fullReturnType);
            if (returnTypeClass == null) {
                // If this is a Generic, we need to load the class associated with the Raw Type, 
                // i.e. for List<Foo>, we want to load List. Othwerise, load the type directly. 
                String classToLoad = null;
                if (DescriptionBuilderUtils.getRawType(fullReturnType) != null) {
                    classToLoad = DescriptionBuilderUtils.getRawType(fullReturnType);
                } else {
                    classToLoad = fullReturnType;
                }
                returnTypeClass = loadClassFromMDC(classToLoad);
            }
        }

        return returnTypeClass;
    }

    private Class loadClassFromMDC(String classToLoad) {
        Class returnClass = null;
        ClassLoader classLoader = null;

        if (getDescriptionBuilderCompositeRef() != null) {
            classLoader = getDescriptionBuilderCompositeRef().getClassLoader();
        }
        returnClass = DescriptionBuilderUtils.loadClassFromComposite(classToLoad, classLoader);
        return returnClass;
    }

    /** @return returns whether this is OneWay */
    public boolean isOneWay() {
        return oneWayAnnotated;
    }

    /** @return Returns the webEndpointAnnot. */
    public WebEndpointAnnot getWebEndpointAnnot() {
        return webEndpointAnnot;
    }

    /** @return Returns the requestWrapperAnnot. */
    public RequestWrapperAnnot getRequestWrapperAnnot() {
        return requestWrapperAnnot;
    }

    /** @return Returns the responseWrapperAnnot. */
    public ResponseWrapperAnnot getResponseWrapperAnnot() {
        return responseWrapperAnnot;
    }

    /** @return Returns the webServiceContextAnnot. */
    public WebServiceContextAnnot getWebServiceContextAnnot() {
        return webServiceContextAnnot;
    }

    /** @return Returns the handlerChainAnnot. */
    public HandlerChainAnnot getHandlerChainAnnot() {
        return handlerChainAnnot;
    }

    /** @return Returns the soapBindingAnnot. */
    public SoapBindingAnnot getSoapBindingAnnot() {
        return soapBindingAnnot;
    }

    /** @return Returns the webMethodAnnot. */
    public WebMethodAnnot getWebMethodAnnot() {
        return webMethodAnnot;
    }

    /** @return Returns the webResultAnnot. */
    public WebResultAnnot getWebResultAnnot() {
        return webResultAnnot;
    }

    /** @return Returns the webServiceRefAnnot. */
    public WebServiceRefAnnot getWebServiceRefAnnot() {
        return webServiceRefAnnot;
    }

    /** @return Returns the exceptions. */
    public String[] getExceptions() {
        return exceptions;
    }

    /** @return Returns the exceptions. */
    public Class[] getExceptionTypes() {
        //TODO: Implement this...
        //for each exception in the array, convert it to a class, and return that
        //If a classloader was not set, then just use the default
        Class[] classes = new Class[0];
        return classes;
    }

    /** @return Returns the fully qualified name of the declaring class. */
    public String getDeclaringClass() {
        if (declaringClass == null && parentDBC != null) {
            return parentDBC.getClassName();
        }
        return declaringClass;
    }

    /** @return Returns the ModuleClassType. */
    public DescriptionBuilderComposite getDescriptionBuilderCompositeRef() {

        return this.parentDBC;
    }

    /** @param methodName The methodName to set. */
    public void setMethodName(String methodName) {
        this.methodName = methodName;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?