import org.opendaylight.controller.cluster.datastore.messages.DataChanged;
import org.opendaylight.controller.cluster.datastore.messages.DataChangedReply;
import org.opendaylight.controller.cluster.datastore.messages.EnableNotification;
+import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener;
import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeListener;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+/**
+ * @Deprecated Replaced by {@link DataTreeChangeListener}
+ */
+@Deprecated
public class DataChangeListener extends AbstractUntypedActor {
private static final Logger LOG = LoggerFactory.getLogger(DataChangeListener.class);
private final AsyncDataChangeListener<YangInstanceIdentifier, NormalizedNode<?, ?>> listener;
private boolean notificationsEnabled = false;
- public DataChangeListener(AsyncDataChangeListener<YangInstanceIdentifier,
- NormalizedNode<?, ?>> listener) {
+ public DataChangeListener(AsyncDataChangeListener<YangInstanceIdentifier, NormalizedNode<?, ?>> listener) {
this.listener = Preconditions.checkNotNull(listener, "listener should not be null");
}
@Override
- public void handleReceive(Object message) throws Exception {
- if(message instanceof DataChanged){
+ public void handleReceive(Object message) {
+ if (message instanceof DataChanged){
dataChanged(message);
- } else if(message instanceof EnableNotification){
+ } else if (message instanceof EnableNotification){
enableNotification((EnableNotification) message);
+ } else {
+ unknownMessage(message);
}
}
// Do nothing if notifications are not enabled
if(!notificationsEnabled) {
- LOG.debug("Notifications not enabled for listener {} - dropping change notification",
- listener);
+ LOG.debug("Notifications not enabled for listener {} - dropping change notification", listener);
return;
}
LOG.error( String.format( "Error notifying listener %s", this.listener ), e );
}
- // It seems the sender is never null but it doesn't hurt to check. If the caller passes in
- // a null sender (ActorRef.noSender()), akka translates that to the deadLetters actor.
- if(getSender() != null && !getContext().system().deadLetters().equals(getSender())) {
- getSender().tell(new DataChangedReply(), getSelf());
+ if(isValidSender(getSender())) {
+ getSender().tell(DataChangedReply.INSTANCE, getSelf());
}
}