Enum Class BrowserPageContext

java.lang.Object
java.lang.Enum<BrowserPageContext>
com.webfirmframework.wffweb.server.page.BrowserPageContext
All Implemented Interfaces:
Serializable, Comparable<BrowserPageContext>, Constable

public enum BrowserPageContext extends Enum<BrowserPageContext>
Since:
2.0.0
  • Enum Constant Details

  • Method Details

    • values

      public static BrowserPageContext[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static BrowserPageContext valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • addBrowserPage

      public String addBrowserPage(String httpSessionId, BrowserPage browserPage)
      Parameters:
      httpSessionId -
      browserPage -
      Returns:
      the instance id (unique) of the browser page.
      Since:
      2.0.0
    • getBrowserPage

      public BrowserPage getBrowserPage(String httpSessionId, String instanceId)
      Parameters:
      httpSessionId -
      instanceId -
      Returns:
      Since:
      2.0.0
    • getBrowserPageIfValid

      public BrowserPage getBrowserPageIfValid(String httpSessionId, String instanceId)
      Gets the browserPage object for the given instance id. It also checks if the browserPage is valid. getBrowserPageIfValid(String, String) method is better than this method in terms of performance.
      Note: this operation is not atomic.
      Parameters:
      httpSessionId -
      instanceId -
      Returns:
      the browserPage object if exists and its internal idle time is not greater than or equal to the time set by enableAutoClean(long) methods otherwise null.
      Since:
      3.0.16
    • getBrowserPage

      public BrowserPage getBrowserPage(String instanceId)
      Gets the browserPage object for the given instance id. getBrowserPage(String, String) method is better than this method in terms of performance.
      Parameters:
      instanceId -
      Returns:
      browser page object if it exists otherwise null.
      Since:
      2.0.0
    • getBrowserPageIfValid

      public BrowserPage getBrowserPageIfValid(String instanceId)
      gets the browserPage object for the given instance id. It also checks if the browserPage is valid. getBrowserPageIfValid(String, String) method is better than this method in terms of performance.
      Note: this operation is not atomic.
      Parameters:
      instanceId -
      Returns:
      the browserPage object if exists and its internal idle time is not greater than or equal to the time set by enableAutoClean(long) methods otherwise null.
      Since:
      3.0.16
    • getBrowserPages

      public Map<String,BrowserPage> getBrowserPages(String httpSessionId)
      Gets all browser pages associated with this session.
      Parameters:
      httpSessionId -
      Returns:
      an unmodifiable map of BrowserPages associated with this session where key as instanceId and value as BrowserPage.
      Since:
      2.0.2
    • destroyContext

      public void destroyContext(String httpSessionId)
      This should be called when the http session is closed
      Parameters:
      httpSessionId - the session id of http session
      Since:
      2.0.0
    • webSocketOpened

      public BrowserPage webSocketOpened(String wffInstanceId)
      this method should be called when the websocket is opened
      Parameters:
      wffInstanceId - the wffInstanceId which can be retried from the request parameter in websocket connection
      Returns:
      the BrowserPage object associated with this instance id, if the instanceId is associated with a closed http session it will return null.
      Since:
      2.0.0
    • webSocketOpened

      public WebSocketOpenedRecord webSocketOpened(String wffInstanceId, Function<String,HeartbeatManager> computeHeartbeatManager)
      this method should be called when the websocket is opened
      Parameters:
      wffInstanceId - the wffInstanceId which can be retried from the request parameter in websocket connection
      computeHeartbeatManager - the function to compute HeartbeatManager.
      Returns:
      the WebSocketOpenedRecord object. It contains BrowserPage object associated with this wffInstanceId and HeartbeatManager associated with its http session id. If the wffInstanceId is associated with a closed http session or wffInstanceId is associated with the BrowserPage is already removed from the context then this method will return null. If this method returns null, the given computeHeartbeatManager will be ignored.
      Since:
      3.0.16
    • removeBrowserPage

      public void removeBrowserPage(String wffInstanceId)
      No need to call this method unless there is a special case like extending the functionality of BrowserPageContext instance.
      Parameters:
      wffInstanceId - the instance id of BrowserPage.
      Since:
      3.0.16
    • clean

      public void clean(long maxIdleTimeout)
      If any object is idle for a time which is greater than or equal the given maxIdleTimeout it will be removed from the BrowserPageContext. Usually may not need to call this method directly because once BrowserPageContext#startAutoClean is called it is internally calling this clean method.
      Parameters:
      maxIdleTimeout - the max idle time to remove the objects. It is usually equal to the maxIdleTimeout of websocket session. It should be greater than the minInterval given in the HeartbeatManager.
      Since:
      3.0.16
    • enableAutoClean

      public void enableAutoClean(long maxIdleTimeout)
      Runs a periodic clean operation when idle time of objects like BrowserPage, HeartbeatManager etc.. are greater than or equal to the given maxIdleTimeout. If it is started it will do the clean operation whenever appropriate, there is no fixed interval of time for this execution.
      Parameters:
      maxIdleTimeout - the max idle time in milliseconds to remove the objects. It is usually equal to the maxIdleTimeout of websocket session. It should be greater than the minInterval given in the HeartbeatManager.
      Since:
      3.0.16
    • enableAutoClean

      public void enableAutoClean(long maxIdleTimeout, Executor executor)
      Runs a periodic clean operation when idle time of objects like BrowserPage, HeartbeatManager etc.. are greater than or equal to the given maxIdleTimeout. If it is started it will do the clean operation whenever appropriate, there is no fixed interval of time for this execution.
      Parameters:
      maxIdleTimeout - the max idle time in milliseconds to remove the objects. It is usually equal to the maxIdleTimeout of websocket session. It should be greater than the minInterval given in the HeartbeatManager.
      executor - the executor object from which the thread will be obtained to run the clean process.
      Since:
      3.0.16, 3.0.18 bug fix
    • disableAutoClean

      public void disableAutoClean()
      Since:
      3.0.16
    • isAutoCleanEnabled

      public boolean isAutoCleanEnabled()
      Returns:
      true if the auto clean is enabled by enableAutoClean method.
      Since:
      3.0.16
    • getHeartbeatManagerForHttpSession

      public HeartbeatManager getHeartbeatManagerForHttpSession(String httpSessionId)
      Parameters:
      httpSessionId -
      Returns:
      the HeartbeatManager associated with this httpSessionId or null if not available. If the last usage time of HeartbeatManager of this http session is greater than or equal to maxIdleTimeout given in the BrowserPageContext#enableAutoClean(long) then this method will return null.
      Since:
      3.0.16
    • getHeartbeatManagerForBrowserPage

      public HeartbeatManager getHeartbeatManagerForBrowserPage(String wffInstanceId)
      Parameters:
      wffInstanceId - the wffInstanceId of BrowserPage.
      Returns:
      the HeartbeatManager associated with this httpSessionId or null if not available. If the last usage time of HeartbeatManager of this http session is greater than or equal to maxIdleTimeout given in the BrowserPageContext#enableAutoClean(long) then this method will return null.
      Since:
      3.0.16
    • webSocketClosed

      @Deprecated public void webSocketClosed(String wffInstanceId)
      Deprecated.
      this method is for future development
      this method should be called when the websocket is closed
      Parameters:
      wffInstanceId - the wffInstanceId which can be retried from the request parameter in websocket connection
      Since:
      2.0.0
    • webSocketClosed

      public BrowserPage webSocketClosed(String wffInstanceId, String sessionId)
      this method should be called when the websocket is closed.
      Parameters:
      wffInstanceId - the wffInstanceId which can be retried from the request parameter in websocket connection
      sessionId - the websocket session id, i.e. the unique id of the websocket session which is given in BrowserPage#addWebSocketPushListener method.
      Returns:
      browserPage instance associated with this wffInstanceId
      Since:
      2.1.0
    • httpSessionClosed

      public void httpSessionClosed(String httpSessionId)
      should be called when the httpsession is closed. The closed http session id should be passed as an argument.
      Parameters:
      httpSessionId -
      Since:
      2.0.0
    • websocketMessaged

      @Deprecated public BrowserPage websocketMessaged(String wffInstanceId, byte[] message)
      Deprecated.
      use webSocketMessaged which does the same job.
      This method is will be removed in the next version. Use webSocketMessaged method instead of this method.
      Parameters:
      wffInstanceId - the wffInstanceId which can be retried from the request parameter in websocket connection.
      message - the message received from websocket
      Since:
      2.0.0
    • webSocketMessaged

      public BrowserPage webSocketMessaged(String wffInstanceId, byte[] message)
      this method should be called when the websocket is messaged.
      Parameters:
      wffInstanceId - the wffInstanceId which can be retried from the request parameter in websocket connection.
      message - the message received from websocket
      Since:
      2.1.0
    • exists

      public boolean exists(BrowserPage browserPage) throws NullValueException
      Checks the existence of browserPage in this context.
      Parameters:
      browserPage -
      Returns:
      true if the given browserPage exists in the BrowserPageContext.
      Throws:
      NullValueException - if the given browserPage instance is null
      Since:
      2.1.13
    • existsAndValid

      public boolean existsAndValid(BrowserPage browserPage) throws NullValueException
      Checks the existence of valid browserPage in this context.
      Note: this operation is not atomic. The validity is time dependent, even if the method returns true browserPage could be invalid in the next moment. However, if it returns false it is trust worthy.
      Parameters:
      browserPage -
      Returns:
      true if the given browserPage exists in the BrowserPageContext and has not expired. The browserPage instance will be considered as invalid if the internal idle time of it is greater than or equal to the time set by enableAutoClean(long) methods.
      Throws:
      NullValueException - if the given browserPage instance is null
      Since:
      3.0.16
    • isDebugMode

      public static boolean isDebugMode()
      Returns:
      true if enabled otherwise false
      Since:
      3.0.18
    • setDebugMode

      public static void setDebugMode(boolean enabled)
      Parameters:
      enabled -
      Since:
      3.0.18