com.sun.xml.internal.ws.api.model.ExceptionType Java Examples

The following examples show how to use com.sun.xml.internal.ws.api.model.ExceptionType. 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: SOAPFaultBuilder.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private static Object getFaultDetail(CheckedExceptionImpl ce, Throwable exception) {
    if (ce == null)
        return null;
    if (ce.getExceptionType().equals(ExceptionType.UserDefined)) {
        return createDetailFromUserDefinedException(ce, exception);
    }
    try {
        Method m = exception.getClass().getMethod("getFaultInfo");
        return m.invoke(exception);
    } catch (Exception e) {
        throw new SerializationException(e);
    }
}
 
Example #2
Source File: SOAPFaultBuilder.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * This should be called from the client side to throw an {@link Exception} for a given soap mesage
 */
public Throwable createException(Map<QName, CheckedExceptionImpl> exceptions) throws JAXBException {
    DetailType dt = getDetail();
    Node detail = null;
    if(dt != null)  detail = dt.getDetail(0);

    //return ProtocolException if the detail is not present or there is no checked exception
    if(detail == null || exceptions == null){
        // No soap detail, doesnt look like its a checked exception
        // throw a protocol exception
        return attachServerException(getProtocolException());
    }

    //check if the detail is a checked exception, if not throw a ProtocolException
    QName detailName = new QName(detail.getNamespaceURI(), detail.getLocalName());
    CheckedExceptionImpl ce = exceptions.get(detailName);
    if (ce == null) {
        //No Checked exception for the received detail QName, throw a SOAPFault exception
        return attachServerException(getProtocolException());

    }

    if (ce.getExceptionType().equals(ExceptionType.UserDefined)) {
        return attachServerException(createUserDefinedException(ce));

    }
    Class exceptionClass = ce.getExceptionClass();
    try {
        Constructor constructor = exceptionClass.getConstructor(String.class, (Class) ce.getDetailType().type);
        Exception exception = (Exception) constructor.newInstance(getFaultString(), getJAXBObject(detail, ce));
        return attachServerException(exception);
    } catch (Exception e) {
        throw new WebServiceException(e);
    }
}
 
Example #3
Source File: SOAPFaultBuilder.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private static Object getFaultDetail(CheckedExceptionImpl ce, Throwable exception) {
    if (ce == null)
        return null;
    if (ce.getExceptionType().equals(ExceptionType.UserDefined)) {
        return createDetailFromUserDefinedException(ce, exception);
    }
    try {
        return ce.getFaultInfoGetter().invoke(exception);
    } catch (Exception e) {
        throw new SerializationException(e);
    }
}
 
Example #4
Source File: SOAPFaultBuilder.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private static Object getFaultDetail(CheckedExceptionImpl ce, Throwable exception) {
    if (ce == null)
        return null;
    if (ce.getExceptionType().equals(ExceptionType.UserDefined)) {
        return createDetailFromUserDefinedException(ce, exception);
    }
    try {
        Method m = exception.getClass().getMethod("getFaultInfo");
        return m.invoke(exception);
    } catch (Exception e) {
        throw new SerializationException(e);
    }
}
 
Example #5
Source File: SOAPFaultBuilder.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * This should be called from the client side to throw an {@link Exception} for a given soap mesage
 */
public Throwable createException(Map<QName, CheckedExceptionImpl> exceptions) throws JAXBException {
    DetailType dt = getDetail();
    Node detail = null;
    if(dt != null)  detail = dt.getDetail(0);

    //return ProtocolException if the detail is not present or there is no checked exception
    if(detail == null || exceptions == null){
        // No soap detail, doesnt look like its a checked exception
        // throw a protocol exception
        return attachServerException(getProtocolException());
    }

    //check if the detail is a checked exception, if not throw a ProtocolException
    QName detailName = new QName(detail.getNamespaceURI(), detail.getLocalName());
    CheckedExceptionImpl ce = exceptions.get(detailName);
    if (ce == null) {
        //No Checked exception for the received detail QName, throw a SOAPFault exception
        return attachServerException(getProtocolException());

    }

    if (ce.getExceptionType().equals(ExceptionType.UserDefined)) {
        return attachServerException(createUserDefinedException(ce));

    }
    Class exceptionClass = ce.getExceptionClass();
    try {
        Constructor constructor = exceptionClass.getConstructor(String.class, (Class) ce.getDetailType().type);
        Exception exception = (Exception) constructor.newInstance(getFaultString(), getJAXBObject(detail, ce));
        return attachServerException(exception);
    } catch (Exception e) {
        throw new WebServiceException(e);
    }
}
 
Example #6
Source File: SOAPFaultBuilder.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * This should be called from the client side to throw an {@link Exception} for a given soap mesage
 */
public Throwable createException(Map<QName, CheckedExceptionImpl> exceptions) throws JAXBException {
    DetailType dt = getDetail();
    Node detail = null;
    if(dt != null)  detail = dt.getDetail(0);

    //return ProtocolException if the detail is not present or there is no checked exception
    if(detail == null || exceptions == null){
        // No soap detail, doesnt look like its a checked exception
        // throw a protocol exception
        return attachServerException(getProtocolException());
    }

    //check if the detail is a checked exception, if not throw a ProtocolException
    QName detailName = new QName(detail.getNamespaceURI(), detail.getLocalName());
    CheckedExceptionImpl ce = exceptions.get(detailName);
    if (ce == null) {
        //No Checked exception for the received detail QName, throw a SOAPFault exception
        return attachServerException(getProtocolException());

    }

    if (ce.getExceptionType().equals(ExceptionType.UserDefined)) {
        return attachServerException(createUserDefinedException(ce));

    }
    Class exceptionClass = ce.getExceptionClass();
    try {
        Constructor constructor = exceptionClass.getConstructor(String.class, (Class) ce.getDetailType().type);
        Exception exception = (Exception) constructor.newInstance(getFaultString(), getJAXBObject(detail, ce));
        return attachServerException(exception);
    } catch (Exception e) {
        throw new WebServiceException(e);
    }
}
 
Example #7
Source File: SOAPFaultBuilder.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private static Object getFaultDetail(CheckedExceptionImpl ce, Throwable exception) {
    if (ce == null)
        return null;
    if (ce.getExceptionType().equals(ExceptionType.UserDefined)) {
        return createDetailFromUserDefinedException(ce, exception);
    }
    try {
        Method m = exception.getClass().getMethod("getFaultInfo");
        return m.invoke(exception);
    } catch (Exception e) {
        throw new SerializationException(e);
    }
}
 
Example #8
Source File: SOAPFaultBuilder.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private static Object getFaultDetail(CheckedExceptionImpl ce, Throwable exception) {
    if (ce == null)
        return null;
    if (ce.getExceptionType().equals(ExceptionType.UserDefined)) {
        return createDetailFromUserDefinedException(ce, exception);
    }
    try {
        Method m = exception.getClass().getMethod("getFaultInfo");
        return m.invoke(exception);
    } catch (Exception e) {
        throw new SerializationException(e);
    }
}
 
Example #9
Source File: SOAPFaultBuilder.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * This should be called from the client side to throw an {@link Exception} for a given soap mesage
 */
public Throwable createException(Map<QName, CheckedExceptionImpl> exceptions) throws JAXBException {
    DetailType dt = getDetail();
    Node detail = null;
    if(dt != null)  detail = dt.getDetail(0);

    //return ProtocolException if the detail is not present or there is no checked exception
    if(detail == null || exceptions == null){
        // No soap detail, doesnt look like its a checked exception
        // throw a protocol exception
        return attachServerException(getProtocolException());
    }

    //check if the detail is a checked exception, if not throw a ProtocolException
    QName detailName = new QName(detail.getNamespaceURI(), detail.getLocalName());
    CheckedExceptionImpl ce = exceptions.get(detailName);
    if (ce == null) {
        //No Checked exception for the received detail QName, throw a SOAPFault exception
        return attachServerException(getProtocolException());

    }

    if (ce.getExceptionType().equals(ExceptionType.UserDefined)) {
        return attachServerException(createUserDefinedException(ce));

    }
    Class exceptionClass = ce.getExceptionClass();
    try {
        Constructor constructor = exceptionClass.getConstructor(String.class, (Class) ce.getDetailType().type);
        Exception exception = (Exception) constructor.newInstance(getFaultString(), getJAXBObject(detail, ce));
        return attachServerException(exception);
    } catch (Exception e) {
        throw new WebServiceException(e);
    }
}
 
Example #10
Source File: SOAPFaultBuilder.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * This should be called from the client side to throw an {@link Exception} for a given soap mesage
 */
public Throwable createException(Map<QName, CheckedExceptionImpl> exceptions) throws JAXBException {
    DetailType dt = getDetail();
    Node detail = null;
    if(dt != null)  detail = dt.getDetail(0);

    //return ProtocolException if the detail is not present or there is no checked exception
    if(detail == null || exceptions == null){
        // No soap detail, doesnt look like its a checked exception
        // throw a protocol exception
        return attachServerException(getProtocolException());
    }

    //check if the detail is a checked exception, if not throw a ProtocolException
    QName detailName = new QName(detail.getNamespaceURI(), detail.getLocalName());
    CheckedExceptionImpl ce = exceptions.get(detailName);
    if (ce == null) {
        //No Checked exception for the received detail QName, throw a SOAPFault exception
        return attachServerException(getProtocolException());

    }

    if (ce.getExceptionType().equals(ExceptionType.UserDefined)) {
        return attachServerException(createUserDefinedException(ce));

    }
    Class exceptionClass = ce.getExceptionClass();
    try {
        Constructor constructor = exceptionClass.getConstructor(String.class, (Class) ce.getDetailType().type);
        Exception exception = (Exception) constructor.newInstance(getFaultString(), getJAXBObject(detail, ce));
        return attachServerException(exception);
    } catch (Exception e) {
        throw new WebServiceException(e);
    }
}
 
Example #11
Source File: SOAPFaultBuilder.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private static Object getFaultDetail(CheckedExceptionImpl ce, Throwable exception) {
    if (ce == null)
        return null;
    if (ce.getExceptionType().equals(ExceptionType.UserDefined)) {
        return createDetailFromUserDefinedException(ce, exception);
    }
    try {
        Method m = exception.getClass().getMethod("getFaultInfo");
        return m.invoke(exception);
    } catch (Exception e) {
        throw new SerializationException(e);
    }
}
 
Example #12
Source File: SOAPFaultBuilder.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * This should be called from the client side to throw an {@link Exception} for a given soap mesage
 */
public Throwable createException(Map<QName, CheckedExceptionImpl> exceptions) throws JAXBException {
    DetailType dt = getDetail();
    Node detail = null;
    if(dt != null)  detail = dt.getDetail(0);

    //return ProtocolException if the detail is not present or there is no checked exception
    if(detail == null || exceptions == null){
        // No soap detail, doesnt look like its a checked exception
        // throw a protocol exception
        return attachServerException(getProtocolException());
    }

    //check if the detail is a checked exception, if not throw a ProtocolException
    QName detailName = new QName(detail.getNamespaceURI(), detail.getLocalName());
    CheckedExceptionImpl ce = exceptions.get(detailName);
    if (ce == null) {
        //No Checked exception for the received detail QName, throw a SOAPFault exception
        return attachServerException(getProtocolException());

    }

    if (ce.getExceptionType().equals(ExceptionType.UserDefined)) {
        return attachServerException(createUserDefinedException(ce));

    }
    Class exceptionClass = ce.getExceptionClass();
    try {
        Constructor constructor = exceptionClass.getConstructor(String.class, (Class) ce.getDetailType().type);
        Exception exception = (Exception) constructor.newInstance(getFaultString(), getJAXBObject(detail, ce));
        return attachServerException(exception);
    } catch (Exception e) {
        throw new WebServiceException(e);
    }
}
 
Example #13
Source File: SOAPFaultBuilder.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private static Object getFaultDetail(CheckedExceptionImpl ce, Throwable exception) {
    if (ce == null)
        return null;
    if (ce.getExceptionType().equals(ExceptionType.UserDefined)) {
        return createDetailFromUserDefinedException(ce, exception);
    }
    try {
        Method m = exception.getClass().getMethod("getFaultInfo");
        return m.invoke(exception);
    } catch (Exception e) {
        throw new SerializationException(e);
    }
}
 
Example #14
Source File: SOAPFaultBuilder.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private static Object getFaultDetail(CheckedExceptionImpl ce, Throwable exception) {
    if (ce == null)
        return null;
    if (ce.getExceptionType().equals(ExceptionType.UserDefined)) {
        return createDetailFromUserDefinedException(ce, exception);
    }
    try {
        Method m = exception.getClass().getMethod("getFaultInfo");
        return m.invoke(exception);
    } catch (Exception e) {
        throw new SerializationException(e);
    }
}
 
Example #15
Source File: SOAPFaultBuilder.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * This should be called from the client side to throw an {@link Exception} for a given soap mesage
 */
public Throwable createException(Map<QName, CheckedExceptionImpl> exceptions) throws JAXBException {
    DetailType dt = getDetail();
    Node detail = null;
    if(dt != null)  detail = dt.getDetail(0);

    //return ProtocolException if the detail is not present or there is no checked exception
    if(detail == null || exceptions == null){
        // No soap detail, doesnt look like its a checked exception
        // throw a protocol exception
        return attachServerException(getProtocolException());
    }

    //check if the detail is a checked exception, if not throw a ProtocolException
    QName detailName = new QName(detail.getNamespaceURI(), detail.getLocalName());
    CheckedExceptionImpl ce = exceptions.get(detailName);
    if (ce == null) {
        //No Checked exception for the received detail QName, throw a SOAPFault exception
        return attachServerException(getProtocolException());

    }

    if (ce.getExceptionType().equals(ExceptionType.UserDefined)) {
        return attachServerException(createUserDefinedException(ce));

    }
    Class exceptionClass = ce.getExceptionClass();
    try {
        Constructor constructor = exceptionClass.getConstructor(String.class, (Class) ce.getDetailType().type);
        Exception exception = (Exception) constructor.newInstance(getFaultString(), getJAXBObject(detail, ce));
        return attachServerException(exception);
    } catch (Exception e) {
        throw new WebServiceException(e);
    }
}
 
Example #16
Source File: SOAPFaultBuilder.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * This should be called from the client side to throw an {@link Exception} for a given soap mesage
 */
public Throwable createException(Map<QName, CheckedExceptionImpl> exceptions) throws JAXBException {
    DetailType dt = getDetail();
    Node detail = null;
    if(dt != null)  detail = dt.getDetail(0);

    //return ProtocolException if the detail is not present or there is no checked exception
    if(detail == null || exceptions == null){
        // No soap detail, doesnt look like its a checked exception
        // throw a protocol exception
        return attachServerException(getProtocolException());
    }

    //check if the detail is a checked exception, if not throw a ProtocolException
    QName detailName = new QName(detail.getNamespaceURI(), detail.getLocalName());
    CheckedExceptionImpl ce = exceptions.get(detailName);
    if (ce == null) {
        //No Checked exception for the received detail QName, throw a SOAPFault exception
        return attachServerException(getProtocolException());

    }

    if (ce.getExceptionType().equals(ExceptionType.UserDefined)) {
        return attachServerException(createUserDefinedException(ce));

    }
    Class exceptionClass = ce.getExceptionClass();
    try {
        Constructor constructor = exceptionClass.getConstructor(String.class, (Class) ce.getDetailType().type);
        Exception exception = (Exception) constructor.newInstance(getFaultString(), getJAXBObject(detail, ce));
        return attachServerException(exception);
    } catch (Exception e) {
        throw new WebServiceException(e);
    }
}
 
Example #17
Source File: CheckedExceptionImpl.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
public ExceptionType getExceptionType() {
    return exceptionType;
}
 
Example #18
Source File: RuntimeModeler.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/**
 * models the exceptions thrown by <code>method</code> and adds them to the <code>javaMethod</code>
 * runtime model object
 * @param javaMethod the runtime model object to add the exception model objects to
 * @param method the <code>method</code> from which to find the exceptions to model
 */
protected void processExceptions(JavaMethodImpl javaMethod, Method method) {
    Action actionAnn = getAnnotation(method, Action.class);
    FaultAction[] faultActions = {};
    if(actionAnn != null)
        faultActions = actionAnn.fault();
    for (Class<?> exception : method.getExceptionTypes()) {

        //Exclude RuntimeException, RemoteException and Error etc
        if (!EXCEPTION_CLASS.isAssignableFrom(exception))
            continue;
        if (RUNTIME_EXCEPTION_CLASS.isAssignableFrom(exception) || REMOTE_EXCEPTION_CLASS.isAssignableFrom(exception))
            continue;

        Class exceptionBean;
        Annotation[] anns;
        WebFault webFault = getAnnotation(exception, WebFault.class);
        Method faultInfoMethod = getWSDLExceptionFaultInfo(exception);
        ExceptionType exceptionType = ExceptionType.WSDLException;
        String namespace = targetNamespace;
        String name = exception.getSimpleName();
        String beanPackage = packageName + PD_JAXWS_PACKAGE_PD;
        if (packageName.length() == 0)
            beanPackage = JAXWS_PACKAGE_PD;
        String className = beanPackage+ name + BEAN;
        String messageName = exception.getSimpleName();
        if (webFault != null) {
            if (webFault.faultBean().length()>0)
                className = webFault.faultBean();
            if (webFault.name().length()>0)
                name = webFault.name();
            if (webFault.targetNamespace().length()>0)
                namespace = webFault.targetNamespace();
            if (webFault.messageName().length()>0)
                messageName = webFault.messageName();
        }
        if (faultInfoMethod == null)  {
            exceptionBean = getExceptionBeanClass(className, exception, name, namespace);
            exceptionType = ExceptionType.UserDefined;
            anns = getAnnotations(exceptionBean);
        } else {
            exceptionBean = faultInfoMethod.getReturnType();
            anns = getAnnotations(faultInfoMethod);
        }
        QName faultName = new QName(namespace, name);
        TypeInfo typeRef = new TypeInfo(faultName, exceptionBean, anns);
        CheckedExceptionImpl checkedException =
            new CheckedExceptionImpl(javaMethod, exception, typeRef, exceptionType);
        checkedException.setMessageName(messageName);
        for(FaultAction fa: faultActions) {
            if(fa.className().equals(exception) && !fa.value().equals("")) {
                checkedException.setFaultAction(fa.value());
                break;
            }
        }
        javaMethod.addException(checkedException);
    }
}
 
Example #19
Source File: RuntimeModeler.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * models the exceptions thrown by <code>method</code> and adds them to the <code>javaMethod</code>
 * runtime model object
 * @param javaMethod the runtime model object to add the exception model objects to
 * @param method the <code>method</code> from which to find the exceptions to model
 */
protected void processExceptions(JavaMethodImpl javaMethod, Method method) {
    Action actionAnn = getAnnotation(method, Action.class);
    FaultAction[] faultActions = {};
    if(actionAnn != null)
        faultActions = actionAnn.fault();
    for (Class<?> exception : method.getExceptionTypes()) {

        //Exclude RuntimeException, RemoteException and Error etc
        if (!EXCEPTION_CLASS.isAssignableFrom(exception))
            continue;
        if (RUNTIME_EXCEPTION_CLASS.isAssignableFrom(exception) || REMOTE_EXCEPTION_CLASS.isAssignableFrom(exception))
            continue;

        Class exceptionBean;
        Annotation[] anns;
        WebFault webFault = getAnnotation(exception, WebFault.class);
        Method faultInfoMethod = getWSDLExceptionFaultInfo(exception);
        ExceptionType exceptionType = ExceptionType.WSDLException;
        String namespace = targetNamespace;
        String name = exception.getSimpleName();
        String beanPackage = packageName + PD_JAXWS_PACKAGE_PD;
        if (packageName.length() == 0)
            beanPackage = JAXWS_PACKAGE_PD;
        String className = beanPackage+ name + BEAN;
        String messageName = exception.getSimpleName();
        if (webFault != null) {
            if (webFault.faultBean().length()>0)
                className = webFault.faultBean();
            if (webFault.name().length()>0)
                name = webFault.name();
            if (webFault.targetNamespace().length()>0)
                namespace = webFault.targetNamespace();
            if (webFault.messageName().length()>0)
                messageName = webFault.messageName();
        }
        if (faultInfoMethod == null)  {
            exceptionBean = getExceptionBeanClass(className, exception, name, namespace);
            exceptionType = ExceptionType.UserDefined;
            anns = getAnnotations(exceptionBean);
        } else {
            exceptionBean = faultInfoMethod.getReturnType();
            anns = getAnnotations(faultInfoMethod);
        }
        QName faultName = new QName(namespace, name);
        TypeInfo typeRef = new TypeInfo(faultName, exceptionBean, anns);
        CheckedExceptionImpl checkedException =
            new CheckedExceptionImpl(javaMethod, exception, typeRef, exceptionType);
        checkedException.setMessageName(messageName);
        for(FaultAction fa: faultActions) {
            if(fa.className().equals(exception) && !fa.value().equals("")) {
                checkedException.setFaultAction(fa.value());
                break;
            }
        }
        javaMethod.addException(checkedException);
    }
}
 
Example #20
Source File: CheckedExceptionImpl.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
public ExceptionType getExceptionType() {
    return exceptionType;
}
 
Example #21
Source File: CheckedExceptionImpl.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
public ExceptionType getExceptionType() {
    return exceptionType;
}
 
Example #22
Source File: RuntimeModeler.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * models the exceptions thrown by <code>method</code> and adds them to the <code>javaMethod</code>
 * runtime model object
 * @param javaMethod the runtime model object to add the exception model objects to
 * @param method the <code>method</code> from which to find the exceptions to model
 */
protected void processExceptions(JavaMethodImpl javaMethod, Method method) {
    Action actionAnn = getAnnotation(method, Action.class);
    FaultAction[] faultActions = {};
    if(actionAnn != null)
        faultActions = actionAnn.fault();
    for (Class<?> exception : method.getExceptionTypes()) {

        //Exclude RuntimeException, RemoteException and Error etc
        if (!EXCEPTION_CLASS.isAssignableFrom(exception))
            continue;
        if (RUNTIME_EXCEPTION_CLASS.isAssignableFrom(exception) || REMOTE_EXCEPTION_CLASS.isAssignableFrom(exception))
            continue;

        Class exceptionBean;
        Annotation[] anns;
        WebFault webFault = getAnnotation(exception, WebFault.class);
        Method faultInfoMethod = getWSDLExceptionFaultInfo(exception);
        ExceptionType exceptionType = ExceptionType.WSDLException;
        String namespace = targetNamespace;
        String name = exception.getSimpleName();
        String beanPackage = packageName + PD_JAXWS_PACKAGE_PD;
        if (packageName.length() == 0)
            beanPackage = JAXWS_PACKAGE_PD;
        String className = beanPackage+ name + BEAN;
        String messageName = exception.getSimpleName();
        if (webFault != null) {
            if (webFault.faultBean().length()>0)
                className = webFault.faultBean();
            if (webFault.name().length()>0)
                name = webFault.name();
            if (webFault.targetNamespace().length()>0)
                namespace = webFault.targetNamespace();
            if (webFault.messageName().length()>0)
                messageName = webFault.messageName();
        }
        if (faultInfoMethod == null)  {
            exceptionBean = getExceptionBeanClass(className, exception, name, namespace);
            exceptionType = ExceptionType.UserDefined;
            anns = getAnnotations(exceptionBean);
        } else {
            exceptionBean = faultInfoMethod.getReturnType();
            anns = getAnnotations(faultInfoMethod);
        }
        QName faultName = new QName(namespace, name);
        TypeInfo typeRef = new TypeInfo(faultName, exceptionBean, anns);
        CheckedExceptionImpl checkedException =
            new CheckedExceptionImpl(javaMethod, exception, typeRef, exceptionType);
        checkedException.setMessageName(messageName);
        for(FaultAction fa: faultActions) {
            if(fa.className().equals(exception) && !fa.value().equals("")) {
                checkedException.setFaultAction(fa.value());
                break;
            }
        }
        javaMethod.addException(checkedException);
    }
}
 
Example #23
Source File: RuntimeModeler.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * models the exceptions thrown by <code>method</code> and adds them to the <code>javaMethod</code>
 * runtime model object
 * @param javaMethod the runtime model object to add the exception model objects to
 * @param method the <code>method</code> from which to find the exceptions to model
 */
protected void processExceptions(JavaMethodImpl javaMethod, Method method) {
    Action actionAnn = getAnnotation(method, Action.class);
    FaultAction[] faultActions = {};
    if(actionAnn != null)
        faultActions = actionAnn.fault();
    for (Class<?> exception : method.getExceptionTypes()) {

        //Exclude RuntimeException, RemoteException and Error etc
        if (!EXCEPTION_CLASS.isAssignableFrom(exception))
            continue;
        if (RUNTIME_EXCEPTION_CLASS.isAssignableFrom(exception) || isRemoteException(exception))
            continue;
        if (getAnnotation(exception, javax.xml.bind.annotation.XmlTransient.class) != null)
            continue;
        Class exceptionBean;
        Annotation[] anns;
        WebFault webFault = getAnnotation(exception, WebFault.class);
        Method faultInfoMethod = getWSDLExceptionFaultInfo(exception);
        ExceptionType exceptionType = ExceptionType.WSDLException;
        String namespace = targetNamespace;
        String name = exception.getSimpleName();
        String beanPackage = packageName + PD_JAXWS_PACKAGE_PD;
        if (packageName.length() == 0)
            beanPackage = JAXWS_PACKAGE_PD;
        String className = beanPackage+ name + BEAN;
        String messageName = exception.getSimpleName();
        if (webFault != null) {
            if (webFault.faultBean().length()>0)
                className = webFault.faultBean();
            if (webFault.name().length()>0)
                name = webFault.name();
            if (webFault.targetNamespace().length()>0)
                namespace = webFault.targetNamespace();
            if (webFault.messageName().length()>0)
                messageName = webFault.messageName();
        }
        if (faultInfoMethod == null)  {
            exceptionBean = getExceptionBeanClass(className, exception, name, namespace);
            exceptionType = ExceptionType.UserDefined;
            anns = getAnnotations(exceptionBean);
        } else {
            exceptionBean = faultInfoMethod.getReturnType();
            anns = getAnnotations(faultInfoMethod);
        }
        QName faultName = new QName(namespace, name);
        TypeInfo typeRef = new TypeInfo(faultName, exceptionBean, anns);
        CheckedExceptionImpl checkedException =
            new CheckedExceptionImpl(javaMethod, exception, typeRef, exceptionType);
        checkedException.setMessageName(messageName);
        checkedException.setFaultInfoGetter(faultInfoMethod);
        for(FaultAction fa: faultActions) {
            if(fa.className().equals(exception) && !fa.value().equals("")) {
                checkedException.setFaultAction(fa.value());
                break;
            }
        }
        javaMethod.addException(checkedException);
    }
}
 
Example #24
Source File: RuntimeModeler.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * models the exceptions thrown by <code>method</code> and adds them to the <code>javaMethod</code>
 * runtime model object
 * @param javaMethod the runtime model object to add the exception model objects to
 * @param method the <code>method</code> from which to find the exceptions to model
 */
protected void processExceptions(JavaMethodImpl javaMethod, Method method) {
    Action actionAnn = getAnnotation(method, Action.class);
    FaultAction[] faultActions = {};
    if(actionAnn != null)
        faultActions = actionAnn.fault();
    for (Class<?> exception : method.getExceptionTypes()) {

        //Exclude RuntimeException, RemoteException and Error etc
        if (!EXCEPTION_CLASS.isAssignableFrom(exception))
            continue;
        if (RUNTIME_EXCEPTION_CLASS.isAssignableFrom(exception) || REMOTE_EXCEPTION_CLASS.isAssignableFrom(exception))
            continue;

        Class exceptionBean;
        Annotation[] anns;
        WebFault webFault = getAnnotation(exception, WebFault.class);
        Method faultInfoMethod = getWSDLExceptionFaultInfo(exception);
        ExceptionType exceptionType = ExceptionType.WSDLException;
        String namespace = targetNamespace;
        String name = exception.getSimpleName();
        String beanPackage = packageName + PD_JAXWS_PACKAGE_PD;
        if (packageName.length() == 0)
            beanPackage = JAXWS_PACKAGE_PD;
        String className = beanPackage+ name + BEAN;
        String messageName = exception.getSimpleName();
        if (webFault != null) {
            if (webFault.faultBean().length()>0)
                className = webFault.faultBean();
            if (webFault.name().length()>0)
                name = webFault.name();
            if (webFault.targetNamespace().length()>0)
                namespace = webFault.targetNamespace();
            if (webFault.messageName().length()>0)
                messageName = webFault.messageName();
        }
        if (faultInfoMethod == null)  {
            exceptionBean = getExceptionBeanClass(className, exception, name, namespace);
            exceptionType = ExceptionType.UserDefined;
            anns = getAnnotations(exceptionBean);
        } else {
            exceptionBean = faultInfoMethod.getReturnType();
            anns = getAnnotations(faultInfoMethod);
        }
        QName faultName = new QName(namespace, name);
        TypeInfo typeRef = new TypeInfo(faultName, exceptionBean, anns);
        CheckedExceptionImpl checkedException =
            new CheckedExceptionImpl(javaMethod, exception, typeRef, exceptionType);
        checkedException.setMessageName(messageName);
        for(FaultAction fa: faultActions) {
            if(fa.className().equals(exception) && !fa.value().equals("")) {
                checkedException.setFaultAction(fa.value());
                break;
            }
        }
        javaMethod.addException(checkedException);
    }
}
 
Example #25
Source File: CheckedExceptionImpl.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public ExceptionType getExceptionType() {
    return exceptionType;
}
 
Example #26
Source File: CheckedExceptionImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
public ExceptionType getExceptionType() {
    return exceptionType;
}
 
Example #27
Source File: RuntimeModeler.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * models the exceptions thrown by <code>method</code> and adds them to the <code>javaMethod</code>
 * runtime model object
 * @param javaMethod the runtime model object to add the exception model objects to
 * @param method the <code>method</code> from which to find the exceptions to model
 */
protected void processExceptions(JavaMethodImpl javaMethod, Method method) {
    Action actionAnn = getAnnotation(method, Action.class);
    FaultAction[] faultActions = {};
    if(actionAnn != null)
        faultActions = actionAnn.fault();
    for (Class<?> exception : method.getExceptionTypes()) {

        //Exclude RuntimeException, RemoteException and Error etc
        if (!EXCEPTION_CLASS.isAssignableFrom(exception))
            continue;
        if (RUNTIME_EXCEPTION_CLASS.isAssignableFrom(exception) || REMOTE_EXCEPTION_CLASS.isAssignableFrom(exception))
            continue;

        Class exceptionBean;
        Annotation[] anns;
        WebFault webFault = getAnnotation(exception, WebFault.class);
        Method faultInfoMethod = getWSDLExceptionFaultInfo(exception);
        ExceptionType exceptionType = ExceptionType.WSDLException;
        String namespace = targetNamespace;
        String name = exception.getSimpleName();
        String beanPackage = packageName + PD_JAXWS_PACKAGE_PD;
        if (packageName.length() == 0)
            beanPackage = JAXWS_PACKAGE_PD;
        String className = beanPackage+ name + BEAN;
        String messageName = exception.getSimpleName();
        if (webFault != null) {
            if (webFault.faultBean().length()>0)
                className = webFault.faultBean();
            if (webFault.name().length()>0)
                name = webFault.name();
            if (webFault.targetNamespace().length()>0)
                namespace = webFault.targetNamespace();
            if (webFault.messageName().length()>0)
                messageName = webFault.messageName();
        }
        if (faultInfoMethod == null)  {
            exceptionBean = getExceptionBeanClass(className, exception, name, namespace);
            exceptionType = ExceptionType.UserDefined;
            anns = getAnnotations(exceptionBean);
        } else {
            exceptionBean = faultInfoMethod.getReturnType();
            anns = getAnnotations(faultInfoMethod);
        }
        QName faultName = new QName(namespace, name);
        TypeInfo typeRef = new TypeInfo(faultName, exceptionBean, anns);
        CheckedExceptionImpl checkedException =
            new CheckedExceptionImpl(javaMethod, exception, typeRef, exceptionType);
        checkedException.setMessageName(messageName);
        for(FaultAction fa: faultActions) {
            if(fa.className().equals(exception) && !fa.value().equals("")) {
                checkedException.setFaultAction(fa.value());
                break;
            }
        }
        javaMethod.addException(checkedException);
    }
}
 
Example #28
Source File: RuntimeModeler.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * models the exceptions thrown by <code>method</code> and adds them to the <code>javaMethod</code>
 * runtime model object
 * @param javaMethod the runtime model object to add the exception model objects to
 * @param method the <code>method</code> from which to find the exceptions to model
 */
protected void processExceptions(JavaMethodImpl javaMethod, Method method) {
    Action actionAnn = getAnnotation(method, Action.class);
    FaultAction[] faultActions = {};
    if(actionAnn != null)
        faultActions = actionAnn.fault();
    for (Class<?> exception : method.getExceptionTypes()) {

        //Exclude RuntimeException, RemoteException and Error etc
        if (!EXCEPTION_CLASS.isAssignableFrom(exception))
            continue;
        if (RUNTIME_EXCEPTION_CLASS.isAssignableFrom(exception) || REMOTE_EXCEPTION_CLASS.isAssignableFrom(exception))
            continue;

        Class exceptionBean;
        Annotation[] anns;
        WebFault webFault = getAnnotation(exception, WebFault.class);
        Method faultInfoMethod = getWSDLExceptionFaultInfo(exception);
        ExceptionType exceptionType = ExceptionType.WSDLException;
        String namespace = targetNamespace;
        String name = exception.getSimpleName();
        String beanPackage = packageName + PD_JAXWS_PACKAGE_PD;
        if (packageName.length() == 0)
            beanPackage = JAXWS_PACKAGE_PD;
        String className = beanPackage+ name + BEAN;
        String messageName = exception.getSimpleName();
        if (webFault != null) {
            if (webFault.faultBean().length()>0)
                className = webFault.faultBean();
            if (webFault.name().length()>0)
                name = webFault.name();
            if (webFault.targetNamespace().length()>0)
                namespace = webFault.targetNamespace();
            if (webFault.messageName().length()>0)
                messageName = webFault.messageName();
        }
        if (faultInfoMethod == null)  {
            exceptionBean = getExceptionBeanClass(className, exception, name, namespace);
            exceptionType = ExceptionType.UserDefined;
            anns = getAnnotations(exceptionBean);
        } else {
            exceptionBean = faultInfoMethod.getReturnType();
            anns = getAnnotations(faultInfoMethod);
        }
        QName faultName = new QName(namespace, name);
        TypeInfo typeRef = new TypeInfo(faultName, exceptionBean, anns);
        CheckedExceptionImpl checkedException =
            new CheckedExceptionImpl(javaMethod, exception, typeRef, exceptionType);
        checkedException.setMessageName(messageName);
        for(FaultAction fa: faultActions) {
            if(fa.className().equals(exception) && !fa.value().equals("")) {
                checkedException.setFaultAction(fa.value());
                break;
            }
        }
        javaMethod.addException(checkedException);
    }
}
 
Example #29
Source File: CheckedExceptionImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public ExceptionType getExceptionType() {
    return exceptionType;
}
 
Example #30
Source File: CheckedExceptionImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public ExceptionType getExceptionType() {
    return exceptionType;
}