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/classes/com | |
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/classes/com')
-rw-r--r-- | src/nativewindow/classes/com/sun/nativewindow/impl/Debug.java | 71 |
1 files changed, 53 insertions, 18 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); } } |