io.vertx.ext.web.sstore

## Class AbstractSession

- java.lang.Object
- - io.vertx.ext.web.sstore.AbstractSession

- All Implemented Interfaces:
    Session

      public abstract class AbstractSession
      extends Object
      implements Session

  The abstract session class provides a barebones implementation for session storage implementors. This class will contain all the related data required for a session plus a couple of helper methods to verify the integrity and versioning of the data. This checksum is important to reduce the amount of times data is pushed to be stored on a backend. As a Vert.x Web user, you should not have to deal with this class directly but with the public interface that it implements.
  Author:
    Paulo Lopes

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `AbstractSession()` This constructor is mandatory (even though not referenced anywhere) is required for serialization purposes.
    `AbstractSession(VertxContextPRNG random)`
    `AbstractSession(VertxContextPRNG random, long timeout, int length)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected int` | `checksum()`
    `protected int` | `crc()`
    `Map<String,Object>` | `data()`
    `void` | `destroy()` Destroy the session
    `<T> T` | `get(String key)` Get some data from the session
    `String` | `id()`
    `void` | `incrementVersion()`
    `boolean` | `isDestroyed()`
    `boolean` | `isEmpty()`
    `boolean` | `isRegenerated()`
    `long` | `lastAccessed()`
    `String` | `oldId()`
    `Session` | `put(String key, Object obj)` Put some data in a session
    `Session` | `regenerateId()`
    `<T> T` | `remove(String key)` Remove some data from the session
    `void` | `setAccessed()` Mark the session as being accessed.
    `protected void` | `setData(JsonObject data)`
    `protected void` | `setData(Map<String,Object> data)`
    `protected void` | `setId(String id)`
    `protected void` | `setLastAccessed(long lastAccessed)`
    `void` | `setPRNG(VertxContextPRNG prng)`
    `protected void` | `setTimeout(long timeout)`
    `protected void` | `setVersion(int version)`
    `long` | `timeout()`
    `int` | `version()`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface io.vertx.ext.web.Session

      `value`

- - ### Constructor Detail

    - #### AbstractSession

          public AbstractSession()

      This constructor is mandatory (even though not referenced anywhere) is required for serialization purposes. Do not remove. It is required as part of the contract of the ClusterSerializable interface which some implementations might require.

    - #### AbstractSession

          public AbstractSession(VertxContextPRNG random)

    - #### AbstractSession

          public AbstractSession(VertxContextPRNG random,
                                 long timeout,
                                 int length)

  - ### Method Detail

    - #### setId

          protected void setId(String id)

    - #### setTimeout

          protected void setTimeout(long timeout)

    - #### setData

          protected void setData(Map<String,Object> data)

    - #### setData

          protected void setData(JsonObject data)

    - #### setLastAccessed

          protected void setLastAccessed(long lastAccessed)

    - #### setVersion

          protected void setVersion(int version)

    - #### setPRNG

          public void setPRNG(VertxContextPRNG prng)

    - #### id

          public String id()

      Specified by:
        `id` in interface `Session`
      Returns:
        The unique ID of the session. This is generated using a random secure UUID.

    - #### regenerateId

          public Session regenerateId()

      Specified by:
        `regenerateId` in interface `Session`
      Returns:
        The new unique ID of the session.

    - #### timeout

          public long timeout()

      Specified by:
        `timeout` in interface `Session`
      Returns:
        the amount of time in ms, after which the session will expire, if not accessed.

    - #### get

          public <T> T get(String key)

      Description copied from interface: `Session`
      Get some data from the session
      Specified by:
        `get` in interface `Session`
      Parameters:
        `key` - the key of the data
      Returns:
        the data

    - #### put

          public Session put(String key,
                             Object obj)

      Description copied from interface: `Session`
      Put some data in a session
      Specified by:
        `put` in interface `Session`
      Parameters:
        `key` - the key for the data
        `obj` - the data
      Returns:
        a reference to this, so the API can be used fluently

    - #### remove

          public <T> T remove(String key)

      Description copied from interface: `Session`
      Remove some data from the session
      Specified by:
        `remove` in interface `Session`
      Parameters:
        `key` - the key of the data
      Returns:
        the data that was there or null if none there

    - #### data

          public Map<String,Object> data()

      Specified by:
        `data` in interface `Session`
      Returns:
        the session data as a map

    - #### isEmpty

          public boolean isEmpty()

      Specified by:
        `isEmpty` in interface `Session`
      Returns:
        true if the session has data

    - #### lastAccessed

          public long lastAccessed()

      Specified by:
        `lastAccessed` in interface `Session`
      Returns:
        the time the session was last accessed

    - #### setAccessed

          public void setAccessed()

      Description copied from interface: `Session`
      Mark the session as being accessed.
      Specified by:
        `setAccessed` in interface `Session`

    - #### destroy

          public void destroy()

      Description copied from interface: `Session`
      Destroy the session
      Specified by:
        `destroy` in interface `Session`

    - #### isDestroyed

          public boolean isDestroyed()

      Specified by:
        `isDestroyed` in interface `Session`
      Returns:
        has the session been destroyed?

    - #### isRegenerated

          public boolean isRegenerated()

      Specified by:
        `isRegenerated` in interface `Session`
      Returns:
        has the session been renewed?

    - #### oldId

          public String oldId()

      Specified by:
        `oldId` in interface `Session`
      Returns:
        old ID if renewed

    - #### version

          public int version()

    - #### incrementVersion

          public void incrementVersion()

    - #### crc

          protected int crc()

    - #### checksum

          protected int checksum()

Copyright © 2020 Eclipse. All rights reserved.