Bug 2486: Get testAbortBeforeFinishCommit working again
[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 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
20
21 /**
22  * DataChangeListenerProxy represents a single remote DataChangeListener
23  */
24 public class DataChangeListenerProxy implements AsyncDataChangeListener<YangInstanceIdentifier, NormalizedNode<?, ?>>{
25     private final ActorSelection dataChangeListenerActor;
26     private final SchemaContext schemaContext;
27
28     public DataChangeListenerProxy(SchemaContext schemaContext, ActorSelection dataChangeListenerActor) {
29         this.dataChangeListenerActor = Preconditions.checkNotNull(dataChangeListenerActor, "dataChangeListenerActor should not be null");
30         this.schemaContext = schemaContext;
31     }
32
33     @Override public void onDataChanged(
34         AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> change) {
35         dataChangeListenerActor.tell(new DataChanged(schemaContext, change), ActorRef.noSender());
36     }
37 }