Enum Class BrowserPageContext
- All Implemented Interfaces:
Serializable
,Comparable<BrowserPageContext>
,Constable
- Since:
- 2.0.0
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
-
Method Summary
Modifier and TypeMethodDescriptionaddBrowserPage
(String httpSessionId, BrowserPage browserPage) void
clean
(long maxIdleTimeout) If any object is idle for a time which is greater than or equal the givenmaxIdleTimeout
it will be removed from theBrowserPageContext
.void
destroyContext
(String httpSessionId) This should be called when the http session is closedvoid
void
enableAutoClean
(long maxIdleTimeout) Runs a periodic clean operation when idle time of objects likeBrowserPage
,HeartbeatManager
etc..void
enableAutoClean
(long maxIdleTimeout, Executor executor) Runs a periodic clean operation when idle time of objects likeBrowserPage
,HeartbeatManager
etc..boolean
exists
(BrowserPage browserPage) Checks the existence ofbrowserPage
in this context.boolean
existsAndValid
(BrowserPage browserPage) Checks the existence of validbrowserPage
in this context.getBrowserPage
(String instanceId) Gets the browserPage object for the given instance id.getBrowserPage
(String httpSessionId, String instanceId) getBrowserPageIfValid
(String instanceId) gets the browserPage object for the given instance id.getBrowserPageIfValid
(String httpSessionId, String instanceId) Gets the browserPage object for the given instance id.getBrowserPages
(String httpSessionId) Gets all browser pages associated with this session.getHeartbeatManagerForBrowserPage
(String wffInstanceId) getHeartbeatManagerForHttpSession
(String httpSessionId) void
httpSessionClosed
(String httpSessionId) should be called when the httpsession is closed.boolean
static boolean
void
removeBrowserPage
(String wffInstanceId) No need to call this method unless there is a special case like extending the functionality ofBrowserPageContext
instance.static void
setDebugMode
(boolean enabled) static BrowserPageContext
Returns the enum constant of this class with the specified name.static BrowserPageContext[]
values()
Returns an array containing the constants of this enum class, in the order they are declared.void
webSocketClosed
(String wffInstanceId) Deprecated.this method is for future developmentwebSocketClosed
(String wffInstanceId, String sessionId) this method should be called when the websocket is closed.websocketMessaged
(String wffInstanceId, byte[] message) Deprecated.use webSocketMessaged which does the same job.webSocketMessaged
(String wffInstanceId, byte[] message) this method should be called when the websocket is messaged.webSocketOpened
(String wffInstanceId) this method should be called when the websocket is openedwebSocketOpened
(String wffInstanceId, Function<String, HeartbeatManager> computeHeartbeatManager) this method should be called when the websocket is opened
-
Enum Constant Details
-
INSTANCE
-
-
Method Details
-
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
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 nameNullPointerException
- if the argument is null
-
addBrowserPage
- Parameters:
httpSessionId
-browserPage
-- Returns:
- the instance id (unique) of the browser page.
- Since:
- 2.0.0
-
getBrowserPage
- Parameters:
httpSessionId
-instanceId
-- Returns:
- Since:
- 2.0.0
-
getBrowserPageIfValid
Gets the browserPage object for the given instance id. It also checks if thebrowserPage
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 byenableAutoClean(long)
methods otherwisenull
. - Since:
- 3.0.16
-
getBrowserPage
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
gets the browserPage object for the given instance id. It also checks if thebrowserPage
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 byenableAutoClean(long)
methods otherwisenull
. - Since:
- 3.0.16
-
getBrowserPages
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
This should be called when the http session is closed- Parameters:
httpSessionId
- the session id of http session- Since:
- 2.0.0
-
webSocketOpened
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 connectioncomputeHeartbeatManager
- the function to computeHeartbeatManager
.- Returns:
- the
WebSocketOpenedRecord
object. It containsBrowserPage
object associated with thiswffInstanceId
andHeartbeatManager
associated with its http session id. If thewffInstanceId
is associated with a closed http session orwffInstanceId
is associated with theBrowserPage
is already removed from the context then this method will returnnull
. If this method returnsnull
, the givencomputeHeartbeatManager
will be ignored. - Since:
- 3.0.16
-
removeBrowserPage
No need to call this method unless there is a special case like extending the functionality ofBrowserPageContext
instance.- Parameters:
wffInstanceId
- the instance id ofBrowserPage
.- 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 givenmaxIdleTimeout
it will be removed from theBrowserPageContext
. Usually may not need to call this method directly because onceBrowserPageContext#startAutoClean
is called it is internally calling thisclean
method.- Parameters:
maxIdleTimeout
- the max idle time to remove the objects. It is usually equal to themaxIdleTimeout
of websocket session. It should be greater than the minInterval given in theHeartbeatManager
.- Since:
- 3.0.16
-
enableAutoClean
public void enableAutoClean(long maxIdleTimeout) Runs a periodic clean operation when idle time of objects likeBrowserPage
,HeartbeatManager
etc.. are greater than or equal to the givenmaxIdleTimeout
. 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 themaxIdleTimeout
of websocket session. It should be greater than the minInterval given in theHeartbeatManager
.- Since:
- 3.0.16
-
enableAutoClean
Runs a periodic clean operation when idle time of objects likeBrowserPage
,HeartbeatManager
etc.. are greater than or equal to the givenmaxIdleTimeout
. 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 themaxIdleTimeout
of websocket session. It should be greater than the minInterval given in theHeartbeatManager
.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
- Parameters:
httpSessionId
-- Returns:
- the
HeartbeatManager
associated with thishttpSessionId
ornull
if not available. If the last usage time ofHeartbeatManager
of this http session is greater than or equal tomaxIdleTimeout
given in theBrowserPageContext#enableAutoClean(long)
then this method will returnnull
. - Since:
- 3.0.16
-
getHeartbeatManagerForBrowserPage
- Parameters:
wffInstanceId
- the wffInstanceId ofBrowserPage
.- Returns:
- the
HeartbeatManager
associated with thishttpSessionId
ornull
if not available. If the last usage time ofHeartbeatManager
of this http session is greater than or equal tomaxIdleTimeout
given in theBrowserPageContext#enableAutoClean(long)
then this method will returnnull
. - Since:
- 3.0.16
-
webSocketClosed
Deprecated.this method is for future developmentthis 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
this method should be called when the websocket is closed.- Parameters:
wffInstanceId
- the wffInstanceId which can be retried from the request parameter in websocket connectionsessionId
- the websocket session id, i.e. the unique id of the websocket session which is given inBrowserPage#addWebSocketPushListener
method.- Returns:
- browserPage instance associated with this wffInstanceId
- Since:
- 2.1.0
-
httpSessionClosed
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.use webSocketMessaged which does the same job.This method is will be removed in the next version. UsewebSocketMessaged
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
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
Checks the existence ofbrowserPage
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
Checks the existence of validbrowserPage
in this context.
Note: this operation is not atomic. The validity is time dependent, even if the method returns truebrowserPage
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 byenableAutoClean(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
-