Package io.objectbox.sync
Class Sync
- java.lang.Object
-
- io.objectbox.sync.Sync
-
public final class Sync extends java.lang.Object
ObjectBox Sync makes data available on other devices.Use the static methods to build a Sync client or embedded server.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static SyncBuilder
client(BoxStore boxStore, java.lang.String url, SyncCredentials credentials)
Starts building aSyncClient
.static SyncHybridBuilder
hybrid(BoxStoreBuilder storeBuilder, java.lang.String url, SyncCredentials authenticatorCredentials)
Starts building aSyncHybrid
, a client/server hybrid typically used for embedded cluster setups.static boolean
isAvailable()
Returns true if the included native (JNI) ObjectBox library supports Sync.static boolean
isHybridAvailable()
Returns true if the included native (JNI) ObjectBox library supports Sync hybrids (server & client).static boolean
isServerAvailable()
Returns true if the included native (JNI) ObjectBox library supports Sync server.static SyncServerBuilder
server(BoxStore boxStore, java.lang.String url, SyncCredentials authenticatorCredentials)
Starts building aSyncServer
.
-
-
-
Method Detail
-
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 & client).
-
client
public static SyncBuilder client(BoxStore boxStore, java.lang.String url, SyncCredentials credentials)
Starts building aSyncClient
. Once done, complete withbuild()
.- Parameters:
boxStore
- TheBoxStore
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 withws://
orwss://
(for encrypted connections), for examplews://127.0.0.1:9999
.credentials
-SyncCredentials
to authenticate with the server.
-
server
public static SyncServerBuilder server(BoxStore boxStore, java.lang.String url, SyncCredentials authenticatorCredentials)
Starts building aSyncServer
. Once done, complete withbuild()
.Note: when also using Admin, make sure it is started before the server.
- Parameters:
boxStore
- TheBoxStore
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 withws://
orwss://
(for encrypted connections), for examplews://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 onlySyncCredentials.sharedSecret(java.lang.String)
andSyncCredentials.none()
are supported.
-
hybrid
public static SyncHybridBuilder hybrid(BoxStoreBuilder storeBuilder, java.lang.String url, SyncCredentials authenticatorCredentials)
Starts building aSyncHybrid
, a client/server hybrid typically used for embedded cluster setups.Unlike
client(BoxStore, String, SyncCredentials)
andserver(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
- TheBoxStoreBuilder
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 withws://
orwss://
(for encrypted connections), for examplews://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 onlySyncCredentials.sharedSecret(java.lang.String)
andSyncCredentials.none()
are supported.- Returns:
- An instance of
SyncHybridBuilder
.
-
-