DataType faultType = (DataType)exceptionType.getLogical();
Class<?> faultBean = null;
WebFault fault = cls.getAnnotation(WebFault.class);
if (fault != null) {
faultName = new QName(fault.targetNamespace(), fault.name());
XMLType xmlType = new XMLType(faultName, null);
faultType.setLogical(xmlType);
if (!"".equals(fault.faultBean())) {
try {
faultBean = Class.forName(fault.faultBean(), false, cls.getClassLoader());
} catch (ClassNotFoundException e) {
throw new ServiceRuntimeException(e);
}
} else {
Method m;
try {
m = cls.getMethod("getFaultInfo", (Class[])null);
faultBean = m.getReturnType();
} catch (NoSuchMethodException e) {
// Ignore
}
}
}
if (faultBean == null) {
String faultBeanClassName = cls.getPackage().getName() + ".jaxws." + cls.getSimpleName() + "Bean";
try {
faultBean = Class.forName(faultBeanClassName, false, cls.getClassLoader());
} catch (ClassNotFoundException e) {
faultBean = cls;
}
}
faultType.setPhysical(faultBean);
// TODO: Use the databinding framework to introspect the fault bean class
if (dataBindingExtensionPoint != null) {
result =
dataBindingExtensionPoint.introspectType(faultType, null, Throwable.class.isAssignableFrom(faultBean));
}
/*
The introspection of the fault DT may not have calculated the correct element name,
though we may have already done this in this method. Let's look at the DataType now
that introspection is done, and, if it has an XMLType, let's set the element to the
'faultName' if we calculated one.
*/
if ((faultName != null) && (faultType.getLogical() instanceof XMLType)) {
XMLType faultTypeXML = (XMLType)faultType.getLogical();
// The element name (if set) should match the fault name
faultTypeXML.setElementName(faultName);
}
return result;
}