-public class DataChangeListener extends UntypedActor {
- @Override public void onReceive(Object message) throws Exception {
- throw new UnsupportedOperationException("onReceive");
+public class DataChangeListener extends AbstractUntypedActor {
+ private final AsyncDataChangeListener<YangInstanceIdentifier, NormalizedNode<?, ?>> listener;
+ private final SchemaContext schemaContext;
+ private final YangInstanceIdentifier pathId;
+
+ public DataChangeListener(SchemaContext schemaContext,
+ AsyncDataChangeListener<YangInstanceIdentifier, NormalizedNode<?, ?>> listener, YangInstanceIdentifier pathId) {
+ this.listener = listener;
+ this.schemaContext = schemaContext;
+ this.pathId = pathId;
+ }
+
+ @Override public void handleReceive(Object message) throws Exception {
+ if(message.getClass().equals(DataChanged.SERIALIZABLE_CLASS)){
+ DataChanged reply = DataChanged.fromSerialize(schemaContext,message, pathId);
+ AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>>
+ change = reply.getChange();
+ this.listener.onDataChanged(change);
+
+ if(getSender() != null){
+ getSender().tell(new DataChangedReply().toSerializable(), getSelf());
+ }
+
+ }