Class ClasspathDescriptorFileFinder

    • Field Detail

      • DEBUG_DESCRIPTOR_FINDER_PROPERTY

        private static final java.lang.String DEBUG_DESCRIPTOR_FINDER_PROPERTY
        See Also:
        Constant Field Values
      • DEBUG_DESCRIPTOR_FINDER

        private static final boolean DEBUG_DESCRIPTOR_FINDER
      • classLoader

        private final java.lang.ClassLoader classLoader
      • names

        private final java.lang.String[] names
      • identifiers

        private final java.util.ArrayList<java.lang.String> identifiers
    • Constructor Detail

      • ClasspathDescriptorFileFinder

        public ClasspathDescriptorFileFinder()
        If this constructor is used then HK2 descriptor files will be found by looking in the classpath of the process. The classloader used will be the classloader for this class itself. The names of the files found will be META-INF/hk2-locator/default.

        This is most commonly used when using HK2 from a stand-alone client in which all the JAR files are on a single classpath

      • ClasspathDescriptorFileFinder

        public ClasspathDescriptorFileFinder​(java.lang.ClassLoader cl)
        This constructor can be used to select the particular classloader to search for HK2 descriptor files. The names of the the files found in this classloader will be META-INF/hk2-locator/default.

        This is commonly used in more complex classloading scenarios where the HK2 descriptor files are not necessarily on the system classpath.

        Parameters:
        cl - May not be null and must be the classloader to use when searching for HK2 descriptor files
      • ClasspathDescriptorFileFinder

        public ClasspathDescriptorFileFinder​(java.lang.ClassLoader cl,
                                             java.lang.String... names)
        This constructor can be used to select the particular classloader to search for HK2 descriptor files. The names of the the files found in this classloader will be META-INF/hk2-locator/name.
        Parameters:
        cl - May not be null and must be the classloader to use when searching for HK2 descriptor files
        names - May not be null and must be the name of the files to search for in the META-INF/hk2-locator directory
    • Method Detail

      • findDescriptorFiles

        public java.util.List<java.io.InputStream> findDescriptorFiles()
                                                                throws java.io.IOException
        Simple implementation of the findDescriptorFiles which does a simple getResources on the classloader in order to find the hk2 descriptor files
        Specified by:
        findDescriptorFiles in interface DescriptorFileFinder
        Returns:
        A non-null (but possibly empty) list of InputStreams for hk2 inhabitant files
        Throws:
        java.io.IOException - If there was an error finding the hk2 inhabitant files
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object