Top Inners Fields Constructors Methods
com.jogamp.common.util.cache

public Class TempJarCache

extends Object
Class Inheritance
Imports
java.io.File, .IOException, java.net.URISyntaxException, java.security.cert.Certificate, java.util.HashMap, .Map, java.util.jar.JarFile, jogamp.common.Debug, com.jogamp.common.net.Uri, com.jogamp.common.os.NativeLibrary, com.jogamp.common.util.JarUtil, .SecurityUtil

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum

Field Summary

Modifier and TypeField and Description
private static Map<Uri, TempJarCache.LoadState>
private static final boolean
private static volatile boolean
private static Map<Uri, TempJarCache.LoadState>
private static Map<String, String>
private static Map<Uri, TempJarCache.LoadState>
private static volatile boolean
private static TempFileCache

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static final synchronized void
addAll(final Class<?>
if class is certified, the JarFile entries needs to have the same certificate
certClass
,
final Uri jarUri)

Adds all types, native libraries, class files and other files (resources) if not yet added.

public static final synchronized void
addClasses(final Class<?>
if class is certified, the JarFile entries needs to have the same certificate
certClass
,
final Uri jarUri)

Adds native classes, if not yet added.

public static final synchronized boolean

Returns:

true if native libraries were added or previously loaded from given jarUri, otherwise false
addNativeLibs
(final Class<?>
if class is certified, the JarFile entries needs to have the same certificate
certClass
,
final Uri jarUri, final String
if not null, only extracts native libraries within this path.
nativeLibraryPath
)

Adds native libraries, if not yet added.

public static final synchronized void
addResources(final Class<?> certClass, final URI jarURI)

Deprecated Use addResources(Class, Uri)
See addResources(Class, Uri)
public static final synchronized void
addResources(final Class<?>
if class is certified, the JarFile entries needs to have the same certificate
certClass
,
final Uri jarUri)

Adds native resources, if not yet added.

public static synchronized boolean
checkClasses(final Uri jarUri, final TempJarCache.LoadState exp)

pack-priv static void
public static synchronized boolean
checkNativeLibs(final Uri jarUri, final TempJarCache.LoadState exp)

public static synchronized boolean
checkResources(final Uri jarUri, final TempJarCache.LoadState exp)

public static final synchronized String
findLibrary(final String libName)

public static final synchronized String
public static final synchronized URI
public static final synchronized Uri
public static TempFileCache
public static boolean

Returns:

true is static initialization was successful
initSingleton
()

Documented way to kick off static initialization.

public static boolean

Returns:

true if this class has been properly initialized, ie. is in use, otherwise false.
isInitialized
()

private static boolean
isInitializedImpl()

This is not recommended since the JNI libraries may still be in use by the ClassLoader they are loaded via System#load(String).

private static boolean
private static void
validateCertificates(final Class<?> certClass, final JarFile jarFile)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

classFileJarsback to summary
private static Map<Uri, TempJarCache.LoadState> classFileJars
DEBUGback to summary
private static final boolean DEBUG
isInitback to summary
private static volatile boolean isInit
nativeLibJarsback to summary
private static Map<Uri, TempJarCache.LoadState> nativeLibJars
nativeLibMapback to summary
private static Map<String, String> nativeLibMap
resourceFileJarsback to summary
private static Map<Uri, TempJarCache.LoadState> resourceFileJars
staticInitErrorback to summary
private static volatile boolean staticInitError
tmpFileCacheback to summary
private static TempFileCache tmpFileCache

Constructor Detail

TempJarCacheback to summary
public TempJarCache()

Method Detail

addAllback to summary
public static final synchronized void addAll(final Class<?> certClass, final 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:Class<?>

if class is certified, the JarFile entries needs to have the same certificate

Exceptions
IOException:
if the jarUri could not be loaded or a previous load attempt failed
addClassesback to summary
public static final synchronized void addClasses(final Class<?> certClass, final 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:Class<?>

if class is certified, the JarFile entries needs to have the same certificate

Exceptions
IOException:
if the jarUri could not be loaded or a previous load attempt failed
addNativeLibsback to summary
public static final synchronized boolean addNativeLibs(final Class<?> certClass, final Uri jarUri, final String nativeLibraryPath) throws IOException, SecurityException, IllegalArgumentException, URISyntaxException

Adds native libraries, if not yet added.

Parameters
certClass:Class<?>

if class is certified, the JarFile entries needs to have the same certificate

nativeLibraryPath:String

if not null, only extracts native libraries within this path.

Returns:boolean

true if native libraries were added or previously loaded from given jarUri, otherwise false

Exceptions
IOException:
if the jarUri could not be loaded or a previous load attempt failed
addResourcesback to summary
public static final synchronized void addResources(final Class<?> certClass, final URI jarURI) throws IOException, SecurityException, IllegalArgumentException, URISyntaxException

Deprecated

Use addResources(Class, Uri)

See addResources(Class, Uri)

addResourcesback to summary
public static final synchronized void addResources(final Class<?> certClass, final Uri jarUri) throws IOException, SecurityException, IllegalArgumentException, URISyntaxException

Adds native resources, if not yet added.

Parameters
certClass:Class<?>

if class is certified, the JarFile entries needs to have the same certificate

Exceptions
IOException:
if the jarUri could not be loaded or a previous load attempt failed
checkClassesback to summary
public static synchronized boolean checkClasses(final Uri jarUri, final TempJarCache.LoadState exp) throws IOException
checkInitializedback to summary
pack-priv static void checkInitialized()
checkNativeLibsback to summary
public static synchronized boolean checkNativeLibs(final Uri jarUri, final TempJarCache.LoadState exp) throws IOException
checkResourcesback to summary
public static synchronized boolean checkResources(final Uri jarUri, final TempJarCache.LoadState exp) throws IOException
findLibraryback to summary
public static final synchronized String findLibrary(final String libName)
findResourceback to summary
public static final synchronized String findResource(final String name)

Similar to ClassLoader#getResource(String).

getResourceback to summary
public static final synchronized URI getResource(final String name) throws URISyntaxException

Deprecated

Use getResourceUri(String)

See getResourceUri(String)

getResourceUriback to summary
public static final synchronized Uri getResourceUri(final String name) throws URISyntaxException

Similar to ClassLoader#getResource(String).

getTempFileCacheback to summary
public static TempFileCache getTempFileCache()
initSingletonback to summary
public static boolean initSingleton()

Documented way to kick off static initialization.

Returns:boolean

true is static initialization was successful

isInitializedback to summary
public static boolean isInitialized()
Returns:boolean

true if this class has been properly initialized, ie. is in use, otherwise false.

isInitializedImplback to summary
private static boolean isInitializedImpl()

This is not recommended since the JNI libraries may still be in use by the ClassLoader they are loaded via System#load(String).

In JogAmp, JNI native libraries loaded and registered by JNILibLoaderBase derivations, where the native JARs might be loaded via JNILibLoaderBase#addNativeJarLibs(Class, String).

The only valid use case to shutdown the TempJarCache is at bootstrapping, i.e. when no native library is guaranteed to be loaded. This could be useful if bootstrapping needs to find the proper native library type.

public static void shutdown() { if (isInit) { // volatile: ok synchronized (TempJarCache.class) { if (isInit) { if(DEBUG) { System.err.println("TempJarCache.shutdown(): real "+(false==staticInitError)+", "+ tmpFileCache.getTempDir()); } isInit = false; if(!staticInitError) { nativeLibMap.clear(); nativeLibMap = null; nativeLibJars.clear(); nativeLibJars = null; classFileJars.clear(); classFileJars = null; resourceFileJars.clear(); resourceFileJars = null; tmpFileCache.destroy(); tmpFileCache = null; } } } } }
testLoadStateback to summary
private static boolean testLoadState(final TempJarCache.LoadState has, final TempJarCache.LoadState exp)
validateCertificatesback to summary
private static void validateCertificates(final Class<?> certClass, final JarFile jarFile) throws IOException, SecurityException
com.jogamp.common.util.cache back to summary

public final Enum TempJarCache.LoadState

extends Enum<TempJarCache.LoadState>
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final TempJarCache.LoadState
public static final TempJarCache.LoadState

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public boolean
public static TempJarCache.LoadState
public static TempJarCache.LoadState[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

LOADEDback to summary
public static final TempJarCache.LoadState LOADED
LOOKED_UPback to summary
public static final TempJarCache.LoadState LOOKED_UP

Constructor Detail

LoadStateback to summary
private LoadState()

Method Detail

compliesWithback to summary
public boolean compliesWith(final TempJarCache.LoadState o2)
valueOfback to summary
public static TempJarCache.LoadState valueOf(String name)
valuesback to summary
public static TempJarCache.LoadState[] values()