类javax.xml.bind.annotation.XmlSeeAlso源码实例Demo

下面列出了怎么用javax.xml.bind.annotation.XmlSeeAlso的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: TencentKona-8   文件: SeiGenerator.java
private void writeXmlSeeAlso(JDefinedClass cls) {
    if (model.getJAXBModel().getS2JJAXBModel() != null) {
        List<JClass> objectFactories = model.getJAXBModel().getS2JJAXBModel().getAllObjectFactories();

        //if there are no object facotires, dont generate @XmlSeeAlso
        if (objectFactories.isEmpty()) {
            return;
        }

        JAnnotationUse xmlSeeAlso = cls.annotate(cm.ref(XmlSeeAlso.class));
        JAnnotationArrayMember paramArray = xmlSeeAlso.paramArray("value");
        for (JClass of : objectFactories) {
            paramArray = paramArray.param(of);
        }
    }

}
 
源代码2 项目: jdk8u60   文件: SeiGenerator.java
private void writeXmlSeeAlso(JDefinedClass cls) {
    if (model.getJAXBModel().getS2JJAXBModel() != null) {
        List<JClass> objectFactories = model.getJAXBModel().getS2JJAXBModel().getAllObjectFactories();

        //if there are no object facotires, dont generate @XmlSeeAlso
        if (objectFactories.isEmpty()) {
            return;
        }

        JAnnotationUse xmlSeeAlso = cls.annotate(cm.ref(XmlSeeAlso.class));
        JAnnotationArrayMember paramArray = xmlSeeAlso.paramArray("value");
        for (JClass of : objectFactories) {
            paramArray = paramArray.param(of);
        }
    }

}
 
private static LinkedList<FieldsOfSubType> getFieldsOfSubTypes(Class<?> thisType,
		StubTypeTreeRepository typeTreeRepository) {
	LinkedList<FieldsOfSubType> fieldsOfAllSubTypes = new LinkedList<FieldsOfSubType>();

	if (!thisType.isAnnotationPresent(XmlSeeAlso.class)) {
		return fieldsOfAllSubTypes;
	}

	List<Class<?>> subTypes = getSubTypes(thisType);

	registerToStubTypeTree(thisType, typeTreeRepository, subTypes);

	for (Class<?> subType : subTypes) {
		FieldsOfSubType fieldsOfSubType = new FieldsOfSubType(subType);
		fieldsOfSubType.addAll(Arrays.asList(subType.getDeclaredFields()));
		LinkedList<FieldsOfSubType> fieldsOfGrandSonType = getFieldsOfSubTypes(subType, typeTreeRepository);
		fieldsOfAllSubTypes.add(fieldsOfSubType);
		fieldsOfAllSubTypes.addAll(fieldsOfGrandSonType);
	}

	return fieldsOfAllSubTypes;
}
 
源代码4 项目: openjdk-jdk8u   文件: SeiGenerator.java
private void writeXmlSeeAlso(JDefinedClass cls) {
    if (model.getJAXBModel().getS2JJAXBModel() != null) {
        List<JClass> objectFactories = model.getJAXBModel().getS2JJAXBModel().getAllObjectFactories();

        //if there are no object facotires, dont generate @XmlSeeAlso
        if (objectFactories.isEmpty()) {
            return;
        }

        JAnnotationUse xmlSeeAlso = cls.annotate(cm.ref(XmlSeeAlso.class));
        JAnnotationArrayMember paramArray = xmlSeeAlso.paramArray("value");
        for (JClass of : objectFactories) {
            paramArray = paramArray.param(of);
        }
    }

}
 
源代码5 项目: openjdk-jdk8u-backup   文件: SeiGenerator.java
private void writeXmlSeeAlso(JDefinedClass cls) {
    if (model.getJAXBModel().getS2JJAXBModel() != null) {
        List<JClass> objectFactories = model.getJAXBModel().getS2JJAXBModel().getAllObjectFactories();

        //if there are no object facotires, dont generate @XmlSeeAlso
        if (objectFactories.isEmpty()) {
            return;
        }

        JAnnotationUse xmlSeeAlso = cls.annotate(cm.ref(XmlSeeAlso.class));
        JAnnotationArrayMember paramArray = xmlSeeAlso.paramArray("value");
        for (JClass of : objectFactories) {
            paramArray = paramArray.param(of);
        }
    }

}
 
源代码6 项目: openjdk-jdk9   文件: SeiGenerator.java
private void writeXmlSeeAlso(JDefinedClass cls) {
    if (model.getJAXBModel().getS2JJAXBModel() != null) {
        List<JClass> objectFactories = model.getJAXBModel().getS2JJAXBModel().getAllObjectFactories();

        //if there are no object facotires, dont generate @XmlSeeAlso
        if (objectFactories.isEmpty()) {
            return;
        }

        JAnnotationUse xmlSeeAlso = cls.annotate(cm.ref(XmlSeeAlso.class));
        JAnnotationArrayMember paramArray = xmlSeeAlso.paramArray("value");
        for (JClass of : objectFactories) {
            paramArray = paramArray.param(of);
        }
    }

}
 
源代码7 项目: hottub   文件: SeiGenerator.java
private void writeXmlSeeAlso(JDefinedClass cls) {
    if (model.getJAXBModel().getS2JJAXBModel() != null) {
        List<JClass> objectFactories = model.getJAXBModel().getS2JJAXBModel().getAllObjectFactories();

        //if there are no object facotires, dont generate @XmlSeeAlso
        if (objectFactories.isEmpty()) {
            return;
        }

        JAnnotationUse xmlSeeAlso = cls.annotate(cm.ref(XmlSeeAlso.class));
        JAnnotationArrayMember paramArray = xmlSeeAlso.paramArray("value");
        for (JClass of : objectFactories) {
            paramArray = paramArray.param(of);
        }
    }

}
 
源代码8 项目: openjdk-8-source   文件: SeiGenerator.java
private void writeXmlSeeAlso(JDefinedClass cls) {
    if (model.getJAXBModel().getS2JJAXBModel() != null) {
        List<JClass> objectFactories = model.getJAXBModel().getS2JJAXBModel().getAllObjectFactories();

        //if there are no object facotires, dont generate @XmlSeeAlso
        if (objectFactories.isEmpty()) {
            return;
        }

        JAnnotationUse xmlSeeAlso = cls.annotate(cm.ref(XmlSeeAlso.class));
        JAnnotationArrayMember paramArray = xmlSeeAlso.paramArray("value");
        for (JClass of : objectFactories) {
            paramArray = paramArray.param(of);
        }
    }

}
 
源代码9 项目: openjdk-8   文件: SeiGenerator.java
private void writeXmlSeeAlso(JDefinedClass cls) {
    if (model.getJAXBModel().getS2JJAXBModel() != null) {
        List<JClass> objectFactories = model.getJAXBModel().getS2JJAXBModel().getAllObjectFactories();

        //if there are no object facotires, dont generate @XmlSeeAlso
        if (objectFactories.isEmpty()) {
            return;
        }

        JAnnotationUse xmlSeeAlso = cls.annotate(cm.ref(XmlSeeAlso.class));
        JAnnotationArrayMember paramArray = xmlSeeAlso.paramArray("value");
        for (JClass of : objectFactories) {
            paramArray = paramArray.param(of);
        }
    }

}
 
源代码10 项目: components   文件: TypeUtils.java
/**
 * Traverse XML data object hierarchy and collect all descendants of a root class.
 *
 * @param rootClass root class of type hierarchy
 * @param clazz type class to be processed
 * @param classes set to collect type classes
 */
public static void collectXmlTypes(Class<?> rootClass, Class<?> clazz, Set<Class<?>> classes) {
    if (classes.contains(clazz)) {
        return;
    }

    if (clazz != rootClass && rootClass.isAssignableFrom(clazz) && !Modifier.isAbstract(clazz.getModifiers())) {
        classes.add(clazz);
    }

    XmlSeeAlso xmlSeeAlso = clazz.getAnnotation(XmlSeeAlso.class);
    if (xmlSeeAlso != null) {
        Collection<Class<?>> referencedClasses = new HashSet<>(Arrays.<Class<?>>asList(xmlSeeAlso.value()));
        for (Class<?> referencedClass : referencedClasses) {
            collectXmlTypes(rootClass, referencedClass, classes);
        }
    }
}
 
源代码11 项目: cxf   文件: XmlSeeAlsoAnnotator.java
public void annotate(JavaAnnotatable  ja) {
    if (collector == null || collector.getTypesPackages().isEmpty()) {
        return;
    }

    JavaInterface intf = null;
    if (ja instanceof JavaInterface) {
        intf = (JavaInterface) ja;
    } else {
        throw new RuntimeException("XmlSeeAlso can only annotate JavaInterface");
    }

    JAnnotation jaxbAnnotation = new JAnnotation(XmlSeeAlso.class);
    intf.addImports(jaxbAnnotation.getImports());

    List<JavaType> types = new ArrayList<>();
    for (String pkg : collector.getTypesPackages()) {
        if (pkg.equals(intf.getPackageName())) {
            types.add(new JavaType(null, "ObjectFactory", null));
        } else {
            types.add(new JavaType(null, pkg + ".ObjectFactory", null));
        }
    }
    jaxbAnnotation.addElement(new JAnnotationElement(null, types));
    intf.addAnnotation(jaxbAnnotation);
}
 
private static List<Class<?>> getSubTypes(Class<?> thisType) {
	List<Class<?>> subTypes = new ArrayList<Class<?>>();
	for (Class<?> subType : thisType.getAnnotation(XmlSeeAlso.class).value()) {
		if (thisType.isAssignableFrom(subType)) {
			subTypes.add(subType);
		}
	}
	return subTypes;
}
 
源代码13 项目: cxf   文件: JAnnotationTest.java
@Test
public void testList() throws Exception {
    JAnnotation annotation = new JAnnotation(XmlSeeAlso.class);
    annotation.addElement(new JAnnotationElement(null,
                                                        Arrays.asList(new Class[]{XmlSeeAlso.class})));
    assertEquals("@XmlSeeAlso({XmlSeeAlso.class})", annotation.toString());
    assertEquals("javax.xml.bind.annotation.XmlSeeAlso", annotation.getImports().iterator().next());
}
 
源代码14 项目: TencentKona-8   文件: RuntimeModeler.java
void processClass(Class clazz) {
        classUsesWebMethod = new HashSet<Class>();
        determineWebMethodUse(clazz);
        WebService webService = getAnnotation(clazz, WebService.class);
        QName portTypeName = getPortTypeName(clazz, targetNamespace, metadataReader);
//        String portTypeLocalName  = clazz.getSimpleName();
//        if (webService.name().length() >0)
//            portTypeLocalName = webService.name();
//
//        targetNamespace = webService.targetNamespace();
        packageName = "";
        if (clazz.getPackage() != null)
            packageName = clazz.getPackage().getName();
//        if (targetNamespace.length() == 0) {
//            targetNamespace = getNamespace(packageName);
//        }
//        model.setTargetNamespace(targetNamespace);
//        QName portTypeName = new QName(targetNamespace, portTypeLocalName);
        targetNamespace = portTypeName.getNamespaceURI();
        model.setPortTypeName(portTypeName);
        model.setTargetNamespace(targetNamespace);
        model.defaultSchemaNamespaceSuffix = config.getMappingInfo().getDefaultSchemaNamespaceSuffix();
        model.setWSDLLocation(webService.wsdlLocation());

        SOAPBinding soapBinding = getAnnotation(clazz, SOAPBinding.class);
        if (soapBinding != null) {
            if (soapBinding.style() == SOAPBinding.Style.RPC && soapBinding.parameterStyle() == SOAPBinding.ParameterStyle.BARE) {
                throw new RuntimeModelerException("runtime.modeler.invalid.soapbinding.parameterstyle",
                        soapBinding, clazz);

            }
            isWrapped = soapBinding.parameterStyle()== WRAPPED;
        }
        defaultBinding = createBinding(soapBinding);
        /*
         * if clazz != portClass then there is an SEI.  If there is an
         * SEI, then all methods should be processed.  However, if there is
         * no SEI, and the implementation class uses at least one
         * WebMethod annotation, then only methods with this annotation
         * will be processed.
         */
/*        if (clazz == portClass) {
            WebMethod webMethod;
            for (Method method : clazz.getMethods()) {
                webMethod = getPrivMethodAnnotation(method, WebMethod.class);
                if (webMethod != null &&
                    !webMethod.exclude()) {
                    usesWebMethod = true;
                    break;
                }
            }
        }*/

        for (Method method : clazz.getMethods()) {
            if (!clazz.isInterface()) {     // if clazz is SEI, then all methods are web methods
                if (method.getDeclaringClass() == Object.class) continue;
                if (!getBooleanSystemProperty("com.sun.xml.internal.ws.legacyWebMethod")) {  // legacy webMethod computation behaviour to be used
                    if (!isWebMethodBySpec(method, clazz))
                        continue;
                } else {
                    if (!isWebMethod(method))
                        continue;
                }
            }
            // TODO: binding can be null. We need to figure out how to post-process
            // RuntimeModel to link to WSDLModel
            processMethod(method);
        }
        //Add additional jaxb classes referenced by {@link XmlSeeAlso}
        XmlSeeAlso xmlSeeAlso = getAnnotation(clazz, XmlSeeAlso.class);
        if(xmlSeeAlso != null)
            model.addAdditionalClasses(xmlSeeAlso.value());
    }
 
源代码15 项目: jdk8u60   文件: RuntimeModeler.java
void processClass(Class clazz) {
        classUsesWebMethod = new HashSet<Class>();
        determineWebMethodUse(clazz);
        WebService webService = getAnnotation(clazz, WebService.class);
        QName portTypeName = getPortTypeName(clazz, targetNamespace, metadataReader);
//        String portTypeLocalName  = clazz.getSimpleName();
//        if (webService.name().length() >0)
//            portTypeLocalName = webService.name();
//
//        targetNamespace = webService.targetNamespace();
        packageName = "";
        if (clazz.getPackage() != null)
            packageName = clazz.getPackage().getName();
//        if (targetNamespace.length() == 0) {
//            targetNamespace = getNamespace(packageName);
//        }
//        model.setTargetNamespace(targetNamespace);
//        QName portTypeName = new QName(targetNamespace, portTypeLocalName);
        targetNamespace = portTypeName.getNamespaceURI();
        model.setPortTypeName(portTypeName);
        model.setTargetNamespace(targetNamespace);
        model.defaultSchemaNamespaceSuffix = config.getMappingInfo().getDefaultSchemaNamespaceSuffix();
        model.setWSDLLocation(webService.wsdlLocation());

        SOAPBinding soapBinding = getAnnotation(clazz, SOAPBinding.class);
        if (soapBinding != null) {
            if (soapBinding.style() == SOAPBinding.Style.RPC && soapBinding.parameterStyle() == SOAPBinding.ParameterStyle.BARE) {
                throw new RuntimeModelerException("runtime.modeler.invalid.soapbinding.parameterstyle",
                        soapBinding, clazz);

            }
            isWrapped = soapBinding.parameterStyle()== WRAPPED;
        }
        defaultBinding = createBinding(soapBinding);
        /*
         * if clazz != portClass then there is an SEI.  If there is an
         * SEI, then all methods should be processed.  However, if there is
         * no SEI, and the implementation class uses at least one
         * WebMethod annotation, then only methods with this annotation
         * will be processed.
         */
/*        if (clazz == portClass) {
            WebMethod webMethod;
            for (Method method : clazz.getMethods()) {
                webMethod = getPrivMethodAnnotation(method, WebMethod.class);
                if (webMethod != null &&
                    !webMethod.exclude()) {
                    usesWebMethod = true;
                    break;
                }
            }
        }*/

        for (Method method : clazz.getMethods()) {
            if (!clazz.isInterface()) {     // if clazz is SEI, then all methods are web methods
                if (method.getDeclaringClass() == Object.class) continue;
                if (!getBooleanSystemProperty("com.sun.xml.internal.ws.legacyWebMethod")) {  // legacy webMethod computation behaviour to be used
                    if (!isWebMethodBySpec(method, clazz))
                        continue;
                } else {
                    if (!isWebMethod(method))
                        continue;
                }
            }
            // TODO: binding can be null. We need to figure out how to post-process
            // RuntimeModel to link to WSDLModel
            processMethod(method);
        }
        //Add additional jaxb classes referenced by {@link XmlSeeAlso}
        XmlSeeAlso xmlSeeAlso = getAnnotation(clazz, XmlSeeAlso.class);
        if(xmlSeeAlso != null)
            model.addAdditionalClasses(xmlSeeAlso.value());
    }
 
源代码16 项目: openjdk-jdk8u   文件: RuntimeModeler.java
void processClass(Class clazz) {
        classUsesWebMethod = new HashSet<Class>();
        determineWebMethodUse(clazz);
        WebService webService = getAnnotation(clazz, WebService.class);
        QName portTypeName = getPortTypeName(clazz, targetNamespace, metadataReader);
//        String portTypeLocalName  = clazz.getSimpleName();
//        if (webService.name().length() >0)
//            portTypeLocalName = webService.name();
//
//        targetNamespace = webService.targetNamespace();
        packageName = "";
        if (clazz.getPackage() != null)
            packageName = clazz.getPackage().getName();
//        if (targetNamespace.length() == 0) {
//            targetNamespace = getNamespace(packageName);
//        }
//        model.setTargetNamespace(targetNamespace);
//        QName portTypeName = new QName(targetNamespace, portTypeLocalName);
        targetNamespace = portTypeName.getNamespaceURI();
        model.setPortTypeName(portTypeName);
        model.setTargetNamespace(targetNamespace);
        model.defaultSchemaNamespaceSuffix = config.getMappingInfo().getDefaultSchemaNamespaceSuffix();
        model.setWSDLLocation(webService.wsdlLocation());

        SOAPBinding soapBinding = getAnnotation(clazz, SOAPBinding.class);
        if (soapBinding != null) {
            if (soapBinding.style() == SOAPBinding.Style.RPC && soapBinding.parameterStyle() == SOAPBinding.ParameterStyle.BARE) {
                throw new RuntimeModelerException("runtime.modeler.invalid.soapbinding.parameterstyle",
                        soapBinding, clazz);

            }
            isWrapped = soapBinding.parameterStyle()== WRAPPED;
        }
        defaultBinding = createBinding(soapBinding);
        /*
         * if clazz != portClass then there is an SEI.  If there is an
         * SEI, then all methods should be processed.  However, if there is
         * no SEI, and the implementation class uses at least one
         * WebMethod annotation, then only methods with this annotation
         * will be processed.
         */
/*        if (clazz == portClass) {
            WebMethod webMethod;
            for (Method method : clazz.getMethods()) {
                webMethod = getPrivMethodAnnotation(method, WebMethod.class);
                if (webMethod != null &&
                    !webMethod.exclude()) {
                    usesWebMethod = true;
                    break;
                }
            }
        }*/

        for (Method method : clazz.getMethods()) {
            if (!clazz.isInterface()) {     // if clazz is SEI, then all methods are web methods
                if (method.getDeclaringClass() == Object.class) continue;
                if (!getBooleanSystemProperty("com.sun.xml.internal.ws.legacyWebMethod")) {  // legacy webMethod computation behaviour to be used
                    if (!isWebMethodBySpec(method, clazz))
                        continue;
                } else {
                    if (!isWebMethod(method))
                        continue;
                }
            }
            // TODO: binding can be null. We need to figure out how to post-process
            // RuntimeModel to link to WSDLModel
            processMethod(method);
        }
        //Add additional jaxb classes referenced by {@link XmlSeeAlso}
        XmlSeeAlso xmlSeeAlso = getAnnotation(clazz, XmlSeeAlso.class);
        if(xmlSeeAlso != null)
            model.addAdditionalClasses(xmlSeeAlso.value());
    }
 
源代码17 项目: openjdk-jdk8u-backup   文件: RuntimeModeler.java
void processClass(Class clazz) {
        classUsesWebMethod = new HashSet<Class>();
        determineWebMethodUse(clazz);
        WebService webService = getAnnotation(clazz, WebService.class);
        QName portTypeName = getPortTypeName(clazz, targetNamespace, metadataReader);
//        String portTypeLocalName  = clazz.getSimpleName();
//        if (webService.name().length() >0)
//            portTypeLocalName = webService.name();
//
//        targetNamespace = webService.targetNamespace();
        packageName = "";
        if (clazz.getPackage() != null)
            packageName = clazz.getPackage().getName();
//        if (targetNamespace.length() == 0) {
//            targetNamespace = getNamespace(packageName);
//        }
//        model.setTargetNamespace(targetNamespace);
//        QName portTypeName = new QName(targetNamespace, portTypeLocalName);
        targetNamespace = portTypeName.getNamespaceURI();
        model.setPortTypeName(portTypeName);
        model.setTargetNamespace(targetNamespace);
        model.defaultSchemaNamespaceSuffix = config.getMappingInfo().getDefaultSchemaNamespaceSuffix();
        model.setWSDLLocation(webService.wsdlLocation());

        SOAPBinding soapBinding = getAnnotation(clazz, SOAPBinding.class);
        if (soapBinding != null) {
            if (soapBinding.style() == SOAPBinding.Style.RPC && soapBinding.parameterStyle() == SOAPBinding.ParameterStyle.BARE) {
                throw new RuntimeModelerException("runtime.modeler.invalid.soapbinding.parameterstyle",
                        soapBinding, clazz);

            }
            isWrapped = soapBinding.parameterStyle()== WRAPPED;
        }
        defaultBinding = createBinding(soapBinding);
        /*
         * if clazz != portClass then there is an SEI.  If there is an
         * SEI, then all methods should be processed.  However, if there is
         * no SEI, and the implementation class uses at least one
         * WebMethod annotation, then only methods with this annotation
         * will be processed.
         */
/*        if (clazz == portClass) {
            WebMethod webMethod;
            for (Method method : clazz.getMethods()) {
                webMethod = getPrivMethodAnnotation(method, WebMethod.class);
                if (webMethod != null &&
                    !webMethod.exclude()) {
                    usesWebMethod = true;
                    break;
                }
            }
        }*/

        for (Method method : clazz.getMethods()) {
            if (!clazz.isInterface()) {     // if clazz is SEI, then all methods are web methods
                if (method.getDeclaringClass() == Object.class) continue;
                if (!getBooleanSystemProperty("com.sun.xml.internal.ws.legacyWebMethod")) {  // legacy webMethod computation behaviour to be used
                    if (!isWebMethodBySpec(method, clazz))
                        continue;
                } else {
                    if (!isWebMethod(method))
                        continue;
                }
            }
            // TODO: binding can be null. We need to figure out how to post-process
            // RuntimeModel to link to WSDLModel
            processMethod(method);
        }
        //Add additional jaxb classes referenced by {@link XmlSeeAlso}
        XmlSeeAlso xmlSeeAlso = getAnnotation(clazz, XmlSeeAlso.class);
        if(xmlSeeAlso != null)
            model.addAdditionalClasses(xmlSeeAlso.value());
    }
 
源代码18 项目: openjdk-jdk9   文件: RuntimeModeler.java
void processClass(Class clazz) {
        classUsesWebMethod = new HashSet<Class>();
        determineWebMethodUse(clazz);
        WebService webService = getAnnotation(clazz, WebService.class);
        QName portTypeName = getPortTypeName(clazz, targetNamespace, metadataReader);
//        String portTypeLocalName  = clazz.getSimpleName();
//        if (webService.name().length() >0)
//            portTypeLocalName = webService.name();
//
//        targetNamespace = webService.targetNamespace();
        packageName = "";
        if (clazz.getPackage() != null)
            packageName = clazz.getPackage().getName();
//        if (targetNamespace.length() == 0) {
//            targetNamespace = getNamespace(packageName);
//        }
//        model.setTargetNamespace(targetNamespace);
//        QName portTypeName = new QName(targetNamespace, portTypeLocalName);
        targetNamespace = portTypeName.getNamespaceURI();
        model.setPortTypeName(portTypeName);
        model.setTargetNamespace(targetNamespace);
        model.defaultSchemaNamespaceSuffix = config.getMappingInfo().getDefaultSchemaNamespaceSuffix();
        model.setWSDLLocation(webService.wsdlLocation());

        SOAPBinding soapBinding = getAnnotation(clazz, SOAPBinding.class);
        if (soapBinding != null) {
            if (soapBinding.style() == SOAPBinding.Style.RPC && soapBinding.parameterStyle() == SOAPBinding.ParameterStyle.BARE) {
                throw new RuntimeModelerException("runtime.modeler.invalid.soapbinding.parameterstyle",
                        soapBinding, clazz);

            }
            isWrapped = soapBinding.parameterStyle()== WRAPPED;
        }
        defaultBinding = createBinding(soapBinding);
        /*
         * if clazz != portClass then there is an SEI.  If there is an
         * SEI, then all methods should be processed.  However, if there is
         * no SEI, and the implementation class uses at least one
         * WebMethod annotation, then only methods with this annotation
         * will be processed.
         */
/*        if (clazz == portClass) {
            WebMethod webMethod;
            for (Method method : clazz.getMethods()) {
                webMethod = getPrivMethodAnnotation(method, WebMethod.class);
                if (webMethod != null &&
                    !webMethod.exclude()) {
                    usesWebMethod = true;
                    break;
                }
            }
        }*/

        for (Method method : clazz.getMethods()) {
            if (!clazz.isInterface()) {     // if clazz is SEI, then all methods are web methods
                if (method.getDeclaringClass() == Object.class) continue;
                if (!getBooleanSystemProperty("com.sun.xml.internal.ws.legacyWebMethod")) {  // legacy webMethod computation behaviour to be used
                    if (!isWebMethodBySpec(method, clazz))
                        continue;
                } else {
                    if (!isWebMethod(method))
                        continue;
                }
            }
            // TODO: binding can be null. We need to figure out how to post-process
            // RuntimeModel to link to WSDLModel
            processMethod(method);
        }
        //Add additional jaxb classes referenced by {@link XmlSeeAlso}
        XmlSeeAlso xmlSeeAlso = getAnnotation(clazz, XmlSeeAlso.class);
        if(xmlSeeAlso != null)
            model.addAdditionalClasses(xmlSeeAlso.value());
    }
 
源代码19 项目: hottub   文件: RuntimeModeler.java
void processClass(Class clazz) {
        classUsesWebMethod = new HashSet<Class>();
        determineWebMethodUse(clazz);
        WebService webService = getAnnotation(clazz, WebService.class);
        QName portTypeName = getPortTypeName(clazz, targetNamespace, metadataReader);
//        String portTypeLocalName  = clazz.getSimpleName();
//        if (webService.name().length() >0)
//            portTypeLocalName = webService.name();
//
//        targetNamespace = webService.targetNamespace();
        packageName = "";
        if (clazz.getPackage() != null)
            packageName = clazz.getPackage().getName();
//        if (targetNamespace.length() == 0) {
//            targetNamespace = getNamespace(packageName);
//        }
//        model.setTargetNamespace(targetNamespace);
//        QName portTypeName = new QName(targetNamespace, portTypeLocalName);
        targetNamespace = portTypeName.getNamespaceURI();
        model.setPortTypeName(portTypeName);
        model.setTargetNamespace(targetNamespace);
        model.defaultSchemaNamespaceSuffix = config.getMappingInfo().getDefaultSchemaNamespaceSuffix();
        model.setWSDLLocation(webService.wsdlLocation());

        SOAPBinding soapBinding = getAnnotation(clazz, SOAPBinding.class);
        if (soapBinding != null) {
            if (soapBinding.style() == SOAPBinding.Style.RPC && soapBinding.parameterStyle() == SOAPBinding.ParameterStyle.BARE) {
                throw new RuntimeModelerException("runtime.modeler.invalid.soapbinding.parameterstyle",
                        soapBinding, clazz);

            }
            isWrapped = soapBinding.parameterStyle()== WRAPPED;
        }
        defaultBinding = createBinding(soapBinding);
        /*
         * if clazz != portClass then there is an SEI.  If there is an
         * SEI, then all methods should be processed.  However, if there is
         * no SEI, and the implementation class uses at least one
         * WebMethod annotation, then only methods with this annotation
         * will be processed.
         */
/*        if (clazz == portClass) {
            WebMethod webMethod;
            for (Method method : clazz.getMethods()) {
                webMethod = getPrivMethodAnnotation(method, WebMethod.class);
                if (webMethod != null &&
                    !webMethod.exclude()) {
                    usesWebMethod = true;
                    break;
                }
            }
        }*/

        for (Method method : clazz.getMethods()) {
            if (!clazz.isInterface()) {     // if clazz is SEI, then all methods are web methods
                if (method.getDeclaringClass() == Object.class) continue;
                if (!getBooleanSystemProperty("com.sun.xml.internal.ws.legacyWebMethod")) {  // legacy webMethod computation behaviour to be used
                    if (!isWebMethodBySpec(method, clazz))
                        continue;
                } else {
                    if (!isWebMethod(method))
                        continue;
                }
            }
            // TODO: binding can be null. We need to figure out how to post-process
            // RuntimeModel to link to WSDLModel
            processMethod(method);
        }
        //Add additional jaxb classes referenced by {@link XmlSeeAlso}
        XmlSeeAlso xmlSeeAlso = getAnnotation(clazz, XmlSeeAlso.class);
        if(xmlSeeAlso != null)
            model.addAdditionalClasses(xmlSeeAlso.value());
    }
 
源代码20 项目: openjdk-8-source   文件: RuntimeModeler.java
void processClass(Class clazz) {
        classUsesWebMethod = new HashSet<Class>();
        determineWebMethodUse(clazz);
        WebService webService = getAnnotation(clazz, WebService.class);
        QName portTypeName = getPortTypeName(clazz, targetNamespace, metadataReader);
//        String portTypeLocalName  = clazz.getSimpleName();
//        if (webService.name().length() >0)
//            portTypeLocalName = webService.name();
//
//        targetNamespace = webService.targetNamespace();
        packageName = "";
        if (clazz.getPackage() != null)
            packageName = clazz.getPackage().getName();
//        if (targetNamespace.length() == 0) {
//            targetNamespace = getNamespace(packageName);
//        }
//        model.setTargetNamespace(targetNamespace);
//        QName portTypeName = new QName(targetNamespace, portTypeLocalName);
        targetNamespace = portTypeName.getNamespaceURI();
        model.setPortTypeName(portTypeName);
        model.setTargetNamespace(targetNamespace);
        model.defaultSchemaNamespaceSuffix = config.getMappingInfo().getDefaultSchemaNamespaceSuffix();
        model.setWSDLLocation(webService.wsdlLocation());

        SOAPBinding soapBinding = getAnnotation(clazz, SOAPBinding.class);
        if (soapBinding != null) {
            if (soapBinding.style() == SOAPBinding.Style.RPC && soapBinding.parameterStyle() == SOAPBinding.ParameterStyle.BARE) {
                throw new RuntimeModelerException("runtime.modeler.invalid.soapbinding.parameterstyle",
                        soapBinding, clazz);

            }
            isWrapped = soapBinding.parameterStyle()== WRAPPED;
        }
        defaultBinding = createBinding(soapBinding);
        /*
         * if clazz != portClass then there is an SEI.  If there is an
         * SEI, then all methods should be processed.  However, if there is
         * no SEI, and the implementation class uses at least one
         * WebMethod annotation, then only methods with this annotation
         * will be processed.
         */
/*        if (clazz == portClass) {
            WebMethod webMethod;
            for (Method method : clazz.getMethods()) {
                webMethod = getPrivMethodAnnotation(method, WebMethod.class);
                if (webMethod != null &&
                    !webMethod.exclude()) {
                    usesWebMethod = true;
                    break;
                }
            }
        }*/

        for (Method method : clazz.getMethods()) {
            if (!clazz.isInterface()) {     // if clazz is SEI, then all methods are web methods
                if (method.getDeclaringClass() == Object.class) continue;
                if (!getBooleanSystemProperty("com.sun.xml.internal.ws.legacyWebMethod")) {  // legacy webMethod computation behaviour to be used
                    if (!isWebMethodBySpec(method, clazz))
                        continue;
                } else {
                    if (!isWebMethod(method))
                        continue;
                }
            }
            // TODO: binding can be null. We need to figure out how to post-process
            // RuntimeModel to link to WSDLModel
            processMethod(method);
        }
        //Add additional jaxb classes referenced by {@link XmlSeeAlso}
        XmlSeeAlso xmlSeeAlso = getAnnotation(clazz, XmlSeeAlso.class);
        if(xmlSeeAlso != null)
            model.addAdditionalClasses(xmlSeeAlso.value());
    }
 
源代码21 项目: openjdk-8   文件: RuntimeModeler.java
void processClass(Class clazz) {
        classUsesWebMethod = new HashSet<Class>();
        determineWebMethodUse(clazz);
        WebService webService = getAnnotation(clazz, WebService.class);
        QName portTypeName = getPortTypeName(clazz, targetNamespace, metadataReader);
//        String portTypeLocalName  = clazz.getSimpleName();
//        if (webService.name().length() >0)
//            portTypeLocalName = webService.name();
//
//        targetNamespace = webService.targetNamespace();
        packageName = "";
        if (clazz.getPackage() != null)
            packageName = clazz.getPackage().getName();
//        if (targetNamespace.length() == 0) {
//            targetNamespace = getNamespace(packageName);
//        }
//        model.setTargetNamespace(targetNamespace);
//        QName portTypeName = new QName(targetNamespace, portTypeLocalName);
        targetNamespace = portTypeName.getNamespaceURI();
        model.setPortTypeName(portTypeName);
        model.setTargetNamespace(targetNamespace);
        model.defaultSchemaNamespaceSuffix = config.getMappingInfo().getDefaultSchemaNamespaceSuffix();
        model.setWSDLLocation(webService.wsdlLocation());

        SOAPBinding soapBinding = getAnnotation(clazz, SOAPBinding.class);
        if (soapBinding != null) {
            if (soapBinding.style() == SOAPBinding.Style.RPC && soapBinding.parameterStyle() == SOAPBinding.ParameterStyle.BARE) {
                throw new RuntimeModelerException("runtime.modeler.invalid.soapbinding.parameterstyle",
                        soapBinding, clazz);

            }
            isWrapped = soapBinding.parameterStyle()== WRAPPED;
        }
        defaultBinding = createBinding(soapBinding);
        /*
         * if clazz != portClass then there is an SEI.  If there is an
         * SEI, then all methods should be processed.  However, if there is
         * no SEI, and the implementation class uses at least one
         * WebMethod annotation, then only methods with this annotation
         * will be processed.
         */
/*        if (clazz == portClass) {
            WebMethod webMethod;
            for (Method method : clazz.getMethods()) {
                webMethod = getPrivMethodAnnotation(method, WebMethod.class);
                if (webMethod != null &&
                    !webMethod.exclude()) {
                    usesWebMethod = true;
                    break;
                }
            }
        }*/

        for (Method method : clazz.getMethods()) {
            if (!clazz.isInterface()) {     // if clazz is SEI, then all methods are web methods
                if (method.getDeclaringClass() == Object.class) continue;
                if (!getBooleanSystemProperty("com.sun.xml.internal.ws.legacyWebMethod")) {  // legacy webMethod computation behaviour to be used
                    if (!isWebMethodBySpec(method, clazz))
                        continue;
                } else {
                    if (!isWebMethod(method))
                        continue;
                }
            }
            // TODO: binding can be null. We need to figure out how to post-process
            // RuntimeModel to link to WSDLModel
            processMethod(method);
        }
        //Add additional jaxb classes referenced by {@link XmlSeeAlso}
        XmlSeeAlso xmlSeeAlso = getAnnotation(clazz, XmlSeeAlso.class);
        if(xmlSeeAlso != null)
            model.addAdditionalClasses(xmlSeeAlso.value());
    }
 
源代码22 项目: cxf   文件: JAXBContextInitializer.java
void addClass(Class<?> claz) {
    if (Throwable.class.isAssignableFrom(claz)) {
        if (!Throwable.class.equals(claz)
            && !Exception.class.equals(claz)) {
            walkReferences(claz);
        }
        addClass(String.class);
    } else if (claz.getName().startsWith("java.")
        || claz.getName().startsWith("javax.")) {
        return;
    } else {
        Class<?> cls = JAXBUtils.getValidClass(claz);
        if (cls == null
            && ReflectionUtil.getDeclaredConstructors(claz).length > 0
            && !Modifier.isAbstract(claz.getModifiers())) {
            if (LOG.isLoggable(Level.INFO)) {
                LOG.info("Class " + claz.getName() + " does not have a default constructor which JAXB requires.");
            }
            //there is no init(), but other constructors
            Object factory = createFactory(claz, ReflectionUtil.getDeclaredConstructors(claz)[0]);
            unmarshallerProperties.put("com.sun.xml.bind.ObjectFactory", factory);
            cls = claz;
        }
        if (null != cls) {
            if (classes.contains(cls)) {
                return;
            }

            if (!cls.isInterface()) {
                classes.add(cls);
            }

            XmlSeeAlso xsa = cls.getAnnotation(XmlSeeAlso.class);
            if (xsa != null) {
                for (Class<?> c : xsa.value()) {
                    addClass(c);
                }
            }
            XmlJavaTypeAdapter xjta = cls.getAnnotation(XmlJavaTypeAdapter.class);
            if (xjta != null) {
                //has an adapter.   We need to inspect the adapter and then
                //return as the adapter will handle the superclass
                //and interfaces and such
                Type t = Utils.getTypeFromXmlAdapter(xjta);
                if (t != null) {
                    addType(t);
                }
                return;
            }

            if (cls.getSuperclass() != null) {
                //JAXB should do this, but it doesn't always.
                //in particular, older versions of jaxb don't
                addClass(cls.getSuperclass());
            }

            if (!cls.isInterface()) {
                walkReferences(cls);
            }
        }
    }
}
 
 同包方法