Package org.ametys.core.util
Class JarFSManager
- java.lang.Object
-
- org.ametys.core.util.JarFSManager
-
public final class JarFSManager extends Object
This component centralize the access to zip files Beware: All opened zip files are kept opened in memory
-
-
Field Summary
Fields Modifier and Type Field Description private static JarFSManager
_instance
private Map<String,FileSystem>
_openedFS
-
Constructor Summary
Constructors Modifier Constructor Description private
JarFSManager()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description FileSystem
getFileSystemByFile(File jarFile)
Return the jar filesystem associated with the given jar fileFileSystem
getFileSystemByResource(String resourcePath)
Return the jar filesystem associated with the given resourceFileSystem
getFileSystemByURI(String jarURI)
Return the jar filesystem associated with the given jar file denoted by its URIstatic JarFSManager
getInstance()
Get the unique instanceString
getJARFileURI(String resourcePath)
Determine the JAR file holding the given resource
-
-
-
Field Detail
-
_instance
private static JarFSManager _instance
-
_openedFS
private Map<String,FileSystem> _openedFS
-
-
Constructor Detail
-
JarFSManager
private JarFSManager()
-
-
Method Detail
-
getInstance
public static JarFSManager getInstance()
Get the unique instance- Returns:
- the unique instance
-
getFileSystemByResource
public FileSystem getFileSystemByResource(String resourcePath) throws IOException
Return the jar filesystem associated with the given resource- Parameters:
resourcePath
- The resource path to seek. Such as 'org/apache/ivy/logo.png'.- Returns:
- The JAR filesystem or null if the resource cannot be found
- Throws:
IOException
- If an error occurred while getting the JAR file of an existing resource
-
getFileSystemByFile
public FileSystem getFileSystemByFile(File jarFile) throws IOException
Return the jar filesystem associated with the given jar file- Parameters:
jarFile
- the jar file to open- Returns:
- The JAR filesystem or null if the file has a problem
- Throws:
IOException
- If an error occurred while opening the JAR file
-
getJARFileURI
public String getJARFileURI(String resourcePath) throws IOException
Determine the JAR file holding the given resource- Parameters:
resourcePath
- The resource path to seek. Such as 'org/apache/ivy/logo.png'.- Returns:
- The JAR file location. Such as '/path/to/jar/ivy.jar' or null if the resource cannot be found
- Throws:
IOException
- If an error occurred while getting the JAR file of an existing resource
-
getFileSystemByURI
public FileSystem getFileSystemByURI(String jarURI) throws IOException
Return the jar filesystem associated with the given jar file denoted by its URI- Parameters:
jarURI
- Such as "jar:file:/path/to/file.jar"- Returns:
- The filesystem or null if the jarURI is null
- Throws:
IOException
- If the JAR file cannot be opened correctly
-
-