Class AppContextInfo


  • public class AppContextInfo
    extends Object
    Instance of this class holds information about a ThreadGroup associated AppContext.

    Non intrusive workaround for Bug 983 and Bug 1004, see getCachedThreadGroup().

    • Constructor Detail

      • AppContextInfo

        public AppContextInfo​(String info)
    • Method Detail

      • isValid

        public final boolean isValid()
        Returns true if this instance has valid AppContext information, i.e. getCachedThreadGroup() returns not null.
      • getCachedThreadGroup

        public final ThreadGroup getCachedThreadGroup()
        Returns the ThreadGroup belonging to the last known AppContext as queried via update(String).

        Returns null if no AppContext has been queried.

        The returned ThreadGroup allows users to create a custom thread belonging to it and hence mitigating Bug 983 and Bug 1004.

        update(String) should be called from a thread belonging to the desired AppContext, i.e. early from within the special threaded application.

        E.g. JAWTWindow issues update(String) in it's constructor.

      • invokeOnAppContextThread

        public RunnableTask invokeOnAppContextThread​(boolean waitUntilDone,
                                                     Runnable runnable,
                                                     String threadBaseName)
        Invokes runnable on a Thread belonging to the AppContext ThreadGroup, see getCachedThreadGroup().

        update(String) is issued first, which returns true if the current thread belongs to an AppContext ThreadGroup. In this case the runnable is invoked on the current thread, otherwise a new Thread will be started.

        If a new Thread is required, the AppContext ThreadGroup is being used if available, otherwise the default system ThreadGroup.

        Parameters:
        waitUntilDone - if true, waits until runnable execution is completed, otherwise returns immediately.
        runnable - the Runnable to be executed. If waitUntilDone is true, the runnable must exist, i.e. not loop forever.
        threadBaseName - the base name for the new thread if required. The resulting thread name will have either '-OnAppContextTG' or '-OnSystemTG' appended
        Returns:
        the Thread used to invoke the runnable, which may be the current Thread or a newly created one, see above.
      • update

        public final boolean update​(String info)
        Update AppContext information for the current ThreadGroup if uninitialized or AppContext changed.

        See getCachedThreadGroup() for usage.

        Parameters:
        info - informal string for logging purposes
        Returns:
        true if the current ThreadGroup is mapped to an AppContext and the information is good, otherwise false.