public static TransformerFactory newTransformerFactory ( String factoryClassName , ClassLoader classLoader ) throws NoSuchMethodException , IllegalAccessException , InvocationTargetException { // use reflection to avoid JAXP 1.4 (and hence JDK6) requirement Class < ? > [ ] methodTypes = new Class [ ] { String . class , ClassLoader . class } ; Method method = TransformerFactory . class . getDeclaredMethod ( "newInstance" , methodTypes ) ; Object [ ] methodArgs = new Object [ ] { factoryClassName , classLoader } ; return ( TransformerFactory ) method . invoke ( null , methodArgs ) ; }
public for use by unit test