Package io.objectbox.sync
Class Sync
java.lang.Object
io.objectbox.sync.Sync
ObjectBox Sync makes data available on other devices.
Use the static methods to build a Sync client or embedded server.
-
Method Summary
Modifier and TypeMethodDescriptionstatic SyncBuilder
client
(BoxStore boxStore, String url, SyncCredentials credentials) Starts building aSyncClient
.static SyncBuilder
client
(BoxStore boxStore, String url, SyncCredentials[] multipleCredentials) Likeclient(BoxStore, String, SyncCredentials)
, but supports passing a set of authentication methods.static SyncHybridBuilder
hybrid
(BoxStoreBuilder storeBuilder, String url, SyncCredentials authenticatorCredentials) Starts building aSyncHybrid
, a client/server hybrid typically used for embedded cluster setups.static boolean
Returns true if the included native (JNI) ObjectBox library supports Sync.static boolean
Returns true if the included native (JNI) ObjectBox library supports Sync hybrids (server and client).static boolean
Returns true if the included native (JNI) ObjectBox library supports Sync server.static SyncServerBuilder
server
(BoxStore boxStore, String url, SyncCredentials authenticatorCredentials) Starts building aSyncServer
.static SyncServerBuilder
server
(BoxStore boxStore, String url, SyncCredentials[] multipleAuthenticatorCredentials) Likeserver(BoxStore, String, SyncCredentials)
, but supports passing a set of authentication methods for clients and peers.
-
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 and client). -
client
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.
-
client
public static SyncBuilder client(BoxStore boxStore, String url, SyncCredentials[] multipleCredentials) Likeclient(BoxStore, String, SyncCredentials)
, but supports passing a set of authentication methods.- Parameters:
multipleCredentials
- An array ofSyncCredentials
to be used to authenticate with the server.
-
server
public static SyncServerBuilder server(BoxStore boxStore, 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)
, any JWT method likeSyncCredentials.jwtIdTokenServer()
as well asSyncCredentials.none()
are supported.
-
server
public static SyncServerBuilder server(BoxStore boxStore, String url, SyncCredentials[] multipleAuthenticatorCredentials) Likeserver(BoxStore, String, SyncCredentials)
, but supports passing a set of authentication methods for clients and peers. -
hybrid
public static SyncHybridBuilder hybrid(BoxStoreBuilder storeBuilder, 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)
, any JWT method likeSyncCredentials.jwtIdTokenServer()
as well asSyncCredentials.none()
are supported.- Returns:
- An instance of
SyncHybridBuilder
.
-