use of com.sun.xml.ws.api.model.ExceptionType in project metro-jax-ws by eclipse-ee4j.
the class RuntimeModeler method processExceptions.
/**
* 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, jakarta.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);
}
}
Aggregations