diff options
author | Sven Gothel <[email protected]> | 2012-03-26 15:16:34 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2012-03-26 15:16:34 +0200 |
commit | e9e61421ef6009e6788998c471d1d3d30aaefea6 (patch) | |
tree | 4f27d46398b5c00f5d27985308f1e2b86dcf7fdb /src/java/com/jogamp/common/os | |
parent | e2abb9583faf4b3dac6094fcd311475777528b8e (diff) |
Platform: Add AWT_AVAILABLE 'knowledge'; RunnableExecutor: Add AWTEDT impl. / API doc cleanup; DynamicLibraryBundle: Add getDefaultRunnableExecutor()
Diffstat (limited to 'src/java/com/jogamp/common/os')
-rwxr-xr-x | src/java/com/jogamp/common/os/DynamicLibraryBundle.java | 12 | ||||
-rw-r--r-- | src/java/com/jogamp/common/os/DynamicLibraryBundleInfo.java | 11 | ||||
-rw-r--r-- | src/java/com/jogamp/common/os/Platform.java | 17 |
3 files changed, 40 insertions, 0 deletions
diff --git a/src/java/com/jogamp/common/os/DynamicLibraryBundle.java b/src/java/com/jogamp/common/os/DynamicLibraryBundle.java index efb6d89..b86a701 100755 --- a/src/java/com/jogamp/common/os/DynamicLibraryBundle.java +++ b/src/java/com/jogamp/common/os/DynamicLibraryBundle.java @@ -33,7 +33,10 @@ import java.util.Arrays; import java.util.HashSet; import java.util.List; +import jogamp.common.awt.AWTEDTExecutor; + import com.jogamp.common.jvm.JNILibLoaderBase; +import com.jogamp.common.util.RunnableExecutor; /** * Provides bundling of:<br> @@ -69,6 +72,15 @@ public class DynamicLibraryBundle implements DynamicLookupHelper { private HashSet<String> toolGetProcAddressFuncNameSet; private List<String> toolGetProcAddressFuncNameList; + /** Returns an AWT-EDT {@link RunnableExecutor} implementation if AWT is available, otherwise {@link RunnableExecutor#currentThreadExecutor}. */ + public static RunnableExecutor getDefaultRunnableExecutor() { + if(Platform.AWT_AVAILABLE) { + return AWTEDTExecutor.singleton; + } else { + return RunnableExecutor.currentThreadExecutor; + } + } + /** Instantiates and loads all {@link NativeLibrary}s incl. JNI libraries. */ public DynamicLibraryBundle(DynamicLibraryBundleInfo info) { if(null==info) { diff --git a/src/java/com/jogamp/common/os/DynamicLibraryBundleInfo.java b/src/java/com/jogamp/common/os/DynamicLibraryBundleInfo.java index 6178048..8532548 100644 --- a/src/java/com/jogamp/common/os/DynamicLibraryBundleInfo.java +++ b/src/java/com/jogamp/common/os/DynamicLibraryBundleInfo.java @@ -86,6 +86,17 @@ public interface DynamicLibraryBundleInfo { /** @return true if the dynamic symbol lookup shall happen system wide, over all loaded libraries. Otherwise only the loaded native libraries are used for lookup, which shall be the default. */ public boolean shallLookupGlobal(); + /** + * Returns a suitable {@link RunnableExecutor} implementation, which is being used + * to load the <code>tool</code> native libraries. + * <p> + * This allows the generic {@link DynamicLibraryBundle} implementation to + * load the <code>tool</code> native libraries on a designated thread. + * </p> + * <p> + * An implementation may return {@link DynamicLibraryBundle#getDefaultRunnableExecutor()}. + * </p> + */ public RunnableExecutor getLibLoaderExecutor(); } diff --git a/src/java/com/jogamp/common/os/Platform.java b/src/java/com/jogamp/common/os/Platform.java index dc1ce91..6553b07 100644 --- a/src/java/com/jogamp/common/os/Platform.java +++ b/src/java/com/jogamp/common/os/Platform.java @@ -38,6 +38,7 @@ import java.util.concurrent.TimeUnit; import com.jogamp.common.nio.Buffers; import com.jogamp.common.util.JarUtil; +import com.jogamp.common.util.ReflectionUtil; import com.jogamp.common.util.VersionNumber; import com.jogamp.common.util.cache.TempJarCache; @@ -61,6 +62,9 @@ public class Platform { public static final boolean USE_TEMP_JAR_CACHE; private static final String useTempJarCachePropName = "jogamp.gluegen.UseTempJarCache"; + /** <code>true</code> if AWT is available and not in headless mode, otherwise <code>false</code>. */ + public static final boolean AWT_AVAILABLE; + public static final boolean JAVA_SE; public static final boolean LITTLE_ENDIAN; public static final String OS; @@ -225,6 +229,19 @@ public class Platform { } machineDescription = md; is32Bit = machineDescription.is32Bit(); + + { + final ClassLoader cl = Platform.class.getClassLoader(); + boolean _AWT_AVAILABLE = false; + if( !Debug.getBooleanProperty("java.awt.headless", true) && + ReflectionUtil.isClassAvailable(ReflectionUtil.AWTNames.ComponentClass, cl) && + ReflectionUtil.isClassAvailable(ReflectionUtil.AWTNames.GraphicsEnvironmentClass, cl) ) { + try { + _AWT_AVAILABLE = false == ((Boolean)ReflectionUtil.callStaticMethod(ReflectionUtil.AWTNames.GraphicsEnvironmentClass, ReflectionUtil.AWTNames.isHeadlessMethod, null, null, cl)).booleanValue(); + } catch (Throwable t) { } + } + AWT_AVAILABLE = _AWT_AVAILABLE; + } } private Platform() {} |