FileDocCategorySizeDatePackage
ContextStorage.javaAPI DocAndroid 1.5 API4635Wed May 06 22:41:54 BST 2009org.apache.harmony.awt

ContextStorage

public final class ContextStorage extends Object
author
Pavel Dolgov
version
$Revision$

Fields Summary
private static volatile boolean
multiContextMode
private volatile boolean
shutdownPending
private static final ContextStorage
globalContext
private Toolkit
toolkit
private ComponentInternals
componentInternals
private WTK
wtk
private GraphicsEnvironment
graphicsEnvironment
private final Object
contextLock
private final Synchronizer
synchronizer
Constructors Summary
Methods Summary
public static voidactivateMultiContextMode()


        
        // TODO: checkPermission
        multiContextMode = true;
    
public static ComponentInternalsgetComponentInternals()

        return getCurrentContext().componentInternals;
    
public static java.lang.ObjectgetContextLock()

        return getCurrentContext().contextLock;
    
private static ContextThreadGroupgetContextThreadGroup()


        Thread thread = Thread.currentThread();
        ThreadGroup group = thread.getThreadGroup();
        while (group != null) {
            if (group instanceof ContextThreadGroup) {
                return (ContextThreadGroup)group;
            }
            group = group.getParent();
        }
        // awt.59=Application has run out of context thread group
        throw new RuntimeException(Messages.getString("awt.59")); //$NON-NLS-1$
    
private static org.apache.harmony.awt.ContextStoragegetCurrentContext()

        return multiContextMode ? getContextThreadGroup().context : globalContext;
    
public static java.awt.ToolkitgetDefaultToolkit()

        return getCurrentContext().toolkit;
    
public static java.awt.GraphicsEnvironmentgetGraphicsEnvironment()

        return getCurrentContext().graphicsEnvironment;
    
public static NativeEventQueuegetNativeEventQueue()

        return getCurrentContext().wtk.getNativeEventQueue();
    
public static NativeIMgetNativeIM()

        return getCurrentContext().wtk.getNativeIM();
    
public static SynchronizergetSynchronizer()

        return getCurrentContext().synchronizer;
    
public static WindowFactorygetWindowFactory()

        return getCurrentContext().wtk.getWindowFactory();
    
static voidsetComponentInternals(ComponentInternals internals)

        // TODO: checkPermission
        getCurrentContext().componentInternals = internals;
    
public static voidsetDefaultToolkit(java.awt.Toolkit newToolkit)

        // TODO: checkPermission
        getCurrentContext().toolkit = newToolkit;
    
public static voidsetGraphicsEnvironment(java.awt.GraphicsEnvironment environment)

        getCurrentContext().graphicsEnvironment = environment;
    
public static voidsetWTK(WTK wtk)

        getCurrentContext().wtk = wtk;
    
voidshutdown()

        if (!multiContextMode) {
            return;
        }
        shutdownPending = true;

        //???AWT: componentInternals.shutdown();

        synchronized(contextLock) {
            toolkit = null;
            componentInternals = null;
            //???AWT: dtk = null;
            wtk = null;
            graphicsEnvironment = null;
        }
    
public static booleanshutdownPending()

        return getCurrentContext().shutdownPending;