Interface Connection


public interface Connection
Connection to a particular variation schema on a Variant server established by VariantClient.connectTo(String). Variant connections are stateless, i.e. no information about this connection is retained on the server. New sessions are created against the live generation of the variation schema named in the connection. If no such schema exists on the server, the UnknownSchemaException is thrown.
Since:
0.7
  • Method Details

    • getClient

      VariantClient getClient()

      The Variant client instance, which created this connection.

      Returns:
      An instance of the VariantClient object, which originally created this connection with VariantClient.connectTo(String).
      Since:
      0.7
    • getOrCreateSession

      Session getOrCreateSession(Object userData, Optional<String> ownerId)
      Get, if exists, or create, if does not exist, a Variant session with the externally tracked ID. If the session with the ID tracked by the custom session ID tracker was found on the server, it is returned. Otherwise, a new session with a new session ID is created and the session ID tracker is reset to track the new ID.
      Parameters:
      userData - An opaque object which is passed, without interpretation, to the constructor of the user supplied session ID tracker.
      ownerId - An Optional containing an arbitrary string uniquely identifying the user actor, or empty if user actor is unknown.
      Returns:
      An object of type Session.
    • getSession

      Optional<? extends Session> getSession(Object userData)
      Get, if exists, the Variant session with the externally tracked ID. If the session with the ID tracked by the custom session ID tracker was found on the server, it is returned, wrapped in Optional. Otherwise, an empty Optional is returned.
      Parameters:
      userData - An opaque object which is passed, without interpretation, to the constructor of the user supplied session ID tracker.
      Returns:
      An Optional, containing the Session object if the session exists on Variant server, or empty otherwise.
      Since:
      0.7
    • getSessionById

      Optional<? extends Session> getSessionById(String sessionId)
      Get, if exists, the Variant session by its ID. Intended for downstream components of the host application, which do not implement an external session ID tracker, but rely on the upstream to create Variant session and pass down its ID.
      Parameters:
      sessionId - The ID of the session to be retrieved from the server.
      Returns:
      An Optional, containing the Session object, if session with the given ID exists on Variant server, or empty otherwise.
      Since:
      0.7
    • getSchemaName

      String getSchemaName()
      The name of the schema which is the target of this connection. Note that only schema name is retained at the connection level. Individual sessions created with this connection object, will be bound to those generations of this schema which were live at the time of session creation.
      Since:
      0.9