Class ClassLoaderPool

java.lang.Object
com.liferay.petra.lang.ClassLoaderPool

public class ClassLoaderPool extends Object
Maps servlet context names to/from the servlet context's class loader.
  • Constructor Details

    • ClassLoaderPool

      public ClassLoaderPool()
  • Method Details

    • getClassLoader

      public static ClassLoader getClassLoader(String contextName)
      Returns the class loader associated with the context name.

      If no class loader is found for the context name, the thread's context class loader is returned as a fallback.

      Parameters:
      contextName - the servlet context's name
      Returns:
      the class loader associated with the context name
    • getContextName

      public static String getContextName(ClassLoader classLoader)
      Returns the context name associated with the class loader.

      If the class loader is null or if no context name is associated with the class loader, {@link <code>"null"</code>} is returned.

      Parameters:
      classLoader - the class loader
      Returns:
      the context name associated with the class loader
    • register

      public static void register(String contextName, ClassLoader classLoader)
    • unregister

      public static void unregister(ClassLoader classLoader)
    • unregister

      public static void unregister(String contextName)