use of javax.xml.soap.SAAJMetaFactory in project tomee by apache.
the class SaajMetaFactoryImpl method callFactoryMethod.
private Object callFactoryMethod(String methodName, String arg) throws SOAPException {
SAAJMetaFactory factory = (SAAJMetaFactory) SaajFactoryFinder.find("javax.xml.soap.MetaFactory");
try {
Method method = factory.getClass().getDeclaredMethod(methodName, new Class[] { String.class });
boolean accessibility = method.isAccessible();
try {
method.setAccessible(true);
Object result = method.invoke(factory, new Object[] { arg });
return result;
} catch (InvocationTargetException e) {
if (e.getTargetException() instanceof SOAPException) {
throw (SOAPException) e.getTargetException();
} else {
throw new SOAPException("Error calling factory method: " + methodName, e);
}
} catch (IllegalArgumentException | IllegalAccessException e) {
throw new SOAPException("Error calling factory method: " + methodName, e);
} finally {
method.setAccessible(accessibility);
}
} catch (NoSuchMethodException e) {
throw new SOAPException("Factory method not found: " + methodName, e);
}
}
Aggregations