rackerlabs/wadl-tools — pull request #124 by dkowis (2014-12-19 00:16:23+00:00)
Title: Use the current class's classloader

If you pass null into the factory creator, it will use the current
thread's ContextClassloader. see:
* [docs for TransformerFactory](http://docs.oracle.com/javase/7/docs/api/javax/xml/transform/TransformerFactory.html#newInstance%28java.lang.String,%20java.lang.ClassLoader%29)
* [docs for XPathFactory](https://docs.oracle.com/javase/7/docs/api/javax/xml/xpath/XPathFactory.html#newInstance%28java.lang.String,%20java.lang.String,%20java.lang.ClassLoader%29)

This results in having to swap out the current thread's classloader,
which isn't always something you're able to do, and it makes it very
difficult to understand which classloader is being used.

Instead, specifying the current class's classloader means it'll look in
the dependency hierarchy that the class was created in, which makes
sense, and is the common way of doing things.

I ran into this problem in Repose when I was actually separating
classpaths for the various EAR file plugins that repose uses. Spring is
firing up these classes, and so I have no control over what thread is
going to be used. It's packaged in an EAR file with the dependencies it
needs, and spring is given the classloader that is scoped to that EAR
file, and so it will know how to find the things if the class's
classloader is used.