Class ClassLoaderSwitcher

  • All Implemented Interfaces:
    java.lang.AutoCloseable

    public class ClassLoaderSwitcher
    extends java.lang.Object
    implements java.lang.AutoCloseable
    Help to switch the class loader of current thread to the NarClassLoader, and change it back when it's done. With the help of try-with-resources statement, the code would be cleaner than using try finally every time.
    • Constructor Summary

      Constructors 
      Constructor Description
      ClassLoaderSwitcher​(java.lang.ClassLoader classLoader)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ClassLoaderSwitcher

        public ClassLoaderSwitcher​(java.lang.ClassLoader classLoader)
    • Method Detail

      • close

        public void close()
        Specified by:
        close in interface java.lang.AutoCloseable