See: Description
Interface | Description |
---|---|
DeltaManager |
Interface for managing partial configuration updates.
|
DeltaReceiver |
Interface for listener to receive configuration deltas.
|
Class | Description |
---|---|
DefaultDeltaManager |
Default
DeltaManager implementation |
Provides implementation to manage partial configuration updates.
Configuration delta is a difference between current full configuration on a client and up-to-date version on a server side.
To subscribe on delta updates for a root configuration record, do following:
public class BasicDeltaReceiver implements DeltaReceiver {
\@Override
public void loadDelta(ConfigurationDelta rootDelta) {
System.out.println("Received delta for " + rootDelta.getHandlerId());
}
}
DeltaManager deltaManager = kaaClient.getDeltaManager();
deltaManager.registerRootReceiver(new BasicDeltaReceiver());
Kaa SDK provides an ability to work with deltas both for a root
configuration record and particular configuration subtrees as well.
Each configuration delta has its own unique id -
DeltaHandlerId
.
Knowing it you can subscribe listener to receive delta updates specific for
this configuration subtree.
Assume we have received delta for a root record using code from the previous example. Next we want to subscribe specific receiver for a some subrecord with field name nestedRecordField. Do following:
String fieldName = "nestedRecordField";
DeltaType nestedRecordDelta = rootDelta.getDeltaType(fieldName);
if (nestedRecordDelta != null && nestedRecordDelta.getNewValue() != null) {
ConfigurationDelta subdelta = (ConfigurationDelta)nestedRecordDelta.getNewValue();
deltaManager.subscribeForDeltaUpdates(subdelta.getHandlerId(), new BasicDeltaReceiver());
// Some useful stuff
// Remove receiver if it is no longer needed
deltaManager.unsubscribeFromDeltaUpdates(subdelta.getHandlerId());
}
DeltaManager
,
DeltaReceiver
,
ConfigurationDelta
Copyright © 2014. All rights reserved.