Top Description Fields Constructors Methods
org.glassfish.hk2.utilities

public Class ClasspathDescriptorFileFinder

extends Object
implements DescriptorFileFinder, DescriptorFileFinderInformation
Class Inheritance
All Implemented Interfaces
org.glassfish.hk2.api.DescriptorFileFinderInformation, org.glassfish.hk2.api.DescriptorFileFinder
Imports
java.io.IOException, .InputStream, java.net.URISyntaxException, .URL, java.security.AccessController, .PrivilegedAction, java.util.ArrayList, .Arrays, .Enumeration, .List, org.glassfish.hk2.api.DescriptorFileFinder, .DescriptorFileFinderInformation, org.glassfish.hk2.utilities.reflection.Logger

This is an implementation of DescriptorFileFinder that uses a particular classloader in order to find descriptor files.
Author
jwells

Field Summary

Modifier and TypeField and Description
private final ClassLoader
private static final boolean
private static final String
private static final String
private final List<String>
private final String[]
private final String

Constructor Summary

AccessConstructor and Description
public
ClasspathDescriptorFileFinder()

If this constructor is used then HK2 descriptor files will be found by looking in the classpath of the process.

public
ClasspathDescriptorFileFinder(ClassLoader
May not be null and must be the classloader to use when searching for HK2 descriptor files
cl
)

This constructor can be used to select the particular classloader to search for HK2 descriptor files.

public
ClasspathDescriptorFileFinder(ClassLoader
May not be null and must be the classloader to use when searching for HK2 descriptor files
cl
,
String...
May not be null and must be the name of the files to search for in the META-INF/hk2-locator directory
names
)

This constructor can be used to select the particular classloader to search for HK2 descriptor files.

public
ClasspathDescriptorFileFinder(String
The directory of locator files, the class loader will search from
resourceBase
,
ClassLoader
May not be null and must be the classloader to use when searching for HK2 descriptor files
cl
)

This constructor can be used to select the particular classloader to search for all files from the given locator directory.

private

Method Summary

Modifier and TypeMethod and Description
public List<InputStream>
findDescriptorFiles()

Implements org.glassfish.hk2.api.DescriptorFileFinder.findDescriptorFiles.

Simple implementation of the findDescriptorFiles which does a simple getResources on the classloader in order to find the hk2 descriptor files

public List<String>
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

classLoaderback to summary
private final ClassLoader classLoader
DEBUG_DESCRIPTOR_FINDERback to summary
private static final boolean DEBUG_DESCRIPTOR_FINDER
DEBUG_DESCRIPTOR_FINDER_PROPERTYback to summary
private static final String DEBUG_DESCRIPTOR_FINDER_PROPERTY
DEFAULT_NAMEback to summary
private static final String DEFAULT_NAME
identifiersback to summary
private final List<String> identifiers
namesback to summary
private final String[] names
resourceBaseback to summary
private final String resourceBase

Constructor Detail

ClasspathDescriptorFileFinderback to summary
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

ClasspathDescriptorFileFinderback to summary
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:ClassLoader

May not be null and must be the classloader to use when searching for HK2 descriptor files

ClasspathDescriptorFileFinderback to summary
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:ClassLoader

May not be null and must be the classloader to use when searching for HK2 descriptor files

names:String[]

May not be null and must be the name of the files to search for in the META-INF/hk2-locator directory

ClasspathDescriptorFileFinderback to summary
public ClasspathDescriptorFileFinder(String resourceBase, ClassLoader cl)

This constructor can be used to select the particular classloader to search for all files from the given locator directory. By using this constructor, all files in the given directory are assumed to be HK2 descriptor files.

Parameters
resourceBase:String

The directory of locator files, the class loader will search from

cl:ClassLoader

May not be null and must be the classloader to use when searching for HK2 descriptor files

ClasspathDescriptorFileFinderback to summary
private ClasspathDescriptorFileFinder(String resourceBase, ClassLoader cl, String... names)

Method Detail

findDescriptorFilesback to summary
public List<InputStream> findDescriptorFiles() throws IOException

Implements org.glassfish.hk2.api.DescriptorFileFinder.findDescriptorFiles.

Simple implementation of the findDescriptorFiles which does a simple getResources on the classloader in order to find the hk2 descriptor files

Annotations
@Override
Exceptions
IOException:

Doc from org.glassfish.hk2.api.DescriptorFileFinder.findDescriptorFiles.

If there was an error finding the hk2 inhabitant files

getDescriptorFileInformationback to summary
public List<String> getDescriptorFileInformation()

Implements org.glassfish.hk2.api.DescriptorFileFinderInformation.getDescriptorFileInformation.

Doc from org.glassfish.hk2.api.DescriptorFileFinderInformation.getDescriptorFileInformation.

This list must have the same cardinality as DescriptorFileFinder#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 a java.net.URL then the toString of the URL would be appropriate. If the InputStream is from a java.io.File then the Absolute path to that file might be appropriate

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.