SyncStatusListener API

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

Note: This topic is not applicable for DOE-based applications.

Create a listener that implements the SyncStatusListener interface.

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

public class MySyncListener implements SyncStatusListener
{
// implementation
}

Pass an instance of the listener to the synchronize methods.

SyncStatusListener listener = new MySyncListener();
SUP101DB.synchronize("sync_group", listener);
// or SUP101DB.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.

The method returns false to allow synchronization to continue. If the method returns true, the synchronization is aborted.

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 other than the primary user interface thread, the client cannot update its screen as the status changes. The client must instruct the primary user interface thread to update the screen regarding the current synchronization status.

This is an example of SyncStatusListener implementation:

public class SyncListener implements 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;
  }
}