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.PoisonPill;
12 import akka.actor.Props;
13 import akka.japi.Creator;
14 import org.opendaylight.controller.cluster.datastore.messages.CloseDataChangeListenerRegistration;
15 import org.opendaylight.controller.cluster.datastore.messages.CloseDataChangeListenerRegistrationReply;
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;
20 public class DataChangeListenerRegistration extends AbstractUntypedActor {
22 private final org.opendaylight.yangtools.concepts.ListenerRegistration<AsyncDataChangeListener<YangInstanceIdentifier, NormalizedNode<?, ?>>>
25 public DataChangeListenerRegistration(
26 org.opendaylight.yangtools.concepts.ListenerRegistration<AsyncDataChangeListener<YangInstanceIdentifier, NormalizedNode<?, ?>>> registration) {
27 this.registration = registration;
31 public void handleReceive(Object message) throws Exception {
32 if (message.getClass().equals(CloseDataChangeListenerRegistration.SERIALIZABLE_CLASS)) {
33 closeListenerRegistration(
34 new CloseDataChangeListenerRegistration());
38 public static Props props(
39 final org.opendaylight.yangtools.concepts.ListenerRegistration<AsyncDataChangeListener<YangInstanceIdentifier, NormalizedNode<?, ?>>> registration) {
40 return Props.create(new Creator<DataChangeListenerRegistration>() {
43 public DataChangeListenerRegistration create() throws Exception {
44 return new DataChangeListenerRegistration(registration);
49 private void closeListenerRegistration(
50 CloseDataChangeListenerRegistration message) {
53 .tell(new CloseDataChangeListenerRegistrationReply().toSerializable(), getSelf());
54 getSelf().tell(PoisonPill.getInstance(), getSelf());