public final class Synchronization
extends ServiceProxy
Constructor and Description |
---|
Synchronization() |
Modifier and Type | Method and Description |
---|---|
void |
cachedResourceChanged(SyncResourceUpdatedCallback callback)
Event that is raised every time a cached resource is updated with new data from the service.
|
int |
cacheHitCount()
Get the cache Hit Count
|
int |
cacheMissCount()
Get the cache miss count
|
void |
discardOfflineUpdates(SyncDiscardOfflineResourceCallback callback)
Discards all offline/local edits for all the resources which are not yet successfully synchronized with server.
|
void |
evictResource(java.lang.String uri)
Evict the cached item specified by the input URL.
|
HttpConnection |
getConnection(java.lang.String url)
Returns the HTTP connection for the provided resource URL.
|
SyncNetworkStatus |
getNetworkStatus()
Gets device network status which is currently being used by Synchronization.
|
void |
loadOfflineResources(SyncLocalLoadingCallback callback)
Returns a list of all MobileResource objects that were updated offline/locally, and not yet successfully synchronized with the server.
|
void |
offlineResourceSynchronized(SyncResourceUpdatedCallback callback)
Event that is raised every time an offline resource is synchronized.
|
MobileEndpoint |
openMobileEndpoint(java.lang.String apiName,
java.lang.String endpointPath,
java.lang.Class mobileClass)
Returns an object that provides access to an endpoint in a custom API.
|
void |
purge()
Clears the cache by deleting all database tables that were created when a MobileEndpoint object was instantiated.
|
void |
requestWithUri(java.lang.String uri,
RequestMethod method,
SyncPolicy policy,
java.util.Map<java.lang.String,java.lang.String> requestHeaders,
byte[] body,
SynchronizationCallback callback)
Allows you to perform GET/PUT/POST/DELETE on a resource.
|
void |
setOfflineMode(boolean isOffline)
Sets the device to offline mode, which is good for testing.
|
void |
synchronizePinnedResource(boolean backgroundSync)
Synchronizes all pinned resources with their mobile backends.
|
public void requestWithUri(java.lang.String uri, RequestMethod method, SyncPolicy policy, java.util.Map<java.lang.String,java.lang.String> requestHeaders, byte[] body, SynchronizationCallback callback) throws java.lang.Exception
uri
- The URI to send the request tomethod
- (optional) RequestMethod value. If not explicitly set, it will be GETpolicy
- (optional) SyncPolicy
object containing all policy settingsrequestHeaders
- (optional) Map containing extra HTTP headers to support requestbody
- (optional) HTTP request body data; 'null' when there's no datacallback
- SynchronizationCallback
object used to return result when request completesjava.lang.Exception
public MobileEndpoint openMobileEndpoint(java.lang.String apiName, java.lang.String endpointPath, java.lang.Class mobileClass)
apiName
- The name of the APIendpointPath
- The endpoint in the APImobileClass
- The type of objects that the API exposespublic HttpConnection getConnection(java.lang.String url) throws java.io.IOException, java.lang.InterruptedException
url
- resource URLjava.io.IOException
java.lang.InterruptedException
public void purge() throws java.io.IOException, java.lang.InterruptedException
java.io.IOException
java.lang.InterruptedException
public void evictResource(java.lang.String uri) throws java.io.IOException, java.lang.InterruptedException
uri
- resource urijava.io.IOException
java.lang.InterruptedException
public int cacheHitCount()
public int cacheMissCount()
public void synchronizePinnedResource(boolean backgroundSync)
backgroundSync
- to specify for background mode sync.public void loadOfflineResources(SyncLocalLoadingCallback callback)
callback
- SyncLocalLoadingCallback
object used to return result when request completespublic void discardOfflineUpdates(SyncDiscardOfflineResourceCallback callback)
public SyncNetworkStatus getNetworkStatus()
SyncNetworkStatus
enum representing device network statuspublic void setOfflineMode(boolean isOffline)
isOffline
- boolean value which allows you to set the device online or offlinepublic void offlineResourceSynchronized(SyncResourceUpdatedCallback callback)
callback
- SyncResourceUpdatedCallback
object used to return result when request completes. This is called for each
offline resource which is synchronized with the servicepublic void cachedResourceChanged(SyncResourceUpdatedCallback callback)
callback
- SyncResourceUpdatedCallback
object used to return result when request completes. This is called for each
cache resource for which the latest data is updated from service