diff options
author | Sven Gothel <[email protected]> | 2009-07-03 23:31:02 +0000 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2009-07-03 23:31:02 +0000 |
commit | 944a0ca587d20d193b9f8c7b5edbd0b0bd0d7666 (patch) | |
tree | 61473a7a57d71427ce8fdf927eefc74130e093bb /src/nativewindow | |
parent | 02ccc7939e2c542860f154e4f9063dbb1839a893 (diff) |
Fix property query. Thx to Ken pointing this out.
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/trunk@2018 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src/nativewindow')
-rw-r--r-- | src/nativewindow/classes/com/sun/nativewindow/impl/Debug.java | 71 | ||||
-rw-r--r-- | src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java | 9 |
2 files changed, 58 insertions, 22 deletions
diff --git a/src/nativewindow/classes/com/sun/nativewindow/impl/Debug.java b/src/nativewindow/classes/com/sun/nativewindow/impl/Debug.java index 7e7b81e8b..7b7785a7c 100644 --- a/src/nativewindow/classes/com/sun/nativewindow/impl/Debug.java +++ b/src/nativewindow/classes/com/sun/nativewindow/impl/Debug.java @@ -47,10 +47,12 @@ public class Debug { // Some common properties private static boolean verbose; private static boolean debugAll; + private static AccessControlContext localACC; static { - verbose = isPropertyDefined("nativewindow.verbose"); - debugAll = isPropertyDefined("nativewindow.debug"); + localACC=AccessController.getContext(); + verbose = isPropertyDefined("nativewindow.verbose", true); + debugAll = isPropertyDefined("nativewindow.debug", true); if (verbose) { Package p = Package.getPackage("javax.media.nativewindow"); System.err.println("NativeWindow specification version " + p.getSpecificationVersion()); @@ -59,34 +61,67 @@ public class Debug { } } - public static int getIntProperty(final String property, final boolean jnlpAlias) { + protected static int getIntProperty(final String property, final boolean jnlpAlias) { + return getIntProperty(property, jnlpAlias, localACC); + } + + public static int getIntProperty(final String property, final boolean jnlpAlias, final AccessControlContext acc) { int i=0; try { - Integer iv = Integer.valueOf(Debug.getProperty(property, jnlpAlias)); + Integer iv = Integer.valueOf(Debug.getProperty(property, jnlpAlias, acc)); i = iv.intValue(); } catch (NumberFormatException nfe) {} return i; } - public static boolean getBooleanProperty(final String property, final boolean jnlpAlias) { - Boolean b = Boolean.valueOf(Debug.getProperty(property, jnlpAlias)); + protected static boolean getBooleanProperty(final String property, final boolean jnlpAlias) { + return getBooleanProperty(property, jnlpAlias, localACC); + } + + public static boolean getBooleanProperty(final String property, final boolean jnlpAlias, final AccessControlContext acc) { + Boolean b = Boolean.valueOf(Debug.getProperty(property, jnlpAlias, acc)); return b.booleanValue(); } - public static boolean isPropertyDefined(final String property) { - return (Debug.getProperty(property, true) != null) ? true : false; + protected static boolean isPropertyDefined(final String property, final boolean jnlpAlias) { + return isPropertyDefined(property, jnlpAlias, localACC); } - public static String getProperty(final String property, final boolean jnlpAlias) { - String s = (String) AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { - String val = System.getProperty(property); - if(null==val && jnlpAlias && !property.startsWith(jnlp_prefix)) { - val = System.getProperty(jnlp_prefix + property); - } - return val; + public static boolean isPropertyDefined(final String property, final boolean jnlpAlias, final AccessControlContext acc) { + return (Debug.getProperty(property, jnlpAlias, acc) != null) ? true : false; + } + + protected static String getProperty(final String property, final boolean jnlpAlias) { + return getProperty(property, jnlpAlias, localACC); + } + + public static String getProperty(final String property, final boolean jnlpAlias, final AccessControlContext acc) { + String s=null; + if(null!=acc && acc.equals(localACC)) { + s = (String) AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + String val=null; + try { + val = System.getProperty(property); + } catch (Exception e) {} + if(null==val && jnlpAlias && !property.startsWith(jnlp_prefix)) { + try { + val = System.getProperty(jnlp_prefix + property); + } catch (Exception e) {} + } + return val; + } + }); + } else { + try { + s = System.getProperty(property); + } catch (Exception e) {} + if(null==s && jnlpAlias && !property.startsWith(jnlp_prefix)) { + try { + s = System.getProperty(jnlp_prefix + property); + } catch (Exception e) {} } - }); + } return s; } public static final String jnlp_prefix = "jnlp." ; @@ -100,6 +135,6 @@ public class Debug { } public static boolean debug(String subcomponent) { - return debugAll() || isPropertyDefined("nativewindow.debug." + subcomponent); + return debugAll() || isPropertyDefined("nativewindow.debug." + subcomponent, true); } } diff --git a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java index 4f1323ff8..eb0c25aed 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java +++ b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java @@ -98,8 +98,9 @@ public abstract class NativeWindowFactory { JVMUtil.initSingleton(); // Gather the windowing OS first - nativeOSNamePure = Debug.getProperty("os.name", false); - nativeOSNameCustom = Debug.getProperty("nativewindow.ws.name", true); + AccessControlContext acc = AccessController.getContext(); + nativeOSNamePure = Debug.getProperty("os.name", false, acc); + nativeOSNameCustom = Debug.getProperty("nativewindow.ws.name", true, acc); if(null==nativeOSNameCustom||nativeOSNameCustom.length()==0) { nativeOSNameCustom = nativeOSNamePure; } @@ -127,8 +128,8 @@ public abstract class NativeWindowFactory { } catch (Exception e) { } } - boolean toolkitLockForced = Debug.getBooleanProperty("nativewindow.locking", true); - boolean awtToolkitLockDisabled = Debug.getBooleanProperty("java.awt.headless", false); + boolean toolkitLockForced = Debug.getBooleanProperty("nativewindow.locking", true, acc); + boolean awtToolkitLockDisabled = Debug.getBooleanProperty("java.awt.headless", false, acc); NativeWindowFactory _factory = null; |