javax.xml.bind.annotation.XmlSeeAlso Java Examples
The following examples show how to use
javax.xml.bind.annotation.XmlSeeAlso.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SeiGenerator.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
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); } } }
Example #2
Source File: XmlSeeAlsoAnnotator.java From cxf with Apache License 2.0 | 6 votes |
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); }
Example #3
Source File: TypeUtils.java From components with Apache License 2.0 | 6 votes |
/** * 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); } } }
Example #4
Source File: SeiGenerator.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
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); } } }
Example #5
Source File: SeiGenerator.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
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); } } }
Example #6
Source File: SeiGenerator.java From hottub with GNU General Public License v2.0 | 6 votes |
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); } } }
Example #7
Source File: SeiGenerator.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
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); } } }
Example #8
Source File: SeiGenerator.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
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); } } }
Example #9
Source File: SeiGenerator.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
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); } } }
Example #10
Source File: Variable2Stub.java From document-management-software with GNU Lesser General Public License v3.0 | 6 votes |
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; }
Example #11
Source File: SeiGenerator.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
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); } } }
Example #12
Source File: Variable2Stub.java From document-management-software with GNU Lesser General Public License v3.0 | 5 votes |
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; }
Example #13
Source File: JAnnotationTest.java From cxf with Apache License 2.0 | 5 votes |
@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()); }
Example #14
Source File: RuntimeModeler.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
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()); }
Example #15
Source File: RuntimeModeler.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
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()); }
Example #16
Source File: RuntimeModeler.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
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()); }
Example #17
Source File: RuntimeModeler.java From hottub with GNU General Public License v2.0 | 4 votes |
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()); }
Example #18
Source File: RuntimeModeler.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
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()); }
Example #19
Source File: RuntimeModeler.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
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()); }
Example #20
Source File: RuntimeModeler.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
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()); }
Example #21
Source File: RuntimeModeler.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
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()); }
Example #22
Source File: JAXBContextInitializer.java From cxf with Apache License 2.0 | 4 votes |
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); } } } }