static ClassLoader resolveClassLoader(ClassLoader classLoader) { // 1) if the user provided a classloader through the API, use that one if (classLoader != null) { log.trace("using provided classloader"); return classLoader; } // 2) if the user provided a classloader through the environment, use that // one Environment environment = Environment.getCurrent(); if (environment != null) { classLoader = environment.getClassLoader(); if (classLoader != null) { log.trace("using environment classloader"); return classLoader; } } // 3) otherwise, use the current thread's context classloader log.trace("using context classloader"); return Thread.currentThread().getContextClassLoader(); }