Merge changes I3e404877,Ida2a5c32,I9e6ce426,I6a4b90f6,I79717533
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / DataChangeListenerProxy.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.controller.cluster.datastore;
10
11 import akka.actor.ActorRef;
12 import akka.actor.ActorSelection;
13 import com.google.common.base.Preconditions;
14 import org.opendaylight.controller.cluster.datastore.messages.DataChanged;
15 import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
16 import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeListener;
17 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
18 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
19
20 /**
21  * DataChangeListenerProxy represents a single remote DataChangeListener
22  */
23 public class DataChangeListenerProxy implements AsyncDataChangeListener<YangInstanceIdentifier, NormalizedNode<?, ?>>{
24     private final ActorSelection dataChangeListenerActor;
25
26     public DataChangeListenerProxy(ActorSelection dataChangeListenerActor) {
27         this.dataChangeListenerActor = Preconditions.checkNotNull(dataChangeListenerActor,
28                 "dataChangeListenerActor should not be null");
29     }
30
31     @Override
32     public void onDataChanged(
33         AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> change) {
34         dataChangeListenerActor.tell(new DataChanged(change), ActorRef.noSender());
35     }
36 }