You can implement a synchronization status listener to track synchronization progress.
Create a listener that implements the SyncStatusListener interface.
public interface SyncStatusListener { boolean objectSyncStatus(ObjectSyncStatusData statusData); } public class MySyncListener extends SyncStatusListener { // implementation }
Pass an instance of the listener to the synchronize methods.
MySyncListener 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.
This 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; } }