Class SyncHybrid
- java.lang.Object
-
- io.objectbox.sync.SyncHybrid
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
public final class SyncHybrid extends java.lang.Object implements java.io.CloseableCombines the functionality of a Sync client and a Sync server.It is typically used in local cluster setups, in which a "hybrid" functions as a client & cluster peer (server).
Call
getStore()to retrieve the store. To set sync listeners use theSyncClientthat is available fromgetClient().This class implements the
Closeableinterface, ensuring that resources are cleaned up properly.
-
-
Field Summary
Fields Modifier and Type Field Description private SyncClientclientprivate SyncServerserverprivate BoxStorestoreprivate BoxStorestoreServer
-
Constructor Summary
Constructors Constructor Description SyncHybrid(BoxStore store, SyncClient client, BoxStore storeServer, SyncServer server)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Closes and cleans up all resources used by this Sync hybrid.protected voidfinalize()Users of this class should explicitly callclose()instead to avoid expensive finalization.SyncClientgetClient()Returns theSyncClientof this hybrid, typically only to set Sync listeners.SyncServergetServer()Returns theSyncServerof this hybrid.BoxStoregetStore()voidstop()Stops the client and server.
-
-
-
Field Detail
-
store
private BoxStore store
-
client
private final SyncClient client
-
storeServer
private BoxStore storeServer
-
server
private final SyncServer server
-
-
Constructor Detail
-
SyncHybrid
SyncHybrid(BoxStore store, SyncClient client, BoxStore storeServer, SyncServer server)
-
-
Method Detail
-
getStore
public BoxStore getStore()
-
getClient
public SyncClient getClient()
Returns theSyncClientof this hybrid, typically only to set Sync listeners.Note: do not stop or close the client directly. Instead, use the
stop()andclose()methods of this hybrid.
-
getServer
public SyncServer getServer()
Returns theSyncServerof this hybrid.Typically, the server should not be touched. Yet, it is still exposed for advanced use cases.
Note: do not stop or close the server directly. Instead, use the
stop()andclose()methods of this hybrid.
-
stop
public void stop()
Stops the client and server.
-
close
public void close()
Closes and cleans up all resources used by this Sync hybrid.It can no longer be used afterward, build a new one instead.
Does nothing if this has already been closed.
- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable
-
finalize
protected void finalize() throws java.lang.ThrowableUsers of this class should explicitly callclose()instead to avoid expensive finalization.- Overrides:
finalizein classjava.lang.Object- Throws:
java.lang.Throwable
-
-