Package org.glassfish.hk2.utilities
Class ClasspathDescriptorFileFinder
- java.lang.Object
-
- org.glassfish.hk2.utilities.ClasspathDescriptorFileFinder
-
- All Implemented Interfaces:
DescriptorFileFinder
,DescriptorFileFinderInformation
- Direct Known Subclasses:
ClasspathDescriptorFileFinder
public class ClasspathDescriptorFileFinder extends Object implements DescriptorFileFinder, DescriptorFileFinderInformation
This is an implementation ofDescriptorFileFinder
that uses a particular classloader in order to find descriptor files.- Author:
- jwells
-
-
Field Summary
-
Fields inherited from interface org.glassfish.hk2.api.DescriptorFileFinder
RESOURCE_BASE
-
-
Constructor Summary
Constructors Constructor Description ClasspathDescriptorFileFinder()
If this constructor is used then HK2 descriptor files will be found by looking in the classpath of the process.ClasspathDescriptorFileFinder(ClassLoader cl)
This constructor can be used to select the particular classloader to search for HK2 descriptor files.ClasspathDescriptorFileFinder(ClassLoader cl, String... names)
This constructor can be used to select the particular classloader to search for HK2 descriptor files.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description List<InputStream>
findDescriptorFiles()
Simple implementation of the findDescriptorFiles which does a simple getResources on the classloader in order to find the hk2 descriptor filesList<String>
getDescriptorFileInformation()
This list must have the same cardinality asDescriptorFileFinder.findDescriptorFiles()
.String
toString()
-
-
-
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(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(ClassLoader cl, 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 filesnames
- 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 List<InputStream> findDescriptorFiles() throws 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 interfaceDescriptorFileFinder
- Returns:
- A non-null (but possibly empty) list of InputStreams for hk2 inhabitant files
- Throws:
IOException
- If there was an error finding the hk2 inhabitant files
-
getDescriptorFileInformation
public List<String> getDescriptorFileInformation()
Description copied from interface:DescriptorFileFinderInformation
This list must have the same cardinality asDescriptorFileFinder.findDescriptorFiles()
. The Strings returned from this list must give identifying information about the InputStream with the same index. For example, if the InputStream is from aURL
then the toString of the URL would be appropriate. If the InputStream is from aFile
then the Absolute path to that file might be appropriate- Specified by:
getDescriptorFileInformation
in interfaceDescriptorFileFinderInformation
- Returns:
- Identifying information about the InputStream
returned by
DescriptorFileFinder.findDescriptorFiles()
correlated by index
-
-