2 * Copyright (c) 2015 Brocade Communications 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
8 package org.opendaylight.controller.cluster.datastore;
10 import akka.actor.ActorRef;
11 import java.util.EventListener;
12 import org.checkerframework.checker.lock.qual.GuardedBy;
13 import org.opendaylight.controller.cluster.datastore.messages.RegisterDataTreeChangeListener;
14 import org.opendaylight.yangtools.concepts.ListenerRegistration;
16 class DelayedDataTreeChangeListenerRegistration<L extends EventListener> implements ListenerRegistration<L> {
17 private final RegisterDataTreeChangeListener registrationMessage;
18 private final ActorRef registrationActor;
21 private boolean closed;
23 DelayedDataTreeChangeListenerRegistration(final RegisterDataTreeChangeListener registrationMessage,
24 final ActorRef registrationActor) {
25 this.registrationMessage = registrationMessage;
26 this.registrationActor = registrationActor;
29 synchronized void doRegistration(final DataTreeChangeListenerSupport support) {
31 support.doRegistration(registrationMessage, registrationActor);
36 public L getInstance() {
37 // ObjectRegistration annotates this method as @Nonnull but we could return null if the delegate is not set yet.
38 // In reality, we do not and should not ever call this method on DelayedDataTreeChangeListenerRegistration
39 // instances anyway but, since we have to provide an implementation to satisfy the interface, we throw
40 // UnsupportedOperationException to honor the API contract of not returning null and to avoid a FindBugs error
41 // for possibly returning null.
42 throw new UnsupportedOperationException(
43 "getInstance should not be called on this instance since it could be null");
47 public synchronized void close() {