Package com.jogamp.common.util.cache
Class TempJarCache
- java.lang.Object
-
- com.jogamp.common.util.cache.TempJarCache
-
public class TempJarCache extends Object
Static Jar file cache handler using an underlying instance ofTempFileCache
, seegetTempFileCache()
.Lifecycle: Concurrently running JVMs and ClassLoader
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
TempJarCache.LoadState
-
Constructor Summary
Constructors Constructor Description TempJarCache()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
addAll(Class<?> certClass, Uri jarUri)
Adds all types, native libraries, class files and other files (resources) if not yet added.static void
addClasses(Class<?> certClass, Uri jarUri)
Adds native classes, if not yet added.static boolean
addNativeLibs(Class<?> certClass, Uri jarUri, String nativeLibraryPath)
Adds native libraries, if not yet added.static void
addResources(Class<?> certClass, Uri jarUri)
Adds native resources, if not yet added.static boolean
checkClasses(Uri jarUri, TempJarCache.LoadState exp)
static boolean
checkNativeLibs(Uri jarUri, TempJarCache.LoadState exp)
static boolean
checkResources(Uri jarUri, TempJarCache.LoadState exp)
static String
findLibrary(String libName)
IfisInitialized(true)
is false due to lack of executable support only, this method always returns false.static String
findResource(String name)
Similar toClassLoader.getResource(String)
.static Uri
getResourceUri(String name)
Similar toClassLoader.getResource(String)
.static TempFileCache
getTempFileCache()
static boolean
initSingleton()
Documented way to kick off static initialization.static boolean
isInitialized(boolean forExecutables)
-
-
-
Method Detail
-
initSingleton
public static boolean initSingleton()
Documented way to kick off static initialization.- Returns:
- true is static initialization was successful
-
isInitialized
public static boolean isInitialized(boolean forExecutables)
- Parameters:
forExecutables
- iftrue
, method also tests whether the underlying cache is suitable to load native libraries or launch executables- Returns:
- true if this class has been properly initialized, ie. is in use. Otherwise returns false.
-
getTempFileCache
public static TempFileCache getTempFileCache()
- Returns:
- the underlying
TempFileCache
- Throws:
JogampRuntimeException
- if notisInitialized(false)
-
checkNativeLibs
public static boolean checkNativeLibs(Uri jarUri, TempJarCache.LoadState exp) throws IOException
- Parameters:
jarUri
-exp
-- Returns:
- Throws:
IOException
JogampRuntimeException
- if notisInitialized(false)
-
checkClasses
public static boolean checkClasses(Uri jarUri, TempJarCache.LoadState exp) throws IOException
- Parameters:
jarUri
-exp
-- Returns:
- Throws:
IOException
JogampRuntimeException
- if notisInitialized(false)
-
checkResources
public static boolean checkResources(Uri jarUri, TempJarCache.LoadState exp) throws IOException
- Parameters:
jarUri
-exp
-- Returns:
- Throws:
IOException
JogampRuntimeException
- if notisInitialized(false)
-
addNativeLibs
public static final boolean addNativeLibs(Class<?> certClass, Uri jarUri, String nativeLibraryPath) throws IOException, SecurityException, IllegalArgumentException, URISyntaxException
Adds native libraries, if not yet added.- Parameters:
certClass
- if class is certified, the JarFile entries needs to have the same certificatejarUri
-nativeLibraryPath
- if not null, only extracts native libraries within this path.- Returns:
- true if native libraries were added or previously loaded from given jarUri, otherwise false
- Throws:
IOException
- if thejarUri
could not be loaded or a previous load attempt failedSecurityException
URISyntaxException
IllegalArgumentException
JogampRuntimeException
- if notisInitialized(true)
-
addClasses
public static final void addClasses(Class<?> certClass, Uri jarUri) throws IOException, SecurityException, IllegalArgumentException, URISyntaxException
Adds native classes, if not yet added. TODO class access pending needs Classloader.defineClass(..) access, ie. own derivation - will do when needed ..- Parameters:
certClass
- if class is certified, the JarFile entries needs to have the same certificatejarUri
-- Throws:
IOException
- if thejarUri
could not be loaded or a previous load attempt failedSecurityException
URISyntaxException
IllegalArgumentException
JogampRuntimeException
- if notisInitialized(false)
-
addResources
public static final void addResources(Class<?> certClass, Uri jarUri) throws IOException, SecurityException, IllegalArgumentException, URISyntaxException
Adds native resources, if not yet added.- Parameters:
certClass
- if class is certified, the JarFile entries needs to have the same certificatejarUri
-- Throws:
IOException
- if thejarUri
could not be loaded or a previous load attempt failedSecurityException
URISyntaxException
IllegalArgumentException
JogampRuntimeException
- if notisInitialized(false)
-
addAll
public static final void addAll(Class<?> certClass, Uri jarUri) throws IOException, SecurityException, IllegalArgumentException, URISyntaxException
Adds all types, native libraries, class files and other files (resources) if not yet added. TODO class access pending needs Classloader.defineClass(..) access, ie. own derivation - will do when needed ..- Parameters:
certClass
- if class is certified, the JarFile entries needs to have the same certificatejarUri
-- Throws:
IOException
- if thejarUri
could not be loaded or a previous load attempt failedSecurityException
URISyntaxException
IllegalArgumentException
JogampRuntimeException
- if notisInitialized(false)
-
findLibrary
public static final String findLibrary(String libName)
IfisInitialized(true)
is false due to lack of executable support only, this method always returns false.- Parameters:
libName
-- Returns:
- the found native library path within this cache or null if not found
- Throws:
JogampRuntimeException
- if notisInitialized(false)
-
findResource
public static final String findResource(String name)
Similar toClassLoader.getResource(String)
.- Parameters:
name
-- Returns:
- Throws:
JogampRuntimeException
- if notisInitialized(false)
-
getResourceUri
public static final Uri getResourceUri(String name) throws URISyntaxException
Similar toClassLoader.getResource(String)
.- Parameters:
name
-- Returns:
- Throws:
URISyntaxException
JogampRuntimeException
- if notisInitialized(false)
-
-