Date: prev next · Thread: first prev next last
2011 Archives by date, by thread · List index


On Fri, 2011-11-04 at 16:23 +0100, Stephan Bergmann wrote:
Anyway, you have been warned.  ;)

Pfff, seems a sure route to madness to have to second guess every
possible java api over and above its documentation in case it uses some
ContextClassLoader under the hood. *shudder*, that'd be some audit
effort. Direct uses are one thing, but indirect hidden ones.

Anyway, is your suggested wrapper correct ? Looks a bit odd now that I
actually read it as opposed to boggle at it.

i.e.

 DocumentBuilderFactory dbFactory;
 ClassLoader old = Thread.currentThread().getContextClassLoader();
 ClassLoader c = OfficeDocumentReportTarget.class.getClassLoader();
 if (c != null) {
     // otherwise, hope context class loader already contains a non-null
value
     Thread.currentThread().setContextClassLoader(c); //like so I guess?
 }
 try {
     dbFactory = DocumentBuilderFactory.newInstance();
 } finally {
     if (c != null) {
         Thread.currentThread().setContextClassLoader(old);
     }
 }

C.


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.