Class SyncHybrid

java.lang.Object
io.objectbox.sync.SyncHybrid
All Implemented Interfaces:
Closeable, AutoCloseable

public final class SyncHybrid extends Object implements Closeable
Combines 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 and cluster peer (server).

Call getStore() to retrieve the store. To set sync listeners use the SyncClient that is available from getClient().

This class implements the Closeable interface, ensuring that resources are cleaned up properly.

  • Method Details

    • getStore

      public BoxStore getStore()
    • getClient

      public SyncClient getClient()
      Returns the SyncClient of this hybrid, typically only to set Sync listeners.

      Note: do not stop or close the client directly. Instead, use the stop() and close() methods of this hybrid.

    • getServer

      public SyncServer getServer()
      Returns the SyncServer of 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() and close() 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:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
    • finalize

      protected void finalize() throws Throwable
      Users of this class should explicitly call close() instead to avoid expensive finalization.
      Overrides:
      finalize in class Object
      Throws:
      Throwable