Package sc.obj

Class CurrentScopeContext

  • public class CurrentScopeContext
    extends java.lang.Object
    Used to define, save and restore the list of scope contexts used in a given operation. For 'crossScope' data binding expressions, we capture the CurrentScopeContext when the binding is created, so we can restore it later to communicate in the context necessary for that binding. Or more specifically, if an event occurs, which is queued to a different context, the data-binding operations will temporarily restore the CurrentScopeContext before firing the binding so it has access to necessary state and locks required to fire. For example, when an object in session scope receives events from a global object in a context, like a JavaModel changed and we want to update the sessions that are viewing that JavaModel. That binding is marked with @Bindable(crossScope=true) and we know to queue the binding and save/restore the context before applying the change. Another use case is for allowing the command-line interpreter to control a specific browser window session. When it opens the window, it adds the scopeContextName query param which signals the PageDispatcher to get the current scope context and register it with a 'scopeContextName'. There are methods here which let the command line interpreter wait for the CurrentScopeContext to be 'ready' which basically means the client is waiting for commands. At that point, we continue the test-script and use that CurrentScopeContext to override the default scope lookup. We can target commands to a specific scope within the CurrentScopeContext using the getScopeContext/ByName methods. So for a test script, when we invoke a command we make sure it goes to the intended window in a multi-window test.
    • Field Detail

      • scopeContexts

        public java.util.List<ScopeContext> scopeContexts
      • scopeContextName

        public java.lang.String scopeContextName
      • traceInfo

        public java.lang.String traceInfo
    • Constructor Detail

      • CurrentScopeContext

        public CurrentScopeContext​(java.util.List<ScopeContext> scopeContexts,
                                   java.util.List<java.lang.Object> locks)
    • Method Detail

      • getScopeContext

        public ScopeContext getScopeContext​(int scopeId)
      • getScopeContextByName

        public ScopeContext getScopeContextByName​(java.lang.String scopeName)
        Returns a specific ScopeContext from this CurrentScopeContext - perhaps the "window" scope to use for an DynUtil.invokeRemote call.
      • startScopeContext

        public void startScopeContext​(boolean acquireLocks)
      • pushCurrentScopeContext

        public static void pushCurrentScopeContext​(CurrentScopeContext state,
                                                   boolean acquireLocks)
        Call this to temporarily restore a CurrentScopeContext retrieved from getCurrentScopeContext. You must call popScopeContext in a finally clause after you've called this method.
      • popCurrentScopeContext

        public static void popCurrentScopeContext​(boolean releaseLocks)
      • getCurrentScopeContext

        public static CurrentScopeContext getCurrentScopeContext()
        Call this to retrieve the current set of scope contexts that are available to your object. For methods that may be called from a different scope environment, you can then use the returned CurrentScopeContext to run code again in the context of that original code from the scope perspective.
      • getThreadScopeContext

        public static CurrentScopeContext getThreadScopeContext()
        Returns the currently pushed CurrentScopeContext (or null if there is not one present)
      • register

        public static CurrentScopeContext register​(java.lang.String scopeContextName,
                                                   CurrentScopeContext ctx)
        Register the CurrentScopeContext - so you can target a specific ScopeContext later via remoteMethod calls (e.g. using cmd.scopeContextName or to find the ScopeContext param to DynUtil.invokeRemote. So far, this is only used in debug mode to make test scripts more flexible in being able to deal with multi-browser window applications.
      • remove

        public static boolean remove​(java.lang.String scopeContextName)
      • waitForCreate

        public static CurrentScopeContext waitForCreate​(java.lang.String scopeContextName,
                                                        long timeout)
      • waitForReady

        public static CurrentScopeContext waitForReady​(java.lang.String scopeContextName,
                                                       long timeout)
      • markReady

        public static void markReady​(java.lang.String scopeContextName,
                                     boolean val)
      • closeScopeContext

        public static void closeScopeContext​(java.lang.String scopeContextName)
      • scopeChanged

        public void scopeChanged()
        Wake up anyone listening for changes to the event context in this current scope context
      • markWaiting

        public void markWaiting​(boolean val)
      • getTraceInfo

        public java.lang.String getTraceInfo()
      • setTraceInfo

        public void setTraceInfo​(java.lang.String info)
      • acquireLocks

        public void acquireLocks()
      • releaseLocks

        public void releaseLocks()
      • toString

        public java.lang.String toString()
        toString in class java.lang.Object
      • getEventScopeContext

        public ScopeContext getEventScopeContext()
      • getSingletonForType

        public java.lang.Object getSingletonForType​(java.lang.Object typeObj)
        If there is a singleton instance for this type, return it, otherwise not. Since we frequently use singletons this method helps diagnostics like the command interpreter where you want to select an instance by it being the only one of it's type for a specific scope context For example, use HtmlPage { } to select whatever page instance is available if there's only one.
      • addSyncTypeToFilter

        public void addSyncTypeToFilter​(java.lang.String typeName,
                                        java.lang.String reason)