In this case we want the application to access the resource from the classpath as if it was on the file system.
We can do this by looking for the file on the classpath, and if found, copying it to a temporary cache directory on disk and serving it from there.
There is one cache dir per Vert.x instance and they are deleted on Vert.x shutdown.
| Modifier and Type | Field and Description |
|---|---|
| private final FileCache | |
| public static final String | |
| private final File | |
| public static final String | |
| public static final String | |
| private final boolean | |
| private final boolean | |
| private static final String | |
| private static final boolean |
| Access | Constructor and Description |
|---|---|
| public | |
| public |
| Modifier and Type | Method and Description |
|---|---|
| public String | |
| public void | close()
Implements io. Close this file resolver, this is a blocking operation. |
| private void | extractFilesFromJarFile(ZipFile zip, String entryFilter)
Extract a subset of the entries to the cache. |
| private ClassLoader | |
| pack-priv FileCache | |
| private static URL | getValidClassLoaderResource(ClassLoader cl, String fileName)
Get a class loader resource that can unpack to a valid cache path. |
| private boolean | Returns: if the bundle resource represented by the bundle URL is a directorythe url url)It is possible to determine if a resource from a bundle is a directory based on whether or not the ClassLoader returns null for a path (which does not already contain a trailing '/') *and* that path with an added trailing '/' |
| private static boolean | |
| private static boolean | |
| private List | Returns: the list of entriesthe URL url)Parse the list of entries of a URL assuming the URL is a jar URL. |
| public File | resolveFile(String
the name to resolve fileName)Implements io. Resolve the file for the specified |
| private File | Returns: the extracted filethe url url, String the file name used to cache the content fileName, boolean isDir)bundle:// urls are used by OSGi implementations to refer to a file contained in a bundle, or in a fragment. |
| private File | |
| private File | |
| private File |
| cache | back to summary |
|---|---|
| private final FileCache cache | |
| CACHE_DIR_BASE_PROP_NAME | back to summary |
|---|---|
| public static final String CACHE_DIR_BASE_PROP_NAME | |
| cwd | back to summary |
|---|---|
| private final File cwd | |
| DISABLE_CP_RESOLVING_PROP_NAME | back to summary |
|---|---|
| public static final String DISABLE_CP_RESOLVING_PROP_NAME | |
| DISABLE_FILE_CACHING_PROP_NAME | back to summary |
|---|---|
| public static final String DISABLE_FILE_CACHING_PROP_NAME | |
| enableCaching | back to summary |
|---|---|
| private final boolean enableCaching | |
| enableCPResolving | back to summary |
|---|---|
| private final boolean enableCPResolving | |
| JAR_URL_SEP | back to summary |
|---|---|
| private static final String JAR_URL_SEP | |
| NON_UNIX_FILE_SEP | back to summary |
|---|---|
| private static final boolean NON_UNIX_FILE_SEP | |
| FileResolverImpl | back to summary |
|---|---|
| public FileResolverImpl() | |
| FileResolverImpl | back to summary |
|---|---|
| public FileResolverImpl(FileSystemOptions fileSystemOptions) | |
| cacheDir | back to summary |
|---|---|
| public String cacheDir() | |
| close | back to summary |
|---|---|
| public void close() throws IOException Implements io. Close this file resolver, this is a blocking operation.
| |
| extractFilesFromJarFile | back to summary |
|---|---|
| private void extractFilesFromJarFile(ZipFile zip, String entryFilter) throws IOException Extract a subset of the entries to the cache. | |
| getClassLoader | back to summary |
|---|---|
| private ClassLoader getClassLoader() | |
| getFileCache | back to summary |
|---|---|
| pack-priv FileCache getFileCache() | |
| getValidClassLoaderResource | back to summary |
|---|---|
| private static URL getValidClassLoaderResource(ClassLoader cl, String fileName) Get a class loader resource that can unpack to a valid cache path. Some valid entries are avoided purposely when we cannot create the corresponding file in the file cache. | |
| isBundleUrlDirectory | back to summary |
|---|---|
| private boolean isBundleUrlDirectory(URL url) It is possible to determine if a resource from a bundle is a directory based on whether or not the ClassLoader returns null for a path (which does not already contain a trailing '/') *and* that path with an added trailing '/'
| |
| isValidCachePath | back to summary |
|---|---|
| private static boolean isValidCachePath(String fileName) | |
| isValidWindowsCachePath | back to summary |
|---|---|
| private static boolean isValidWindowsCachePath(char c) | |
| listOfEntries | back to summary |
|---|---|
| private List Parse the list of entries of a URL assuming the URL is a jar URL.
| |
| resolveFile | back to summary |
|---|---|
| public File resolveFile(String fileName) Implements io. Doc from io. Resolve the file for the specified | |
| unpackFromBundleURL | back to summary |
|---|---|
| private File unpackFromBundleURL(URL url, String fileName, boolean isDir) bundle:// urls are used by OSGi implementations to refer to a file contained in a bundle, or in a fragment. There is not much we can do to get the file from it, except reading it from the url. This method copies the files by reading it from the url. | |
| unpackFromFileURL | back to summary |
|---|---|
| private File unpackFromFileURL(URL url, String fileName, ClassLoader cl) | |
| unpackFromJarURL | back to summary |
|---|---|
| private File unpackFromJarURL(URL url, String fileName, ClassLoader cl) | |
| unpackUrlResource | back to summary |
|---|---|
| private File unpackUrlResource(URL url, String fileName, ClassLoader cl, boolean isDir) | |