Java Code Examples for javax.xml.bind.annotation.XmlType#namespace()
The following examples show how to use
javax.xml.bind.annotation.XmlType#namespace() .
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: SchemaCollectionContextProxy.java From cxf with Apache License 2.0 | 6 votes |
private QName getTypeQName(Class<?> cls, String namespace) { QName qn = TYPE_MAP.get(cls); if (qn != null) { return qn; } XmlType xtype = cls.getAnnotation(XmlType.class); String tn = xtype == null ? "##default" : xtype.name(); String tns = xtype == null ? "##default" : xtype.namespace(); if ("##default".equals(tn)) { tn = java.beans.Introspector.decapitalize(cls.getSimpleName()); } if ("##default".equals(tns) || StringUtils.isEmpty(tns)) { tns = JAXBUtils.getPackageNamespace(cls); } if ("##default".equals(tns) || StringUtils.isEmpty(tns)) { tns = namespace; } return new QName(tns, tn); }
Example 2
Source File: TypeInfoImpl.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Parses a (potentially-null) {@link XmlType} annotation on a class * and determine the actual value. * * @param clazz * The class on which the XmlType annotation is checked. * @param t * The {@link XmlType} annotation on the clazz. This value * is taken as a parameter to improve the performance for the case where * 't' is pre-computed. */ protected final QName parseTypeName(ClassDeclT clazz, XmlType t) { String nsUri="##default"; String local="##default"; if(t!=null) { nsUri = t.namespace(); local = t.name(); } if(local.length()==0) return null; // anonymous if(local.equals("##default")) // if defaulted ... local = NameConverter.standard.toVariableName(nav().getClassShortName(clazz)); if(nsUri.equals("##default")) { // if defaulted ... XmlSchema xs = reader().getPackageAnnotation(XmlSchema.class,clazz,this); if(xs!=null) nsUri = xs.namespace(); else { nsUri = builder.defaultNsUri; } } return new QName(nsUri.intern(),local.intern()); }
Example 3
Source File: PluginContext.java From jaxb2-rich-contract-plugin with MIT License | 5 votes |
private static String getNamespaceUri(final Class<?> boundClass) { final XmlRootElement elementAnnotation = boundClass.getAnnotation(XmlRootElement.class); if (elementAnnotation != null && !"##default".equals(elementAnnotation.namespace())) { return elementAnnotation.namespace(); } else { final XmlType xmlTypeAnnotation = boundClass.getAnnotation(XmlType.class); if (xmlTypeAnnotation != null && !"##default".equals(xmlTypeAnnotation.namespace())) { return xmlTypeAnnotation.namespace(); } else { return getNamespaceUri(boundClass.getPackage()); } } }
Example 4
Source File: TypeInfoImpl.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
/** * Parses a (potentially-null) {@link XmlType} annotation on a class * and determine the actual value. * * @param clazz * The class on which the XmlType annotation is checked. * @param t * The {@link XmlType} annotation on the clazz. This value * is taken as a parameter to improve the performance for the case where * 't' is pre-computed. */ protected final QName parseTypeName(ClassDeclT clazz, XmlType t) { String nsUri="##default"; String local="##default"; if(t!=null) { nsUri = t.namespace(); local = t.name(); } if(local.length()==0) return null; // anonymous if(local.equals("##default")) // if defaulted ... local = NameConverter.standard.toVariableName(nav().getClassShortName(clazz)); if(nsUri.equals("##default")) { // if defaulted ... XmlSchema xs = reader().getPackageAnnotation(XmlSchema.class,clazz,this); if(xs!=null) nsUri = xs.namespace(); else { nsUri = builder.defaultNsUri; } } return new QName(nsUri.intern(),local.intern()); }
Example 5
Source File: TypeInfoImpl.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
/** * Parses a (potentially-null) {@link XmlType} annotation on a class * and determine the actual value. * * @param clazz * The class on which the XmlType annotation is checked. * @param t * The {@link XmlType} annotation on the clazz. This value * is taken as a parameter to improve the performance for the case where * 't' is pre-computed. */ protected final QName parseTypeName(ClassDeclT clazz, XmlType t) { String nsUri="##default"; String local="##default"; if(t!=null) { nsUri = t.namespace(); local = t.name(); } if(local.length()==0) return null; // anonymous if(local.equals("##default")) // if defaulted ... local = NameConverter.standard.toVariableName(nav().getClassShortName(clazz)); if(nsUri.equals("##default")) { // if defaulted ... XmlSchema xs = reader().getPackageAnnotation(XmlSchema.class,clazz,this); if(xs!=null) nsUri = xs.namespace(); else { nsUri = builder.defaultNsUri; } } return new QName(nsUri.intern(),local.intern()); }
Example 6
Source File: TypeInfoImpl.java From hottub with GNU General Public License v2.0 | 5 votes |
/** * Parses a (potentially-null) {@link XmlType} annotation on a class * and determine the actual value. * * @param clazz * The class on which the XmlType annotation is checked. * @param t * The {@link XmlType} annotation on the clazz. This value * is taken as a parameter to improve the performance for the case where * 't' is pre-computed. */ protected final QName parseTypeName(ClassDeclT clazz, XmlType t) { String nsUri="##default"; String local="##default"; if(t!=null) { nsUri = t.namespace(); local = t.name(); } if(local.length()==0) return null; // anonymous if(local.equals("##default")) // if defaulted ... local = NameConverter.standard.toVariableName(nav().getClassShortName(clazz)); if(nsUri.equals("##default")) { // if defaulted ... XmlSchema xs = reader().getPackageAnnotation(XmlSchema.class,clazz,this); if(xs!=null) nsUri = xs.namespace(); else { nsUri = builder.defaultNsUri; } } return new QName(nsUri.intern(),local.intern()); }
Example 7
Source File: TypeInfoImpl.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * Parses a (potentially-null) {@link XmlType} annotation on a class * and determine the actual value. * * @param clazz * The class on which the XmlType annotation is checked. * @param t * The {@link XmlType} annotation on the clazz. This value * is taken as a parameter to improve the performance for the case where * 't' is pre-computed. */ protected final QName parseTypeName(ClassDeclT clazz, XmlType t) { String nsUri="##default"; String local="##default"; if(t!=null) { nsUri = t.namespace(); local = t.name(); } if(local.length()==0) return null; // anonymous if(local.equals("##default")) // if defaulted ... local = NameConverter.standard.toVariableName(nav().getClassShortName(clazz)); if(nsUri.equals("##default")) { // if defaulted ... XmlSchema xs = reader().getPackageAnnotation(XmlSchema.class,clazz,this); if(xs!=null) nsUri = xs.namespace(); else { nsUri = builder.defaultNsUri; } } return new QName(nsUri.intern(),local.intern()); }
Example 8
Source File: TypeInfoImpl.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * Parses a (potentially-null) {@link XmlType} annotation on a class * and determine the actual value. * * @param clazz * The class on which the XmlType annotation is checked. * @param t * The {@link XmlType} annotation on the clazz. This value * is taken as a parameter to improve the performance for the case where * 't' is pre-computed. */ protected final QName parseTypeName(ClassDeclT clazz, XmlType t) { String nsUri="##default"; String local="##default"; if(t!=null) { nsUri = t.namespace(); local = t.name(); } if(local.length()==0) return null; // anonymous if(local.equals("##default")) // if defaulted ... local = NameConverter.standard.toVariableName(nav().getClassShortName(clazz)); if(nsUri.equals("##default")) { // if defaulted ... XmlSchema xs = reader().getPackageAnnotation(XmlSchema.class,clazz,this); if(xs!=null) nsUri = xs.namespace(); else { nsUri = builder.defaultNsUri; } } return new QName(nsUri.intern(),local.intern()); }
Example 9
Source File: TypeInfoImpl.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * Parses a (potentially-null) {@link XmlType} annotation on a class * and determine the actual value. * * @param clazz * The class on which the XmlType annotation is checked. * @param t * The {@link XmlType} annotation on the clazz. This value * is taken as a parameter to improve the performance for the case where * 't' is pre-computed. */ protected final QName parseTypeName(ClassDeclT clazz, XmlType t) { String nsUri="##default"; String local="##default"; if(t!=null) { nsUri = t.namespace(); local = t.name(); } if(local.length()==0) return null; // anonymous if(local.equals("##default")) // if defaulted ... local = NameConverter.standard.toVariableName(nav().getClassShortName(clazz)); if(nsUri.equals("##default")) { // if defaulted ... XmlSchema xs = reader().getPackageAnnotation(XmlSchema.class,clazz,this); if(xs!=null) nsUri = xs.namespace(); else { nsUri = builder.defaultNsUri; } } return new QName(nsUri.intern(),local.intern()); }
Example 10
Source File: TypeInfoImpl.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * Parses a (potentially-null) {@link XmlType} annotation on a class * and determine the actual value. * * @param clazz * The class on which the XmlType annotation is checked. * @param t * The {@link XmlType} annotation on the clazz. This value * is taken as a parameter to improve the performance for the case where * 't' is pre-computed. */ protected final QName parseTypeName(ClassDeclT clazz, XmlType t) { String nsUri="##default"; String local="##default"; if(t!=null) { nsUri = t.namespace(); local = t.name(); } if(local.length()==0) return null; // anonymous if(local.equals("##default")) // if defaulted ... local = NameConverter.standard.toVariableName(nav().getClassShortName(clazz)); if(nsUri.equals("##default")) { // if defaulted ... XmlSchema xs = reader().getPackageAnnotation(XmlSchema.class,clazz,this); if(xs!=null) nsUri = xs.namespace(); else { nsUri = builder.defaultNsUri; } } return new QName(nsUri.intern(),local.intern()); }
Example 11
Source File: WebServiceWrapperGenerator.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
private boolean generateExceptionBean(TypeElement thrownDecl, String beanPackage) { if (!builder.isServiceException(thrownDecl.asType())) return false; String exceptionName = ClassNameInfo.getName(thrownDecl.getQualifiedName().toString()); if (processedExceptions.contains(exceptionName)) return false; processedExceptions.add(exceptionName); WebFault webFault = thrownDecl.getAnnotation(WebFault.class); String className = beanPackage+ exceptionName + BEAN.getValue(); Collection<MemberInfo> members = ap_generator.collectExceptionBeanMembers(thrownDecl); boolean isWSDLException = isWSDLException(members, thrownDecl); String namespace = typeNamespace; String name = exceptionName; FaultInfo faultInfo; if (isWSDLException) { TypeMirror beanType = getFaultInfoMember(members).getParamType(); faultInfo = new FaultInfo(TypeMonikerFactory.getTypeMoniker(beanType), true); namespace = webFault.targetNamespace().length()>0 ? webFault.targetNamespace() : namespace; name = webFault.name().length()>0 ? webFault.name() : name; faultInfo.setElementName(new QName(namespace, name)); seiContext.addExceptionBeanEntry(thrownDecl.getQualifiedName(), faultInfo, builder); return false; } if (webFault != null) { namespace = webFault.targetNamespace().length()>0 ? webFault.targetNamespace() : namespace; name = webFault.name().length()>0 ? webFault.name() : name; className = webFault.faultBean().length()>0 ? webFault.faultBean() : className; } JDefinedClass cls = getCMClass(className, CLASS); faultInfo = new FaultInfo(className, false); if (duplicateName(className)) { builder.processError(WebserviceapMessages.WEBSERVICEAP_METHOD_EXCEPTION_BEAN_NAME_NOT_UNIQUE( typeElement.getQualifiedName(), thrownDecl.getQualifiedName())); } boolean canOverWriteBean = builder.canOverWriteClass(className); if (!canOverWriteBean) { builder.log("Class " + className + " exists. Not overwriting."); seiContext.addExceptionBeanEntry(thrownDecl.getQualifiedName(), faultInfo, builder); return false; } if (seiContext.getExceptionBeanName(thrownDecl.getQualifiedName()) != null) return false; //write class comment - JAXWS warning JDocComment comment = cls.javadoc(); for (String doc : GeneratorBase.getJAXWSClassComment(ToolVersion.VERSION.MAJOR_VERSION)) { comment.add(doc); } // XmlElement Declarations writeXmlElementDeclaration(cls, name, namespace); // XmlType Declaration //members = sortMembers(members); XmlType xmlType = thrownDecl.getAnnotation(XmlType.class); String xmlTypeName = (xmlType != null && !xmlType.name().equals("##default")) ? xmlType.name() : exceptionName; String xmlTypeNamespace = (xmlType != null && !xmlType.namespace().equals("##default")) ? xmlType.namespace() : typeNamespace; writeXmlTypeDeclaration(cls, xmlTypeName, xmlTypeNamespace, members); writeMembers(cls, members); seiContext.addExceptionBeanEntry(thrownDecl.getQualifiedName(), faultInfo, builder); return true; }
Example 12
Source File: WebServiceWrapperGenerator.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
private boolean generateExceptionBean(TypeElement thrownDecl, String beanPackage) { if (!builder.isServiceException(thrownDecl.asType())) return false; String exceptionName = ClassNameInfo.getName(thrownDecl.getQualifiedName().toString()); if (processedExceptions.contains(exceptionName)) return false; processedExceptions.add(exceptionName); WebFault webFault = thrownDecl.getAnnotation(WebFault.class); String className = beanPackage+ exceptionName + BEAN.getValue(); Collection<MemberInfo> members = ap_generator.collectExceptionBeanMembers(thrownDecl); boolean isWSDLException = isWSDLException(members, thrownDecl); String namespace = typeNamespace; String name = exceptionName; FaultInfo faultInfo; if (isWSDLException) { TypeMirror beanType = getFaultInfoMember(members).getParamType(); faultInfo = new FaultInfo(TypeMonikerFactory.getTypeMoniker(beanType), true); namespace = webFault.targetNamespace().length()>0 ? webFault.targetNamespace() : namespace; name = webFault.name().length()>0 ? webFault.name() : name; faultInfo.setElementName(new QName(namespace, name)); seiContext.addExceptionBeanEntry(thrownDecl.getQualifiedName(), faultInfo, builder); return false; } if (webFault != null) { namespace = webFault.targetNamespace().length()>0 ? webFault.targetNamespace() : namespace; name = webFault.name().length()>0 ? webFault.name() : name; className = webFault.faultBean().length()>0 ? webFault.faultBean() : className; } JDefinedClass cls = getCMClass(className, CLASS); faultInfo = new FaultInfo(className, false); if (duplicateName(className)) { builder.processError(WebserviceapMessages.WEBSERVICEAP_METHOD_EXCEPTION_BEAN_NAME_NOT_UNIQUE( typeElement.getQualifiedName(), thrownDecl.getQualifiedName())); } boolean canOverWriteBean = builder.canOverWriteClass(className); if (!canOverWriteBean) { builder.log("Class " + className + " exists. Not overwriting."); seiContext.addExceptionBeanEntry(thrownDecl.getQualifiedName(), faultInfo, builder); return false; } if (seiContext.getExceptionBeanName(thrownDecl.getQualifiedName()) != null) { return false; } addGeneratedFile(className); //write class comment - JAXWS warning JDocComment comment = cls.javadoc(); for (String doc : GeneratorBase.getJAXWSClassComment(ToolVersion.VERSION.MAJOR_VERSION)) { comment.add(doc); } // XmlElement Declarations writeXmlElementDeclaration(cls, name, namespace); // XmlType Declaration //members = sortMembers(members); XmlType xmlType = thrownDecl.getAnnotation(XmlType.class); String xmlTypeName = (xmlType != null && !xmlType.name().equals("##default")) ? xmlType.name() : exceptionName; String xmlTypeNamespace = (xmlType != null && !xmlType.namespace().equals("##default")) ? xmlType.namespace() : typeNamespace; writeXmlTypeDeclaration(cls, xmlTypeName, xmlTypeNamespace, members); writeMembers(cls, members); seiContext.addExceptionBeanEntry(thrownDecl.getQualifiedName(), faultInfo, builder); return true; }
Example 13
Source File: WebServiceWrapperGenerator.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
private boolean generateExceptionBean(TypeElement thrownDecl, String beanPackage) { if (!builder.isServiceException(thrownDecl.asType())) return false; String exceptionName = ClassNameInfo.getName(thrownDecl.getQualifiedName().toString()); if (processedExceptions.contains(exceptionName)) return false; processedExceptions.add(exceptionName); WebFault webFault = thrownDecl.getAnnotation(WebFault.class); String className = beanPackage+ exceptionName + BEAN.getValue(); Collection<MemberInfo> members = ap_generator.collectExceptionBeanMembers(thrownDecl); boolean isWSDLException = isWSDLException(members, thrownDecl); String namespace = typeNamespace; String name = exceptionName; FaultInfo faultInfo; if (isWSDLException) { TypeMirror beanType = getFaultInfoMember(members).getParamType(); faultInfo = new FaultInfo(TypeMonikerFactory.getTypeMoniker(beanType), true); namespace = webFault.targetNamespace().length()>0 ? webFault.targetNamespace() : namespace; name = webFault.name().length()>0 ? webFault.name() : name; faultInfo.setElementName(new QName(namespace, name)); seiContext.addExceptionBeanEntry(thrownDecl.getQualifiedName(), faultInfo, builder); return false; } if (webFault != null) { namespace = webFault.targetNamespace().length()>0 ? webFault.targetNamespace() : namespace; name = webFault.name().length()>0 ? webFault.name() : name; className = webFault.faultBean().length()>0 ? webFault.faultBean() : className; } JDefinedClass cls = getCMClass(className, CLASS); faultInfo = new FaultInfo(className, false); if (duplicateName(className)) { builder.processError(WebserviceapMessages.WEBSERVICEAP_METHOD_EXCEPTION_BEAN_NAME_NOT_UNIQUE( typeElement.getQualifiedName(), thrownDecl.getQualifiedName())); } boolean canOverWriteBean = builder.canOverWriteClass(className); if (!canOverWriteBean) { builder.log("Class " + className + " exists. Not overwriting."); seiContext.addExceptionBeanEntry(thrownDecl.getQualifiedName(), faultInfo, builder); return false; } if (seiContext.getExceptionBeanName(thrownDecl.getQualifiedName()) != null) return false; //write class comment - JAXWS warning JDocComment comment = cls.javadoc(); for (String doc : GeneratorBase.getJAXWSClassComment(ToolVersion.VERSION.MAJOR_VERSION)) { comment.add(doc); } // XmlElement Declarations writeXmlElementDeclaration(cls, name, namespace); // XmlType Declaration //members = sortMembers(members); XmlType xmlType = thrownDecl.getAnnotation(XmlType.class); String xmlTypeName = (xmlType != null && !xmlType.name().equals("##default")) ? xmlType.name() : exceptionName; String xmlTypeNamespace = (xmlType != null && !xmlType.namespace().equals("##default")) ? xmlType.namespace() : typeNamespace; writeXmlTypeDeclaration(cls, xmlTypeName, xmlTypeNamespace, members); writeMembers(cls, members); seiContext.addExceptionBeanEntry(thrownDecl.getQualifiedName(), faultInfo, builder); return true; }
Example 14
Source File: WebServiceWrapperGenerator.java From hottub with GNU General Public License v2.0 | 4 votes |
private boolean generateExceptionBean(TypeElement thrownDecl, String beanPackage) { if (!builder.isServiceException(thrownDecl.asType())) return false; String exceptionName = ClassNameInfo.getName(thrownDecl.getQualifiedName().toString()); if (processedExceptions.contains(exceptionName)) return false; processedExceptions.add(exceptionName); WebFault webFault = thrownDecl.getAnnotation(WebFault.class); String className = beanPackage+ exceptionName + BEAN.getValue(); Collection<MemberInfo> members = ap_generator.collectExceptionBeanMembers(thrownDecl); boolean isWSDLException = isWSDLException(members, thrownDecl); String namespace = typeNamespace; String name = exceptionName; FaultInfo faultInfo; if (isWSDLException) { TypeMirror beanType = getFaultInfoMember(members).getParamType(); faultInfo = new FaultInfo(TypeMonikerFactory.getTypeMoniker(beanType), true); namespace = webFault.targetNamespace().length()>0 ? webFault.targetNamespace() : namespace; name = webFault.name().length()>0 ? webFault.name() : name; faultInfo.setElementName(new QName(namespace, name)); seiContext.addExceptionBeanEntry(thrownDecl.getQualifiedName(), faultInfo, builder); return false; } if (webFault != null) { namespace = webFault.targetNamespace().length()>0 ? webFault.targetNamespace() : namespace; name = webFault.name().length()>0 ? webFault.name() : name; className = webFault.faultBean().length()>0 ? webFault.faultBean() : className; } JDefinedClass cls = getCMClass(className, CLASS); faultInfo = new FaultInfo(className, false); if (duplicateName(className)) { builder.processError(WebserviceapMessages.WEBSERVICEAP_METHOD_EXCEPTION_BEAN_NAME_NOT_UNIQUE( typeElement.getQualifiedName(), thrownDecl.getQualifiedName())); } boolean canOverWriteBean = builder.canOverWriteClass(className); if (!canOverWriteBean) { builder.log("Class " + className + " exists. Not overwriting."); seiContext.addExceptionBeanEntry(thrownDecl.getQualifiedName(), faultInfo, builder); return false; } if (seiContext.getExceptionBeanName(thrownDecl.getQualifiedName()) != null) return false; //write class comment - JAXWS warning JDocComment comment = cls.javadoc(); for (String doc : GeneratorBase.getJAXWSClassComment(ToolVersion.VERSION.MAJOR_VERSION)) { comment.add(doc); } // XmlElement Declarations writeXmlElementDeclaration(cls, name, namespace); // XmlType Declaration //members = sortMembers(members); XmlType xmlType = thrownDecl.getAnnotation(XmlType.class); String xmlTypeName = (xmlType != null && !xmlType.name().equals("##default")) ? xmlType.name() : exceptionName; String xmlTypeNamespace = (xmlType != null && !xmlType.namespace().equals("##default")) ? xmlType.namespace() : typeNamespace; writeXmlTypeDeclaration(cls, xmlTypeName, xmlTypeNamespace, members); writeMembers(cls, members); seiContext.addExceptionBeanEntry(thrownDecl.getQualifiedName(), faultInfo, builder); return true; }
Example 15
Source File: WebServiceWrapperGenerator.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
private boolean generateExceptionBean(TypeElement thrownDecl, String beanPackage) { if (!builder.isServiceException(thrownDecl.asType())) return false; String exceptionName = ClassNameInfo.getName(thrownDecl.getQualifiedName().toString()); if (processedExceptions.contains(exceptionName)) return false; processedExceptions.add(exceptionName); WebFault webFault = thrownDecl.getAnnotation(WebFault.class); String className = beanPackage+ exceptionName + BEAN.getValue(); Collection<MemberInfo> members = ap_generator.collectExceptionBeanMembers(thrownDecl); boolean isWSDLException = isWSDLException(members, thrownDecl); String namespace = typeNamespace; String name = exceptionName; FaultInfo faultInfo; if (isWSDLException) { TypeMirror beanType = getFaultInfoMember(members).getParamType(); faultInfo = new FaultInfo(TypeMonikerFactory.getTypeMoniker(beanType), true); namespace = webFault.targetNamespace().length()>0 ? webFault.targetNamespace() : namespace; name = webFault.name().length()>0 ? webFault.name() : name; faultInfo.setElementName(new QName(namespace, name)); seiContext.addExceptionBeanEntry(thrownDecl.getQualifiedName(), faultInfo, builder); return false; } if (webFault != null) { namespace = webFault.targetNamespace().length()>0 ? webFault.targetNamespace() : namespace; name = webFault.name().length()>0 ? webFault.name() : name; className = webFault.faultBean().length()>0 ? webFault.faultBean() : className; } JDefinedClass cls = getCMClass(className, CLASS); faultInfo = new FaultInfo(className, false); if (duplicateName(className)) { builder.processError(WebserviceapMessages.WEBSERVICEAP_METHOD_EXCEPTION_BEAN_NAME_NOT_UNIQUE( typeElement.getQualifiedName(), thrownDecl.getQualifiedName())); } boolean canOverWriteBean = builder.canOverWriteClass(className); if (!canOverWriteBean) { builder.log("Class " + className + " exists. Not overwriting."); seiContext.addExceptionBeanEntry(thrownDecl.getQualifiedName(), faultInfo, builder); return false; } if (seiContext.getExceptionBeanName(thrownDecl.getQualifiedName()) != null) return false; //write class comment - JAXWS warning JDocComment comment = cls.javadoc(); for (String doc : GeneratorBase.getJAXWSClassComment(ToolVersion.VERSION.MAJOR_VERSION)) { comment.add(doc); } // XmlElement Declarations writeXmlElementDeclaration(cls, name, namespace); // XmlType Declaration //members = sortMembers(members); XmlType xmlType = thrownDecl.getAnnotation(XmlType.class); String xmlTypeName = (xmlType != null && !xmlType.name().equals("##default")) ? xmlType.name() : exceptionName; String xmlTypeNamespace = (xmlType != null && !xmlType.namespace().equals("##default")) ? xmlType.namespace() : typeNamespace; writeXmlTypeDeclaration(cls, xmlTypeName, xmlTypeNamespace, members); writeMembers(cls, members); seiContext.addExceptionBeanEntry(thrownDecl.getQualifiedName(), faultInfo, builder); return true; }
Example 16
Source File: WebServiceWrapperGenerator.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
private boolean generateExceptionBean(TypeElement thrownDecl, String beanPackage) { if (!builder.isServiceException(thrownDecl.asType())) return false; String exceptionName = ClassNameInfo.getName(thrownDecl.getQualifiedName().toString()); if (processedExceptions.contains(exceptionName)) return false; processedExceptions.add(exceptionName); WebFault webFault = thrownDecl.getAnnotation(WebFault.class); String className = beanPackage+ exceptionName + BEAN.getValue(); Collection<MemberInfo> members = ap_generator.collectExceptionBeanMembers(thrownDecl); boolean isWSDLException = isWSDLException(members, thrownDecl); String namespace = typeNamespace; String name = exceptionName; FaultInfo faultInfo; if (isWSDLException) { TypeMirror beanType = getFaultInfoMember(members).getParamType(); faultInfo = new FaultInfo(TypeMonikerFactory.getTypeMoniker(beanType), true); namespace = webFault.targetNamespace().length()>0 ? webFault.targetNamespace() : namespace; name = webFault.name().length()>0 ? webFault.name() : name; faultInfo.setElementName(new QName(namespace, name)); seiContext.addExceptionBeanEntry(thrownDecl.getQualifiedName(), faultInfo, builder); return false; } if (webFault != null) { namespace = webFault.targetNamespace().length()>0 ? webFault.targetNamespace() : namespace; name = webFault.name().length()>0 ? webFault.name() : name; className = webFault.faultBean().length()>0 ? webFault.faultBean() : className; } JDefinedClass cls = getCMClass(className, CLASS); faultInfo = new FaultInfo(className, false); if (duplicateName(className)) { builder.processError(WebserviceapMessages.WEBSERVICEAP_METHOD_EXCEPTION_BEAN_NAME_NOT_UNIQUE( typeElement.getQualifiedName(), thrownDecl.getQualifiedName())); } boolean canOverWriteBean = builder.canOverWriteClass(className); if (!canOverWriteBean) { builder.log("Class " + className + " exists. Not overwriting."); seiContext.addExceptionBeanEntry(thrownDecl.getQualifiedName(), faultInfo, builder); return false; } if (seiContext.getExceptionBeanName(thrownDecl.getQualifiedName()) != null) return false; //write class comment - JAXWS warning JDocComment comment = cls.javadoc(); for (String doc : GeneratorBase.getJAXWSClassComment(ToolVersion.VERSION.MAJOR_VERSION)) { comment.add(doc); } // XmlElement Declarations writeXmlElementDeclaration(cls, name, namespace); // XmlType Declaration //members = sortMembers(members); XmlType xmlType = thrownDecl.getAnnotation(XmlType.class); String xmlTypeName = (xmlType != null && !xmlType.name().equals("##default")) ? xmlType.name() : exceptionName; String xmlTypeNamespace = (xmlType != null && !xmlType.namespace().equals("##default")) ? xmlType.namespace() : typeNamespace; writeXmlTypeDeclaration(cls, xmlTypeName, xmlTypeNamespace, members); writeMembers(cls, members); seiContext.addExceptionBeanEntry(thrownDecl.getQualifiedName(), faultInfo, builder); return true; }
Example 17
Source File: WebServiceWrapperGenerator.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
private boolean generateExceptionBean(TypeElement thrownDecl, String beanPackage) { if (!builder.isServiceException(thrownDecl.asType())) return false; String exceptionName = ClassNameInfo.getName(thrownDecl.getQualifiedName().toString()); if (processedExceptions.contains(exceptionName)) return false; processedExceptions.add(exceptionName); WebFault webFault = thrownDecl.getAnnotation(WebFault.class); String className = beanPackage+ exceptionName + BEAN.getValue(); Collection<MemberInfo> members = ap_generator.collectExceptionBeanMembers(thrownDecl); boolean isWSDLException = isWSDLException(members, thrownDecl); String namespace = typeNamespace; String name = exceptionName; FaultInfo faultInfo; if (isWSDLException) { TypeMirror beanType = getFaultInfoMember(members).getParamType(); faultInfo = new FaultInfo(TypeMonikerFactory.getTypeMoniker(beanType), true); namespace = webFault.targetNamespace().length()>0 ? webFault.targetNamespace() : namespace; name = webFault.name().length()>0 ? webFault.name() : name; faultInfo.setElementName(new QName(namespace, name)); seiContext.addExceptionBeanEntry(thrownDecl.getQualifiedName(), faultInfo, builder); return false; } if (webFault != null) { namespace = webFault.targetNamespace().length()>0 ? webFault.targetNamespace() : namespace; name = webFault.name().length()>0 ? webFault.name() : name; className = webFault.faultBean().length()>0 ? webFault.faultBean() : className; } JDefinedClass cls = getCMClass(className, CLASS); faultInfo = new FaultInfo(className, false); if (duplicateName(className)) { builder.processError(WebserviceapMessages.WEBSERVICEAP_METHOD_EXCEPTION_BEAN_NAME_NOT_UNIQUE( typeElement.getQualifiedName(), thrownDecl.getQualifiedName())); } boolean canOverWriteBean = builder.canOverWriteClass(className); if (!canOverWriteBean) { builder.log("Class " + className + " exists. Not overwriting."); seiContext.addExceptionBeanEntry(thrownDecl.getQualifiedName(), faultInfo, builder); return false; } if (seiContext.getExceptionBeanName(thrownDecl.getQualifiedName()) != null) return false; //write class comment - JAXWS warning JDocComment comment = cls.javadoc(); for (String doc : GeneratorBase.getJAXWSClassComment(ToolVersion.VERSION.MAJOR_VERSION)) { comment.add(doc); } // XmlElement Declarations writeXmlElementDeclaration(cls, name, namespace); // XmlType Declaration //members = sortMembers(members); XmlType xmlType = thrownDecl.getAnnotation(XmlType.class); String xmlTypeName = (xmlType != null && !xmlType.name().equals("##default")) ? xmlType.name() : exceptionName; String xmlTypeNamespace = (xmlType != null && !xmlType.namespace().equals("##default")) ? xmlType.namespace() : typeNamespace; writeXmlTypeDeclaration(cls, xmlTypeName, xmlTypeNamespace, members); writeMembers(cls, members); seiContext.addExceptionBeanEntry(thrownDecl.getQualifiedName(), faultInfo, builder); return true; }
Example 18
Source File: XmlTypeUtils.java From jaxb2-basics with BSD 2-Clause "Simplified" License | 4 votes |
public static QName getTypeName(Class<?> targetClass) { Validate.notNull(targetClass); final Package targetPackage = targetClass.getPackage(); final XmlType xmlTypeAnnotation = targetClass .getAnnotation(XmlType.class); final String localPart; final String namespaceURI; final String prefix; if (xmlTypeAnnotation == null) { localPart = NameConverter.standard.toVariableName(targetClass .getSimpleName()); namespaceURI = getNamespace(targetPackage); } else { final String name = xmlTypeAnnotation.name(); if (name == null || "".equals(name)) { localPart = null; } else { if ("##default".equals(name)) { localPart = NameConverter.standard .toVariableName(targetClass.getSimpleName()); } else { localPart = name; } } final String namespace = xmlTypeAnnotation.namespace(); if (namespace == null || "".equals(namespace)) { namespaceURI = ""; } else { if ("##default".equals(namespace)) { namespaceURI = getNamespace(targetPackage); } else { namespaceURI = namespace; } } } if (localPart == null) { return null; } else { prefix = getPrefix(targetPackage, namespaceURI); } return prefix == null ? new QName(namespaceURI, localPart) : new QName( namespaceURI, localPart, prefix); }
Example 19
Source File: WebServiceWrapperGenerator.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
private boolean generateExceptionBean(TypeElement thrownDecl, String beanPackage) { if (!builder.isServiceException(thrownDecl.asType())) return false; String exceptionName = ClassNameInfo.getName(thrownDecl.getQualifiedName().toString()); if (processedExceptions.contains(exceptionName)) return false; processedExceptions.add(exceptionName); WebFault webFault = thrownDecl.getAnnotation(WebFault.class); String className = beanPackage+ exceptionName + BEAN.getValue(); Collection<MemberInfo> members = ap_generator.collectExceptionBeanMembers(thrownDecl); boolean isWSDLException = isWSDLException(members, thrownDecl); String namespace = typeNamespace; String name = exceptionName; FaultInfo faultInfo; if (isWSDLException) { TypeMirror beanType = getFaultInfoMember(members).getParamType(); faultInfo = new FaultInfo(TypeMonikerFactory.getTypeMoniker(beanType), true); namespace = webFault.targetNamespace().length()>0 ? webFault.targetNamespace() : namespace; name = webFault.name().length()>0 ? webFault.name() : name; faultInfo.setElementName(new QName(namespace, name)); seiContext.addExceptionBeanEntry(thrownDecl.getQualifiedName(), faultInfo, builder); return false; } if (webFault != null) { namespace = webFault.targetNamespace().length()>0 ? webFault.targetNamespace() : namespace; name = webFault.name().length()>0 ? webFault.name() : name; className = webFault.faultBean().length()>0 ? webFault.faultBean() : className; } JDefinedClass cls = getCMClass(className, CLASS); faultInfo = new FaultInfo(className, false); if (duplicateName(className)) { builder.processError(WebserviceapMessages.WEBSERVICEAP_METHOD_EXCEPTION_BEAN_NAME_NOT_UNIQUE( typeElement.getQualifiedName(), thrownDecl.getQualifiedName())); } boolean canOverWriteBean = builder.canOverWriteClass(className); if (!canOverWriteBean) { builder.log("Class " + className + " exists. Not overwriting."); seiContext.addExceptionBeanEntry(thrownDecl.getQualifiedName(), faultInfo, builder); return false; } if (seiContext.getExceptionBeanName(thrownDecl.getQualifiedName()) != null) return false; //write class comment - JAXWS warning JDocComment comment = cls.javadoc(); for (String doc : GeneratorBase.getJAXWSClassComment(ToolVersion.VERSION.MAJOR_VERSION)) { comment.add(doc); } // XmlElement Declarations writeXmlElementDeclaration(cls, name, namespace); // XmlType Declaration //members = sortMembers(members); XmlType xmlType = thrownDecl.getAnnotation(XmlType.class); String xmlTypeName = (xmlType != null && !xmlType.name().equals("##default")) ? xmlType.name() : exceptionName; String xmlTypeNamespace = (xmlType != null && !xmlType.namespace().equals("##default")) ? xmlType.namespace() : typeNamespace; writeXmlTypeDeclaration(cls, xmlTypeName, xmlTypeNamespace, members); writeMembers(cls, members); seiContext.addExceptionBeanEntry(thrownDecl.getQualifiedName(), faultInfo, builder); return true; }