Class SessionKernelWrapper<T extends SessionKernel>
- java.lang.Object
-
- com.inductiveautomation.ignition.common.lifecycle.AbstractLifecycle
-
- com.inductiveautomation.perspective.gateway.session.SessionKernelWrapper<T>
-
- Type Parameters:
T
- the type ofSessionKernel
to be encapsulated by this wrapper
- All Implemented Interfaces:
AuditingContext
,LoggingContext
,PerspectiveElement
,PropertyTreeOwner
,Session
,InternalSession
,SessionKernel
- Direct Known Subclasses:
AbstractSession
,SecuredPerspectiveProjectSession
public abstract class SessionKernelWrapper<T extends SessionKernel> extends AbstractLifecycle implements SessionKernel, InternalSession
Base class for Perspective Sessions which wrap a session kernel. AllSessionKernel
methods in this class will proxy calls to the delegate session kernel.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.inductiveautomation.perspective.gateway.session.InternalSession
InternalSession.PageVisitor
-
Nested classes/interfaces inherited from interface com.inductiveautomation.perspective.gateway.api.Session
Session.WebAuthStatusChangeEvent
-
-
Field Summary
-
Fields inherited from interface com.inductiveautomation.perspective.gateway.session.InternalSession
SESSION
-
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract void
broadcast(java.lang.String protocol, java.lang.String payload)
Broadcast a message to all pages associated with this sessionjava.util.Optional<com.inductiveautomation.ignition.common.gson.JsonElement>
claimToken(java.lang.String type, java.lang.String token)
Claim the given token associated with the given data type previously created by this session kernel.java.lang.String
createToken(java.lang.String type, com.inductiveautomation.ignition.common.gson.JsonElement data)
Create a new token associated with the given type and data for the this session kernel.AuditContext.Builder
getAuditSnapshot()
com.google.common.eventbus.EventBus
getEventBus()
AnEventBus
for events targeted to the running Perspective Project this session.com.inductiveautomation.ignition.common.gson.Gson
getGson()
long
getLastComm(java.util.concurrent.TimeUnit timeUnit)
Return the time in the given time unit when the last communication was received from the clientlong
getLastMessageTime()
LoggerEx
getLogger()
java.lang.String
getLogoutMessage()
java.lang.String
getPageClosedMessage()
java.lang.String
getProjectName()
The project that this session is running.java.lang.String
getSessionClosedMessage()
PerspectiveSessionCollection
getSessionCollection()
java.util.UUID
getSessionId()
PerspectiveSessionInfo
getSessionInfo()
long
getStartupTime()
long
getUptime(java.util.concurrent.TimeUnit timeUnit)
Return the amount of time elapsed in the given time unit since the session started up.void
onHello()
Called every time the hello API is invoked on this session.protected void
onShutdown()
protected void
onStartup()
ExecutionQueue
queue()
Queue upon which all work for components and their properties should occur onvoid
touch()
Updates the last message time to the current time in nanoseconds-
Methods inherited from class com.inductiveautomation.ignition.common.lifecycle.AbstractLifecycle
isRunning, shutdown, startup
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.inductiveautomation.perspective.gateway.api.AuditingContext
audit
-
Methods inherited from interface com.inductiveautomation.perspective.gateway.session.InternalSession
close, closePage, closePage, destroySession, findPage, getLocale, getOrCreatePage, getPages, getPerspectiveContext, getProject, getTimeZone, getTimeZoneId, isRunning, logout, notifyConnected, notifyDisconnected, onKeepaliveReceived, onLoginResponse, onLogoutResponse, onSessionInit, receive, scope, shutdown, startup, updateSessionProps, visitPage
-
Methods inherited from interface com.inductiveautomation.perspective.gateway.api.LoggingContext
mdc, mdcSetupTree, mdcTeardownTree, mdcWrap
-
Methods inherited from interface com.inductiveautomation.perspective.gateway.api.PerspectiveElement
createPropertyReference, getAuditProfile, getQualifiedPath
-
Methods inherited from interface com.inductiveautomation.perspective.gateway.api.PropertyTreeOwner
getPropertyTreeOf
-
Methods inherited from interface com.inductiveautomation.perspective.gateway.api.Session
createViewModel, findViewConfig, getGatewayContext, getMdcParent, getName, getNamedQueryManager, getPage, getPageTimeout, getScriptManager, getSession, getTagHistoryManager, getTagManager, getView, getWebAuthStatus, mdcSetup, mdcTeardown, refreshBinding, sendErrorToDesigner
-
Methods inherited from interface com.inductiveautomation.perspective.gateway.session.SessionKernel
shutdown, startup
-
-
-
-
Method Detail
-
getSessionCollection
public PerspectiveSessionCollection getSessionCollection()
- Specified by:
getSessionCollection
in interfaceInternalSession
- Specified by:
getSessionCollection
in interfaceSessionKernel
- Returns:
- the
PerspectiveSessionCollection
which contains the session
-
getProjectName
public java.lang.String getProjectName()
Description copied from interface:Session
The project that this session is running.- Specified by:
getProjectName
in interfaceSession
- Specified by:
getProjectName
in interfaceSessionKernel
- Returns:
- the name of the project associated with the session
-
getGson
public com.inductiveautomation.ignition.common.gson.Gson getGson()
- Specified by:
getGson
in interfaceSessionKernel
- Returns:
- a
Gson
instance for json serialization / de-serialization
-
queue
public ExecutionQueue queue()
Description copied from interface:Session
Queue upon which all work for components and their properties should occur on- Specified by:
queue
in interfaceSession
- Specified by:
queue
in interfaceSessionKernel
- Returns:
- the
ExecutionQueue
used to run session tasks in serial
-
getLogger
public LoggerEx getLogger()
- Specified by:
getLogger
in interfaceLoggingContext
- Specified by:
getLogger
in interfaceSessionKernel
- Returns:
- the
LoggerEx
associated with the session
-
getEventBus
public com.google.common.eventbus.EventBus getEventBus()
Description copied from interface:Session
AnEventBus
for events targeted to the running Perspective Project this session.- Specified by:
getEventBus
in interfaceSession
- Specified by:
getEventBus
in interfaceSessionKernel
- Returns:
- the
EventBus
associated with the session
-
getSessionId
public java.util.UUID getSessionId()
- Specified by:
getSessionId
in interfaceSession
- Specified by:
getSessionId
in interfaceSessionKernel
- Returns:
- the session's unique identifier
-
getStartupTime
public long getStartupTime()
- Specified by:
getStartupTime
in interfaceSessionKernel
- Returns:
- the time in nanoseconds when the session kernel started (or 0 if the session kernel has not yet been started)
-
getLastMessageTime
public long getLastMessageTime()
- Specified by:
getLastMessageTime
in interfaceSessionKernel
- Returns:
- the time in nanoseconds when the last message was received by the session containing this kernel
-
touch
public void touch()
Description copied from interface:SessionKernel
Updates the last message time to the current time in nanoseconds- Specified by:
touch
in interfaceSessionKernel
- See Also:
System.nanoTime()
-
broadcast
protected abstract void broadcast(java.lang.String protocol, java.lang.String payload)
Broadcast a message to all pages associated with this session- Parameters:
protocol
- the protocol of the message to broadcastpayload
- the payload of the message to broadcast
-
onStartup
protected void onStartup()
- Specified by:
onStartup
in classAbstractLifecycle
-
onShutdown
protected void onShutdown()
- Specified by:
onShutdown
in classAbstractLifecycle
-
onHello
public void onHello()
Description copied from interface:InternalSession
Called every time the hello API is invoked on this session.- Specified by:
onHello
in interfaceInternalSession
-
getSessionInfo
public PerspectiveSessionInfo getSessionInfo()
- Specified by:
getSessionInfo
in interfaceInternalSession
- Returns:
- a report about this session
-
getUptime
public long getUptime(java.util.concurrent.TimeUnit timeUnit)
Description copied from interface:InternalSession
Return the amount of time elapsed in the given time unit since the session started up.- Specified by:
getUptime
in interfaceInternalSession
- Parameters:
timeUnit
- theTimeUnit
to which the internal startup time should be converted- Returns:
- the up time in the given unit
-
getLastComm
public long getLastComm(java.util.concurrent.TimeUnit timeUnit)
Description copied from interface:InternalSession
Return the time in the given time unit when the last communication was received from the client- Specified by:
getLastComm
in interfaceInternalSession
- Parameters:
timeUnit
- theTimeUnit
to which the last communication time should be converted- Returns:
- the last communication time in the given unit
-
getSessionClosedMessage
public java.lang.String getSessionClosedMessage()
- Specified by:
getSessionClosedMessage
in interfaceInternalSession
- Returns:
- the default message sent to the client when the session is closed
-
getPageClosedMessage
public java.lang.String getPageClosedMessage()
- Specified by:
getPageClosedMessage
in interfaceInternalSession
- Returns:
- the default message sent to the client then a page is closed
-
getLogoutMessage
public java.lang.String getLogoutMessage()
- Specified by:
getLogoutMessage
in interfaceInternalSession
- Returns:
- the default message sent to the client when the user logs out
-
getAuditSnapshot
@Nonnull public AuditContext.Builder getAuditSnapshot()
- Specified by:
getAuditSnapshot
in interfaceAuditingContext
- Returns:
- A new, or extended,
AuditContext.Builder
, with qualified information about the current scope.
-
createToken
public java.lang.String createToken(java.lang.String type, com.inductiveautomation.ignition.common.gson.JsonElement data)
Description copied from interface:SessionKernel
Create a new token associated with the given type and data for the this session kernel. The token expires in 30 seconds.- Specified by:
createToken
in interfaceInternalSession
- Specified by:
createToken
in interfaceSessionKernel
- Returns:
- the new short-lived token
-
claimToken
public java.util.Optional<com.inductiveautomation.ignition.common.gson.JsonElement> claimToken(java.lang.String type, java.lang.String token)
Description copied from interface:SessionKernel
Claim the given token associated with the given data type previously created by this session kernel.- Specified by:
claimToken
in interfaceInternalSession
- Specified by:
claimToken
in interfaceSessionKernel
token
- the token to claim- Returns:
- an
Optional
containing theJsonElement
data associated with the given data type and token, or an empty Optional if no data exists for the given data type and token pair
-
-