Interface ClassResolver


  • public interface ClassResolver
    A class resolver for loading classes in a loosly coupled manner to cater for different platforms such as standalone, web container, j2ee container and OSGi platforms.
    • Method Detail

      • addClassLoader

        void addClassLoader​(ClassLoader classLoader)
        Adds a custom class loader to use.
        Parameters:
        classLoader - a custom class loader
      • resolveClass

        Class<?> resolveClass​(String name)
        Resolves the given class by its name
        Parameters:
        name - full qualified name of class
        Returns:
        the class if resolved, null if not found.
      • resolveClass

        <T> Class<T> resolveClass​(String name,
                                  Class<T> type)
        Resolves the given class by its name
        Parameters:
        name - full qualified name of class
        type - the expected type of the class
        Returns:
        the class if resolved, null if not found.
      • resolveClass

        Class<?> resolveClass​(String name,
                              ClassLoader loader)
        Resolves the given class by its name
        Parameters:
        name - full qualified name of class
        loader - use the provided class loader
        Returns:
        the class if resolved, null if not found.
      • resolveClass

        <T> Class<T> resolveClass​(String name,
                                  Class<T> type,
                                  ClassLoader loader)
        Resolves the given class by its name
        Parameters:
        name - full qualified name of class
        type - the expected type of the class
        loader - use the provided class loader
        Returns:
        the class if resolved, null if not found.
      • resolveMandatoryClass

        Class<?> resolveMandatoryClass​(String name)
                                throws ClassNotFoundException
        Resolves the given class by its name
        Parameters:
        name - full qualified name of class
        Returns:
        the class if resolved, null if not found.
        Throws:
        ClassNotFoundException - is thrown if class not found
      • resolveMandatoryClass

        <T> Class<T> resolveMandatoryClass​(String name,
                                           Class<T> type)
                                    throws ClassNotFoundException
        Resolves the given class by its name
        Parameters:
        name - full qualified name of class
        type - the expected type of the class
        Returns:
        the class if resolved, null if not found.
        Throws:
        ClassNotFoundException - is thrown if class not found
      • resolveMandatoryClass

        Class<?> resolveMandatoryClass​(String name,
                                       ClassLoader loader)
                                throws ClassNotFoundException
        Resolves the given class by its name
        Parameters:
        name - full qualified name of class
        loader - use the provided class loader
        Returns:
        the class if resolved, null if not found.
        Throws:
        ClassNotFoundException - is thrown if class not found
      • resolveMandatoryClass

        <T> Class<T> resolveMandatoryClass​(String name,
                                           Class<T> type,
                                           ClassLoader loader)
                                    throws ClassNotFoundException
        Resolves the given class by its name
        Parameters:
        name - full qualified name of class
        type - the expected type of the class
        loader - use the provided class loader
        Returns:
        the class if resolved, null if not found.
        Throws:
        ClassNotFoundException - is thrown if class not found
      • loadResourceAsStream

        InputStream loadResourceAsStream​(String uri)
        Loads the given resource as a stream
        Parameters:
        uri - the uri of the resource
        Returns:
        as a stream
      • loadResourceAsURL

        URL loadResourceAsURL​(String uri)
        Loads the given resource as a URL
        Parameters:
        uri - the uri of the resource
        Returns:
        as a URL
      • loadResourcesAsURL

        Enumeration<URL> loadResourcesAsURL​(String uri)
        Loads the given resources as a URL from the current bundle/classloader
        Parameters:
        uri - the uri of the resource
        Returns:
        the URLs found on the classpath
      • loadAllResourcesAsURL

        Enumeration<URL> loadAllResourcesAsURL​(String uri)
        Loads the given resources as a URL from all bundles/classloaders
        Parameters:
        uri - the uri of the resource
        Returns:
        the URLs found on the classpath