All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.giraone.io.copier.common.ClassUtils Maven / Gradle / Ivy

Go to download

Utility JAR for copying a file tree from web server or from classpath resources to a (local) file system.

The newest version!
package com.giraone.io.copier.common;

/**
 * Miscellaneous java.lang.Class utility methods inspired by org.springframework.util.ClassUtils.
 */
public class ClassUtils {

    /**
     * Return the default ClassLoader to use:
     * 
    *
  • typically the thread context ClassLoader, if available.
  • *
  • otherwise the ClassLoader that loaded this ClassUtils class
  • *
* Call this method if you intend to use the thread context ClassLoader in a scenario where you clearly prefer a non-null * ClassLoader reference: for example, for class path resource loading. * * @return a class loader or null */ public static ClassLoader getDefaultClassLoader() { ClassLoader ret = null; try { ret = Thread.currentThread().getContextClassLoader(); } catch (Throwable ex) { // Cannot get thread context ClassLoader - using fallback... } if (ret == null) { // No thread context class loader -> use class loader of this class. ret = ClassUtils.class.getClassLoader(); if (ret == null) { // getClassLoader() returning null indicates the bootstrap ClassLoader. try { ret = ClassLoader.getSystemClassLoader(); } catch (Throwable ex) { // Cannot access system ClassLoader - the caller must live with null. } } } return ret; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy