2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
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
9 package org.opendaylight.controller.cluster.datastore;
11 import akka.actor.ActorRef;
12 import akka.actor.ActorSelection;
13 import akka.actor.PoisonPill;
14 import org.opendaylight.controller.cluster.datastore.messages.CloseDataChangeListenerRegistration;
15 import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeListener;
16 import org.opendaylight.yangtools.concepts.ListenerRegistration;
17 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
18 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
21 * ListenerRegistrationProxy acts as a proxy for a ListenerRegistration that was done on a remote shard
23 * Registering a DataChangeListener on the Data Store creates a new instance of the ListenerRegistrationProxy
24 * The ListenerRegistrationProxy talks to a remote ListenerRegistration actor.
27 public class DataChangeListenerRegistrationProxy implements ListenerRegistration {
28 private final ActorSelection listenerRegistrationActor;
29 private final AsyncDataChangeListener listener;
30 private final ActorRef dataChangeListenerActor;
32 public <L extends AsyncDataChangeListener<InstanceIdentifier, NormalizedNode<?, ?>>>
33 DataChangeListenerRegistrationProxy(
34 ActorSelection listenerRegistrationActor,
35 L listener, ActorRef dataChangeListenerActor) {
36 this.listenerRegistrationActor = listenerRegistrationActor;
37 this.listener = listener;
38 this.dataChangeListenerActor = dataChangeListenerActor;
42 public Object getInstance() {
48 listenerRegistrationActor.tell(new CloseDataChangeListenerRegistration(), null);
49 dataChangeListenerActor.tell(PoisonPill.getInstance(), null);