Java Code Examples for javax.xml.ws.WebFault#name()
The following examples show how to use
javax.xml.ws.WebFault#name() .
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: ExceptionClassTest.java From development with Apache License 2.0 | 6 votes |
@Test public void testForWebFaultAnnotationInExceptions() throws Exception { StringBuffer errors = new StringBuffer(); List<Class<?>> classes = PackageClassReader.getClasses( CurrencyException.class, Throwable.class, ClassFilter.CLASSES_ONLY); for (Class<?> clazz : getApplicationExceptions(classes)) { WebFault annotation = clazz.getAnnotation(WebFault.class); if (annotation == null) { errors.append("Class ").append(clazz.getName()) .append(" misses WebFault annotation\n"); continue; } String name = annotation.name(); if (!name.equals(clazz.getSimpleName())) { errors.append("Class ").append(clazz.getName()) .append(" uses a WebFault name annotation that ") .append("does not match the class name.\n"); } } if (errors.length() > 0) { fail("Exceptions without constructor(String):\n" + errors.toString()); } }
Example 2
Source File: JaxWsServiceConfiguration.java From cxf with Apache License 2.0 | 6 votes |
@Override public QName getFaultName(InterfaceInfo service, OperationInfo o, Class<?> exClass, Class<?> beanClass) { WebFault fault = exClass.getAnnotation(WebFault.class); if (fault != null) { String name = fault.name(); if (name.length() == 0) { name = exClass.getSimpleName(); } String ns = fault.targetNamespace(); if (ns.length() == 0) { ns = service.getName().getNamespaceURI(); } return new QName(ns, name); } return null; }
Example 3
Source File: WebFaultOutInterceptor.java From cxf with Apache License 2.0 | 5 votes |
private QName getFaultName(WebFault wf, Class<?> cls, OperationInfo op) { String ns = wf.targetNamespace(); if (StringUtils.isEmpty(ns) && op != null) { ns = op.getName().getNamespaceURI(); } String name = wf.name(); if (StringUtils.isEmpty(name)) { name = cls.getSimpleName(); } return new QName(ns, name); }
Example 4
Source File: InternalContextUtils.java From cxf with Apache License 2.0 | 5 votes |
private static boolean matchFault(Throwable t, FaultInfo fi) { //REVISIT not sure if this class-based comparison works in general as the fault class defined // in the service interface has no direct relationship to the message body's type. MessagePartInfo fmpi = fi.getFirstMessagePart(); Class<?> fiTypeClass = fmpi.getTypeClass(); if (fiTypeClass != null && t.getClass().isAssignableFrom(fiTypeClass)) { return true; } // CXF-6575 QName fiName = fmpi.getConcreteName(); WebFault wf = t.getClass().getAnnotation(WebFault.class); return wf != null && fiName != null && wf.targetNamespace() != null && wf.targetNamespace().equals(fiName.getNamespaceURI()) && wf.name() != null && wf.name().equals(fiName.getLocalPart()); }
Example 5
Source File: MAPAggregatorImpl.java From cxf with Apache License 2.0 | 5 votes |
private String getFaultNameFromMessage(final Message message) { Exception e = message.getContent(Exception.class); Throwable cause = e.getCause(); if (cause == null) { cause = e; } if (e instanceof Fault) { WebFault t = cause.getClass().getAnnotation(WebFault.class); if (t != null) { return t.name(); } } return cause.getClass().getSimpleName(); }
Example 6
Source File: WebFaultInInterceptor.java From cxf with Apache License 2.0 | 5 votes |
private QName getFaultName(Exception webFault) { QName faultName = null; WebFault wf = webFault.getClass().getAnnotation(WebFault.class); if (wf != null) { faultName = new QName(wf.targetNamespace(), wf.name()); } return faultName; }
Example 7
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; }
Example 8
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 9
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 10
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 11
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 12
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 13
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 14
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; }