Interface Connection


public interface Connection
Connection to a particular schema on a Variant server. The first operation a new Variant client instance must do is connect to a particular schema on a Variant server by calling 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 via the VariantClient.connectTo(String) call.
      Since:
      0.7
    • getOrCreateSession

      Session getOrCreateSession(Object... userData)
      Get, if exists, or create, if does not exist, the Variant session with the externally tracked ID. If the session was not found on the server, a new session is created with a new session ID and the session tracker is updated accordingly.
      Parameters:
      userData - An array of zero or more opaque objects which is passed, without interpretation, to the constructor of the session ID tracker.
      Returns:
      An object of type Session. Cannot be null.
      Throws:
      UnknownSchemaException
      Since:
      0.7
    • getSession

      Optional<? extends Session> getSession(Object... userData)
      Get, if exists, the Variant session with the externally tracked ID.
      Parameters:
      userData - An array of zero or more opaque objects which is passed, without interpretation, to the constructor of the session ID tracker.
      Returns:
      An Optional, containing the Session object if the session exists on Variant server, or empty otherwise.
      Throws:
      UnknownSchemaException
      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 you are looking to retrieve from the server.
      Returns:
      An Optional, containing the Session object, if session with the given ID exists on Variant server, or empty otherwise.
      Throws:
      UnknownSchemaException
      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, may be connected to different generations of this schema.
      Since:
      0.9