home *** CD-ROM | disk | FTP | other *** search
- package com.sun.java.swing;
-
- import java.util.Hashtable;
-
- final class AppContext {
- private static Hashtable security2appContexts = new Hashtable(2);
- private static Object nullSecurityContext = new Object();
- private final Hashtable table = new Hashtable(2);
-
- private AppContext(Object securityContext) {
- security2appContexts.put(securityContext, this);
- }
-
- public Object get(Object key) {
- return this.table.get(key);
- }
-
- public static AppContext getAppContext() {
- Object securityContext = nullSecurityContext;
- AppContext appContext = (AppContext)security2appContexts.get(securityContext);
- if (appContext == null) {
- appContext = new AppContext(securityContext);
- security2appContexts.put(securityContext, appContext);
- }
-
- return appContext;
- }
-
- public Object put(Object key, Object value) {
- return this.table.put(key, value);
- }
-
- public Object remove(Object key) {
- return this.table.remove(key);
- }
-
- public String toString() {
- Object securityContext = nullSecurityContext;
- SecurityManager sm = System.getSecurityManager();
- if (sm != null) {
- Object context = System.getSecurityManager().getSecurityContext();
- if (context != null) {
- securityContext = context;
- }
- }
-
- String contextName = securityContext.equals(nullSecurityContext) ? "null" : securityContext.toString();
- return this.getClass().getName() + "[SecurityContext=" + contextName + "]";
- }
- }
-