Class ServiceClassLoader

java.lang.Object
java.lang.ClassLoader
i5.las2peer.classLoaders.ServiceClassLoader

public class ServiceClassLoader extends ClassLoader
A service class loader is responsible for loading classes from the service bundle, probably loaded via a Repository
  • Constructor Details

    • ServiceClassLoader

      public ServiceClassLoader(LoadedLibrary lib, ClassLoader parent, ClassLoaderPolicy policy)
      create a new class loader for a given library.
      Parameters:
      lib - A library to load service classes from
      parent - A parent class loader
      policy - A class loader policy
  • Method Details

    • findClass

      protected Class<?> findClass(String className) throws ClassNotFoundException
      Overrides:
      findClass in class ClassLoader
      Throws:
      ClassNotFoundException
    • loadClass

      protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException
      loading classes in a Library class loader follows the following steps: check if the class has already been loaded look into all bundles class loaders this library class loader has been registered to look into the bootstrap class loader alert that the class cannot be found
      Overrides:
      loadClass in class ClassLoader
      Parameters:
      name - A class name to load
      resolve - If true the loaded class is resolved
      Returns:
      class definition of the requested class
      Throws:
      ClassNotFoundException - If the class was not found
    • getLibrary

      public LoadedLibrary getLibrary()
      get the library this loader is responsible for
      Returns:
      library linked to this classloader
    • getResource

      public URL getResource(String resourceName)
      get the URL for a resource
      Overrides:
      getResource in class ClassLoader
      Parameters:
      resourceName - A resource name
      Returns:
      Returns the URL for the resource or null, if the resource was not found