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 of SessionKernel to be encapsulated by this wrapper
All Implemented Interfaces:
Lifecycle, 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. All SessionKernel methods in this class will proxy calls to the delegate session kernel.
  • Method Details

    • getSessionCollection

      public PerspectiveSessionCollection getSessionCollection()
      Specified by:
      getSessionCollection in interface InternalSession
      Specified by:
      getSessionCollection in interface SessionKernel
      Returns:
      the PerspectiveSessionCollection which contains the session
    • getProjectName

      public String getProjectName()
      Description copied from interface: Session
      The project that this session is running.
      Specified by:
      getProjectName in interface Session
      Specified by:
      getProjectName in interface SessionKernel
      Returns:
      the name of the project associated with the session
    • getGson

      public com.inductiveautomation.ignition.common.gson.Gson getGson()
      Specified by:
      getGson in interface SessionKernel
      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 interface Session
      Specified by:
      queue in interface SessionKernel
      Returns:
      the ExecutionQueue used to run session tasks in serial
    • getLogger

      public LoggerEx getLogger()
      Specified by:
      getLogger in interface LoggingContext
      Specified by:
      getLogger in interface SessionKernel
      Returns:
      the LoggerEx associated with the session
    • getEventBus

      public com.google.common.eventbus.EventBus getEventBus()
      Specified by:
      getEventBus in interface SessionKernel
    • getEventManager

      public EventManager getEventManager()
      Description copied from interface: Session
      An EventManager for events targeted to the running Perspective Project this session.
      Specified by:
      getEventManager in interface Session
      Specified by:
      getEventManager in interface SessionKernel
      Returns:
      the EventManager associated with the session
    • getSessionId

      public UUID getSessionId()
      Specified by:
      getSessionId in interface Session
      Specified by:
      getSessionId in interface SessionKernel
      Returns:
      the session's unique identifier
    • getStartupTime

      public long getStartupTime()
      Specified by:
      getStartupTime in interface SessionKernel
      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 interface SessionKernel
      Returns:
      the time in nanoseconds when the last message was received by the session containing this kernel
    • getSessionStats

      public SessionStats getSessionStats()
      Specified by:
      getSessionStats in interface Session
      Specified by:
      getSessionStats in interface SessionKernel
      Returns:
      An object containing various statistics that pertain to this session. Also useful for registering metrics that will automatically get removed when this session is shut down.
    • touch

      public void touch()
      Description copied from interface: SessionKernel
      Updates the last message time to the current time in nanoseconds
      Specified by:
      touch in interface SessionKernel
      See Also:
    • broadcast

      protected abstract void broadcast(String protocol, String payload)
      Broadcast a message to all pages associated with this session
      Parameters:
      protocol - the protocol of the message to broadcast
      payload - the payload of the message to broadcast
    • onStartup

      protected void onStartup()
      Specified by:
      onStartup in class AbstractLifecycle
    • onShutdown

      protected void onShutdown()
      Specified by:
      onShutdown in class AbstractLifecycle
    • onHello

      public void onHello()
      Description copied from interface: InternalSession
      Called every time the hello API is invoked on this session.
      Specified by:
      onHello in interface InternalSession
    • getSessionInfo

      public PerspectiveSessionInfo getSessionInfo()
      Specified by:
      getSessionInfo in interface InternalSession
      Returns:
      a report about this session
    • getUptime

      public long getUptime(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 interface InternalSession
      Parameters:
      timeUnit - the TimeUnit to which the internal startup time should be converted
      Returns:
      the up time in the given unit
    • getLastComm

      public long getLastComm(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 interface InternalSession
      Parameters:
      timeUnit - the TimeUnit to which the last communication time should be converted
      Returns:
      the last communication time in the given unit
    • getSessionClosedMessage

      public String getSessionClosedMessage()
      Specified by:
      getSessionClosedMessage in interface InternalSession
      Returns:
      the default message sent to the client when the session is closed
    • getPageClosedMessage

      public String getPageClosedMessage()
      Specified by:
      getPageClosedMessage in interface InternalSession
      Returns:
      the default message sent to the client then a page is closed
    • getLogoutMessage

      public String getLogoutMessage()
      Specified by:
      getLogoutMessage in interface InternalSession
      Returns:
      the default message sent to the client when the user logs out
    • getAuditSnapshot

      public @NonNull AuditContext.Builder getAuditSnapshot()
      Specified by:
      getAuditSnapshot in interface AuditingContext
      Returns:
      A new, or extended, AuditContext.Builder, with qualified information about the current scope.
    • createToken

      public String createToken(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 interface InternalSession
      Specified by:
      createToken in interface SessionKernel
      Returns:
      the new short-lived token
    • claimToken

      public Optional<com.inductiveautomation.ignition.common.gson.JsonElement> claimToken(String type, 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 interface InternalSession
      Specified by:
      claimToken in interface SessionKernel
      Parameters:
      token - the token to claim
      Returns:
      an Optional containing the JsonElement 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