Class Sync

java.lang.Object
io.objectbox.sync.Sync

public final class Sync extends Object
ObjectBox Sync makes data available on other devices.

Use the static methods to build a Sync client or embedded server.

  • Constructor Details

    • Sync

      private Sync()
  • Method Details

    • isAvailable

      public static boolean isAvailable()
      Returns true if the included native (JNI) ObjectBox library supports Sync.
    • isServerAvailable

      public static boolean isServerAvailable()
      Returns true if the included native (JNI) ObjectBox library supports Sync server.
    • isHybridAvailable

      public static boolean isHybridAvailable()
      Returns true if the included native (JNI) ObjectBox library supports Sync hybrids (server invalid input: '&' client).
    • client

      public static SyncBuilder client(BoxStore boxStore, String url, SyncCredentials credentials)
      Starts building a SyncClient. Once done, complete with build().
      Parameters:
      boxStore - The BoxStore the client should use.
      url - The URL of the Sync server on which the Sync protocol is exposed. This is typically a WebSockets URL starting with ws:// or wss:// (for encrypted connections), for example ws://127.0.0.1:9999.
      credentials - SyncCredentials to authenticate with the server.
    • client

      public static SyncBuilder client(BoxStore boxStore, String url, SyncCredentials[] multipleCredentials)
      Starts building a SyncClient. Once done, complete with build().
      Parameters:
      boxStore - The BoxStore the client should use.
      url - The URL of the Sync server on which the Sync protocol is exposed. This is typically a WebSockets URL starting with ws:// or wss:// (for encrypted connections), for example ws://127.0.0.1:9999.
      multipleCredentials - An array of SyncCredentials to be used to authenticate the user.
    • server

      public static SyncServerBuilder server(BoxStore boxStore, String url, SyncCredentials authenticatorCredentials)
      Starts building a SyncServer. Once done, complete with build().

      Note: when also using Admin, make sure it is started before the server.

      Parameters:
      boxStore - The BoxStore the server should use.
      url - The URL of the Sync server on which the Sync protocol is exposed. This is typically a WebSockets URL starting with ws:// or wss:// (for encrypted connections), for example ws://0.0.0.0:9999.
      authenticatorCredentials - An authentication method available to Sync clients and peers. Additional authenticator credentials can be supplied using the returned builder. For the embedded server, currently only SyncCredentials.sharedSecret(java.lang.String) and SyncCredentials.none() are supported.
    • server

      public static SyncServerBuilder server(BoxStore boxStore, String url, SyncCredentials[] multipleAuthenticatorCredentials)
      Starts building a SyncServer. Once done, complete with build().

      Note: when also using Admin, make sure it is started before the server.

      Parameters:
      boxStore - The BoxStore the server should use.
      url - The URL of the Sync server on which the Sync protocol is exposed. This is typically a WebSockets URL starting with ws:// or wss:// (for encrypted connections), for example ws://0.0.0.0:9999.
      multipleAuthenticatorCredentials - An authentication method available to Sync clients and peers. Additional authenticator credentials can be supplied using the returned builder. For the embedded server, currently only SyncCredentials.sharedSecret(java.lang.String) and SyncCredentials.none() are supported.
    • hybrid

      public static SyncHybridBuilder hybrid(BoxStoreBuilder storeBuilder, String url, SyncCredentials authenticatorCredentials)
      Starts building a SyncHybrid, a client/server hybrid typically used for embedded cluster setups.

      Unlike client(BoxStore, String, SyncCredentials) and server(BoxStore, String, SyncCredentials), the client Store is not built before. Instead, a Store builder must be passed. The client and server Store will be built internally when calling this method.

      To configure client and server use the methods on SyncHybridBuilder.

      Parameters:
      storeBuilder - The BoxStoreBuilder to use for building the client store.
      url - The URL of the Sync server on which the Sync protocol is exposed. This is typically a WebSockets URL starting with ws:// or wss:// (for encrypted connections), for example ws://0.0.0.0:9999.
      authenticatorCredentials - An authentication method available to Sync clients and peers. The client of the hybrid is pre-configured with them. Additional credentials can be supplied using the client and server builder of the returned builder. For the embedded server, currently only SyncCredentials.sharedSecret(java.lang.String) and SyncCredentials.none() are supported.
      Returns:
      An instance of SyncHybridBuilder.