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 javax.annotation.concurrent.GuardedBy;
13 import org.opendaylight.controller.cluster.datastore.messages.ListenerRegistrationMessage;
14 import org.opendaylight.yangtools.concepts.ListenerRegistration;
16 abstract class DelayedListenerRegistration<L extends EventListener, M extends ListenerRegistrationMessage>
17 implements ListenerRegistration<L> {
18 private final M registrationMessage;
19 private final ActorRef registrationActor;
22 private boolean closed;
24 protected DelayedListenerRegistration(M registrationMessage, ActorRef registrationActor) {
25 this.registrationMessage = registrationMessage;
26 this.registrationActor = registrationActor;
29 M getRegistrationMessage() {
30 return registrationMessage;
33 synchronized void createDelegate(final AbstractDataListenerSupport<L, M, ?> support) {
35 support.doRegistration(registrationMessage, registrationActor);
40 public L getInstance() {
41 // We could return null if the delegate is not set yet. In reality though, we do not and should not ever call
42 // this method on DelayedListenerRegistration instances but, since we have to provide an implementation to
43 // satisfy the interface, we throw UnsupportedOperationException to avoid possibly returning null.
44 throw new UnsupportedOperationException(
45 "getInstance should not be called on this instance since it could be null");
49 public synchronized void close() {