BUG 2138 - Do not fail on module-based default shard
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / ShardDataTreeChangeListenerPublisherActorProxy.java
1 /*
2  * Copyright (c) 2016 Brocade Communications 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 package org.opendaylight.controller.cluster.datastore;
9
10 import akka.actor.ActorContext;
11 import javax.annotation.concurrent.NotThreadSafe;
12 import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeListener;
13 import org.opendaylight.yangtools.concepts.ListenerRegistration;
14 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
15
16 /**
17  * Implementation of ShardDataTreeChangeListenerPublisher that offloads the generation and publication
18  * of data tree change notifications to an actor.
19  *
20  * @author Thomas Pantelis
21  */
22 @NotThreadSafe
23 class ShardDataTreeChangeListenerPublisherActorProxy extends AbstractShardDataTreeNotificationPublisherActorProxy
24         implements ShardDataTreeChangeListenerPublisher {
25
26     private final ShardDataTreeChangeListenerPublisher delegatePublisher =
27             new DefaultShardDataTreeChangeListenerPublisher();
28
29     ShardDataTreeChangeListenerPublisherActorProxy(ActorContext actorContext, String actorName) {
30         super(actorContext, actorName);
31     }
32
33     private ShardDataTreeChangeListenerPublisherActorProxy(ShardDataTreeChangeListenerPublisherActorProxy other) {
34         super(other);
35     }
36
37     @Override
38     public <L extends DOMDataTreeChangeListener> ListenerRegistration<L> registerTreeChangeListener(
39             YangInstanceIdentifier treeId, L listener) {
40         return delegatePublisher.registerTreeChangeListener(treeId, listener);
41     }
42
43     @Override
44     public ShardDataTreeChangeListenerPublisher newInstance() {
45         return new ShardDataTreeChangeListenerPublisherActorProxy(this);
46     }
47
48     @Override
49     protected ShardDataTreeNotificationPublisher getDelegatePublisher() {
50         return delegatePublisher;
51     }
52 }