Package de.xima.fc.plugin.helper
Class PluginFileHelper
- java.lang.Object
-
- de.xima.fc.plugin.helper.PluginFileHelper
-
public class PluginFileHelper extends Object
- Author:
- XIMA MEDIA GmbH
-
-
Constructor Summary
Constructors Constructor Description PluginFileHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static IPluginFileHelpercreateFacade(PluginRuntime runtime)Creates a new plugin file helper that delegates to the given runtime.static voiddeletePluginFiles(PluginRuntime prtm)static voiddeletePluginFiles(String scopeKey, String runtimeKey)static voiddeletePluginJarAndUnpacked(File jarFile)static FilegetPluginFolder(PluginRuntime runtime)The path to the folder with all plugin files, such as/tmp/formcycle/system/04ed.static FilegetPluginFolder(String scopeKey, String runtimeKey)The path to the folder with all plugin files, such as/tmp/formcycle/system/04ed.static FilegetPluginJarFile(PluginRuntime runtime)The path to the JAR file of the plugin, such as/tmp/formcycle/system/04ed/plugin.jar.static FilegetPluginJarFile(String scopeKey, String runtimeKey)The path to the JAR file of the plugin, such as/tmp/formcycle/system/04ed/plugin.jar.static FilegetPluginJarFromUnpackedRootDir(File file)Finds the plugin JAR file from a given root directory.static FilegetPluginJarUnpackedDir(PluginRuntime runtime)The base directory with all files from an unpacked JAR, such as/tmp/formcycle/system/04ed/plugin.static FilegetPluginJarUnpackedDir(File file)The base directory with all files from an unpacked JAR, such as/tmp/formcycle/system/04ed/plugin.static FilegetPluginJarUnpackedDir(String scopeKey, String runtimeKey)The base directory with all files from an unpacked JAR, such as/tmp/formcycle/system/04ed/plugin.static FilegetPluginJarUnpackedManifestFile(File file)The manifest file from the unpacked JAR, such as/tmp/formcycle/system/04ed/plugin/MANIFEST.MF.static FilegetPluginJarUnpackedManifestFile(String scopeKey, String runtimeKey)The manifest file from the unpacked JAR, such as/tmp/formcycle/system/04ed/plugin/MANIFEST.MF.static FilegetPluginJarUnpackedRootDir(File file)The root directory with the unpacked files from the JAR, such as/tmp/formcycle/system/04ed/plugin/root.static FilegetPluginJarUnpackedRootDir(String scopeKey, String runtimeKey)The root directory with the unpacked files from the JAR, such as/tmp/formcycle/system/04ed/plugin/root.static FilegetPluginMetaFile(PluginRuntime rtm)static FilegetPluginMetaFile(String scopeKey, String runtimeKey)static FilegetPluginPropertiesFile(PluginRuntime rtm)static FilegetPluginPropertiesFile(String scopeKey, String runtimeKey)static booleanisUnpackedJarDir(File file)static voidremoveJarFileCacheEntries(File jarToDelete)Deprecated.This depends on internal implementation details of the JDK and may or may not work.static voidremoveJarFileCacheEntries(JarFile jarToDelete)Deprecated.This depends on internal implementation details of the JDK and may or may not work.static UnpackedJarFileunpackJarFile(File file, File unpackedDir)Unpacks the contents of a JAR file to a given directory.static voidupdatePluginFiles(PluginSyncData pluginData)
-
-
-
Method Detail
-
updatePluginFiles
public static void updatePluginFiles(PluginSyncData pluginData) throws IOException
- Throws:
IOException
-
removeJarFileCacheEntries
@Deprecated public static void removeJarFileCacheEntries(File jarToDelete)
Deprecated.This depends on internal implementation details of the JDK and may or may not work. Using reflection to access the internals ofsun.net.www.protocol.jarand to delete caches is not supported by Java anymore under the new module system.Attempts to remove any cache entry forJarURLConnectionandJarFile.- Parameters:
jarToDelete- the jar file to remove from cache
-
removeJarFileCacheEntries
@Deprecated public static void removeJarFileCacheEntries(JarFile jarToDelete)
Deprecated.This depends on internal implementation details of the JDK and may or may not work. Using reflection to access the internals ofsun.net.www.protocol.jarand to delete caches is not supported by Java anymore under the new module system.Attempts to remove any cache entry forJarURLConnectionandJarFile.- Parameters:
jarToDelete- the jar file to remove from cache
-
deletePluginFiles
public static void deletePluginFiles(PluginRuntime prtm) throws IOException
- Throws:
IOException
-
deletePluginFiles
public static void deletePluginFiles(String scopeKey, String runtimeKey) throws IOException
- Throws:
IOException
-
getPluginPropertiesFile
public static File getPluginPropertiesFile(PluginRuntime rtm)
-
getPluginPropertiesFile
public static File getPluginPropertiesFile(String scopeKey, String runtimeKey)
-
getPluginMetaFile
public static File getPluginMetaFile(PluginRuntime rtm)
-
getPluginJarFile
public static File getPluginJarFile(PluginRuntime runtime)
The path to the JAR file of the plugin, such as/tmp/formcycle/system/04ed/plugin.jar.- Parameters:
runtime- Runtime of the plugin with a scope and runtime key.- Returns:
- The path to the JAR file of the plugin.
-
getPluginJarFile
public static File getPluginJarFile(String scopeKey, String runtimeKey)
The path to the JAR file of the plugin, such as/tmp/formcycle/system/04ed/plugin.jar.- Parameters:
scopeKey- Scope key of the plugin, either the system scope or a client scope.runtimeKey- Unique runtime key of the plugin.- Returns:
- The path to the JAR file of the plugin.
-
getPluginJarUnpackedRootDir
public static File getPluginJarUnpackedRootDir(File file)
The root directory with the unpacked files from the JAR, such as/tmp/formcycle/system/04ed/plugin/root. This is also the root for the plugin JAR classpath.- Parameters:
file- JAR file path fromgetPluginJarFile(String, String), or theunpacked directoryitself.- Returns:
- The root directory with the unpacked files from the JAR
-
getPluginJarUnpackedRootDir
public static File getPluginJarUnpackedRootDir(String scopeKey, String runtimeKey)
The root directory with the unpacked files from the JAR, such as/tmp/formcycle/system/04ed/plugin/root. This is also the root for the plugin JAR classpath.- Parameters:
scopeKey- Scope key of the plugin, either the system scope or a client scope.runtimeKey- Unique runtime key of the plugin.- Returns:
- The root directory with the unpacked files from the JAR
-
getPluginJarUnpackedManifestFile
public static File getPluginJarUnpackedManifestFile(File file)
The manifest file from the unpacked JAR, such as/tmp/formcycle/system/04ed/plugin/MANIFEST.MF.- Parameters:
file- JAR file path fromgetPluginJarFile(String, String), or theunpacked directoryitself.- Returns:
- The manifest file from the unpacked JAR
-
getPluginJarUnpackedManifestFile
public static File getPluginJarUnpackedManifestFile(String scopeKey, String runtimeKey)
The manifest file from the unpacked JAR, such as/tmp/formcycle/system/04ed/plugin/MANIFEST.MF.- Parameters:
scopeKey- Scope key of the plugin, either the system scope or a client scope.runtimeKey- Unique runtime key of the plugin.- Returns:
- The manifest file from the unpacked JAR
-
getPluginJarUnpackedDir
public static File getPluginJarUnpackedDir(String scopeKey, String runtimeKey)
The base directory with all files from an unpacked JAR, such as/tmp/formcycle/system/04ed/plugin. This is also the root for the plugin JAR classpath.- Parameters:
scopeKey- Scope key of the plugin, either the system scope or a client scope.runtimeKey- Unique runtime key of the plugin.- Returns:
- The base directory with all files from an unpacked JAR.
-
getPluginJarUnpackedDir
public static File getPluginJarUnpackedDir(PluginRuntime runtime)
The base directory with all files from an unpacked JAR, such as/tmp/formcycle/system/04ed/plugin. This is also the root for the plugin JAR classpath.- Parameters:
runtime- Runtime of the plugin with a scope and runtime key.- Returns:
- The base directory with all files from an unpacked JAR.
-
getPluginJarUnpackedDir
public static File getPluginJarUnpackedDir(File file)
The base directory with all files from an unpacked JAR, such as/tmp/formcycle/system/04ed/plugin. This is also the root for the plugin JAR classpath.- Parameters:
file- JAR file path fromgetPluginJarFile(String, String), or the unpacked directory itself.- Returns:
- The base directory with all files from an unpacked JAR.
-
getPluginFolder
public static File getPluginFolder(PluginRuntime runtime)
The path to the folder with all plugin files, such as/tmp/formcycle/system/04ed.- Parameters:
runtime- Runtime of the plugin with a scope and runtime key.- Returns:
- The path to the folder with all plugin files.
-
getPluginFolder
public static File getPluginFolder(String scopeKey, String runtimeKey)
The path to the folder with all plugin files, such as/tmp/formcycle/system/04ed.- Parameters:
scopeKey- Scope key of the plugin, either the system scope or a client scope.runtimeKey- Unique runtime key of the plugin.- Returns:
- The path to the folder with all plugin files.
-
unpackJarFile
public static UnpackedJarFile unpackJarFile(File file, File unpackedDir) throws IOException
Unpacks the contents of a JAR file to a given directory. The directory is deleted, if it exists. For Multi-release JAR files, this method unpacks the files corresponding to the Java versionof the current JVM.- Parameters:
file- A JAR file to unpack.unpackedDir- Target directory. When this directory exists already, it is removed- Returns:
- A descriptor for the various unpacked files.
- Throws:
IOException- When the JAR file could not be read of the unpacked files could not be written to the disk.
-
createFacade
public static IPluginFileHelper createFacade(PluginRuntime runtime)
Creates a new plugin file helper that delegates to the given runtime.- Parameters:
runtime- Runtime of an initialized plugin.- Returns:
- A new plugin file helper that delegates to the given runtime.
-
deletePluginJarAndUnpacked
public static void deletePluginJarAndUnpacked(File jarFile)
-
isUnpackedJarDir
public static boolean isUnpackedJarDir(File file)
- Parameters:
file- A directory to check, or a plugin JAR file.- Returns:
- Whether the given directory is an
getPluginJarUnpackedDir(PluginRuntime), or whether the JAR file is next to such a directory.
-
getPluginJarFromUnpackedRootDir
public static File getPluginJarFromUnpackedRootDir(File file)
Finds the plugin JAR file from a given root directory. This is the inverse operation ofgetPluginJarFromUnpackedRootDir(File).- Parameters:
file- Anunpacked root dir.- Returns:
- The plugin JAR file for the unpacked root dir.
-
-