descriptionbuildercomposite.java

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

JAVA
493
字号
/*
 * 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 javax.wsdl.Definition;
import java.net.URL;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class DescriptionBuilderComposite implements TMAnnotationComposite, TMFAnnotationComposite {
    /*
      * This structure contains the full reflected class, as well as, the
      * possible annotations found for this class...the class description
      * must be complete enough for full validation between class info and annotations
      * The annotations will be added to the corresponding class members.
      */

    public DescriptionBuilderComposite() {

        methodDescriptions = new ArrayList<MethodDescriptionComposite>();
        fieldDescriptions = new ArrayList<FieldDescriptionComposite>();
        webServiceRefAnnotList = new ArrayList<WebServiceRefAnnot>();
        interfacesList = new ArrayList<String>();
    }

    //Class type within the module
    public static enum ModuleClassType {
        SERVICEIMPL, SEI, SERVICE, SUPER, PROVIDER, FAULT}

    private ModuleClassType moduleClassType = null;

    //Note: a WSDL is not necessary
    private Definition wsdlDefinition = null;
    private URL wsdlURL = null;

    // Class-level annotations
    private WebServiceAnnot webServiceAnnot;
    private WebServiceProviderAnnot webServiceProviderAnnot;
    private ServiceModeAnnot serviceModeAnnot;
    private WebServiceClientAnnot webServiceClientAnnot;
    private WebFaultAnnot webFaultAnnot;
    private HandlerChainAnnot handlerChainAnnot;
    private SoapBindingAnnot soapBindingAnnot;
    private List<WebServiceRefAnnot> webServiceRefAnnotList;
    private BindingTypeAnnot bindingTypeAnnot;
    private WebServiceContextAnnot webServiceContextAnnot;

    // Class information
    private String className;
    private String[] classModifiers; //public, abstract, final, strictfp...
    private String extendsClass;    //Set to the name of the super class
    private List<String> interfacesList; //Set this for all implemented interfaces
    private boolean isInterface = false;

    private List<MethodDescriptionComposite> methodDescriptions;
    private List<FieldDescriptionComposite> fieldDescriptions;

    private WsdlGenerator wsdlGenerator;
    private ClassLoader classLoader;

    // Methods
    public WebServiceAnnot getWebServiceAnnot() {
        return this.webServiceAnnot;
    }

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

    /** @return Returns the className. */
    public String getClassName() {
        return className;
    }

    /** @return Returns the super class name. */
    public String getSuperClassName() {
        return extendsClass;
    }

    /** @return Returns the list of implemented interfaces. */
    public List<String> getInterfacesList() {
        return interfacesList;
    }

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

    /** @return Returns the serviceModeAnnot. */
    public ServiceModeAnnot getServiceModeAnnot() {
        return serviceModeAnnot;
    }

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

    /** @return Returns the webFaultAnnot. */
    public WebFaultAnnot getWebFaultAnnot() {
        return webFaultAnnot;
    }

    /** @return Returns the webServiceClientAnnot. */
    public WebServiceClientAnnot getWebServiceClientAnnot() {
        return webServiceClientAnnot;
    }

    /** @return Returns the webServiceProviderAnnot. */
    public WebServiceProviderAnnot getWebServiceProviderAnnot() {
        return webServiceProviderAnnot;
    }

    /** @return Returns the webServiceRefAnnot list. */
    public List<WebServiceRefAnnot> getAllWebServiceRefAnnots() {
        return webServiceRefAnnotList;
    }

    /** @return Returns the webServiceRefAnnot. */
    public WebServiceRefAnnot getWebServiceRefAnnot(String name) {

        WebServiceRefAnnot wsra = null;
        Iterator<WebServiceRefAnnot> iter =
                webServiceRefAnnotList.iterator();

        while (iter.hasNext()) {
            wsra = iter.next();
            if (wsra.name().equals(name))
                return wsra;
        }
        return wsra;
    }

    /** @return Returns the webServiceRefAnnot. */
    public BindingTypeAnnot getBindingTypeAnnot() {
        return bindingTypeAnnot;
    }

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

    /** @return Returns the wsdlDefinition */
    public Definition getWsdlDefinition() {
        return wsdlDefinition;
    }

    /** @return Returns the wsdlURL */
    public URL getWsdlURL() {
        return this.wsdlURL;
    }

    /** Returns a collection of all MethodDescriptionComposites that match the specified name */
    public List<MethodDescriptionComposite> getMethodDescriptionComposite(String methodName) {
        ArrayList<MethodDescriptionComposite> matchingMethods =
                new ArrayList<MethodDescriptionComposite>();
        Iterator<MethodDescriptionComposite> iter = methodDescriptions.iterator();
        while (iter.hasNext()) {
            MethodDescriptionComposite composite = iter.next();

            if (composite.getMethodName() != null) {
                if (composite.getMethodName().equals(methodName)) {
                    matchingMethods.add(composite);
                }
            }
        }

        return matchingMethods;
    }

    /**
     * Returns the nth occurence of this MethodComposite. Since method names are not unique, we have
     * to account for multiple occurrences
     *
     * @param methodName
     * @param occurence  The nth occurance to return; not this is NOT 0 based
     * @return Returns the methodDescriptionComposite
     */
    public MethodDescriptionComposite getMethodDescriptionComposite(
            String methodName,
            int occurence) {
        MethodDescriptionComposite returnMDC = null;
        List<MethodDescriptionComposite> matchingMethods =
                getMethodDescriptionComposite(methodName);
        if (matchingMethods != null && !matchingMethods.isEmpty() &&
                occurence > 0 && occurence <= matchingMethods.size()) {
            returnMDC = matchingMethods.get(--occurence);
        }
        return returnMDC;
    }

    public List<MethodDescriptionComposite> getMethodDescriptionsList() {
        return methodDescriptions;
    }

    /** @return Returns the methodDescriptionComposite..null if not found */
    public FieldDescriptionComposite getFieldDescriptionComposite(String fieldName) {

        FieldDescriptionComposite composite = null;
        Iterator<FieldDescriptionComposite> iter =
                fieldDescriptions.iterator();

        while (iter.hasNext()) {
            composite = iter.next();
            if (composite.getFieldName().equals(fieldName))
                return composite;
        }
        return composite;
    }

    /** @return Returns the ModuleClassType. */
    public WsdlGenerator getCustomWsdlGenerator() {

        return this.wsdlGenerator;
    }

    /** @return Returns the ClassLoader. */
    public ClassLoader getClassLoader() {

        return this.classLoader;
    }

    /** @return Returns true if this is an interface */

⌨️ 快捷键说明

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