jdk/src/share/classes/sun/awt/AppContext.java

Print this page
rev 5709 : 6664509: Add logging context
6664528: Find log level matching its name or value given at construction time
Reviewed-by: alanb, ahgross, jgish, hawtin

@@ -325,25 +325,31 @@
 
         if (appContext == mainAppContext)  {
             // Before we return the main "system" AppContext, check to
             // see if there's an AWTSecurityManager installed.  If so,
             // allow it to choose the AppContext to return.
-            SecurityManager securityManager = System.getSecurityManager();
-            if ((securityManager != null) &&
-                (securityManager instanceof AWTSecurityManager))
-            {
-                AWTSecurityManager awtSecMgr = (AWTSecurityManager)securityManager;
-                AppContext secAppContext = awtSecMgr.getAppContext();
+            AppContext secAppContext = getExecutionAppContext();
                 if (secAppContext != null)  {
                     appContext = secAppContext; // Return what we're told
                 }
             }
-        }
 
         return appContext;
     }
 
+    private final static AppContext getExecutionAppContext() {
+        SecurityManager securityManager = System.getSecurityManager();
+        if ((securityManager != null) &&
+            (securityManager instanceof AWTSecurityManager))
+        {
+            AWTSecurityManager awtSecMgr = (AWTSecurityManager) securityManager;
+            AppContext secAppContext = awtSecMgr.getAppContext();
+            return secAppContext; // Return what we're told
+        }
+        return null;
+    }
+
     /**
      * Returns the main ("system") AppContext.
      *
      * @return  the main AppContext
      * @since   1.8

@@ -804,10 +810,25 @@
                 return getAppContext().isDisposed();
             }
             public boolean isMainAppContext() {
                 return (numAppContexts == 1);
             }
+            public Object getContext() {
+                return getAppContext();
+            }
+            public Object getExecutionContext() {
+                return getExecutionAppContext();
+            }
+            public Object get(Object context, Object key) {
+                return ((AppContext)context).get(key);
+            }
+            public void put(Object context, Object key, Object value) {
+                ((AppContext)context).put(key, value);
+            }
+            public void remove(Object context, Object key) {
+                ((AppContext)context).remove(key);
+            }
         });
     }
 }
 
 final class MostRecentKeyValue {