SyncStatusListener API

You can implement a synchronization status listener to track the progress of synchronization.

Create a listener that implements the SyncStatusListener interface as follows:

public interface SyncStatusListener 
{
    boolean objectSyncStatus(ObjectSyncStatusData statusData);
}

public class MySyncListener extends SyncStatusListener
{
// implementation
}

Pass an instance of the listener to the synchronize methods as follows:

MySyncListener listener = new MySyncListener();
<PkgName>DB.synchronize("sync_group", listener);
// or <PkgName>DB.synchronize(listener); if we want to synchronize all
// synchronization groups

As the application synchronization progresses, the objectSyncStatus method defined by the SyncStatusListener interface is called and is passed an ObjectSyncStatusData object. The ObjectSyncStatusData object contains information about the MBO being synchronized, the connection to which it is related, and the current state of the synchronization process. By testing the State property of the ObjectSyncStatusData object and comparing it to the possible values in the SyncStatusState enumeration, the application can react accordingly to the state of the synchronization.

Possible uses of objectSyncStatus method include changing form elements on the client screen to show synchronization progress, such as a green image when the synchronization is in progress, a red image if the synchronization fails, and a gray image when the synchronization has completed successfully and disconnected from the server.

Note: The objectSyncStatus method of SyncStatusListener is called and executed in the data synchronization thread. If a client runs synchronizations in a thread that is not the primary user interface thread, the client cannot update its screen as the status changes. In that case, the client must instruct the primary user interface thread to update the screen regarding the current synchronization status.

The following is an example of syncStatusListener implementation:

public class SyncListener extends syncStatusListener
{
  public boolean objectSyncStatus(ObjectSyncStatusData data)
  {
    switch (data.getSyncStatusState()) {
    case SyncStatusState.APPLICATION_SYNC_DONE:
      //implement your own UI indicator bar
      break;
    case SyncStatusState.APPLICATION_SYNC_ERROR:
      //implement your own UI indicator bar
      break;
    case SyncStatusState.SYNC_DONE:
      //implement your own UI indicator bar
      break;
    case SyncStatusState.SYNC_STARTING:
      //implement your own UI indicator bar
      break;
    ...
    }
    return false;
  }
}