Class SharedUtilityClassLoader

All Implemented Interfaces:
Closeable, AutoCloseable

public class SharedUtilityClassLoader extends URLClassLoader
Singleton shared ClassLoader for common utility classes and shared dependencies.

Serves as the parent ClassLoader for all RuleClassLoader instances to ensure shared classes (such as API contracts, Jackson nodes, and utility classes) are loaded once in Metaspace, avoiding redundant class definitions and reducing memory overhead.

  • Method Details

    • getInstance

      public static SharedUtilityClassLoader getInstance()
      Retrieves the singleton instance of SharedUtilityClassLoader.
      Returns:
      singleton SharedUtilityClassLoader instance
    • isSharedPackage

      public boolean isSharedPackage(String className)
      Checks if a given class name falls under the packages shared by this ClassLoader.
      Parameters:
      className - FQCN to check
      Returns:
      true if the class belongs to a shared package prefix
    • loadClass

      protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException
      Overrides:
      loadClass in class ClassLoader
      Throws:
      ClassNotFoundException
    • getSharedLoadedClassNames

      public Set<String> getSharedLoadedClassNames()
    • getSharedPackages

      public Set<String> getSharedPackages()