Merge "BUG 2799: SPI for EventSources"
[controller.git] / opendaylight / md-sal / messagebus-impl / src / main / java / org / opendaylight / controller / messagebus / app / impl / EventSourceRegistrationImpl.java
1 /*
2  * Copyright (c) 2015 Cisco 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.messagebus.app.impl;
9
10 import org.opendaylight.controller.messagebus.spi.EventSource;
11 import org.opendaylight.controller.messagebus.spi.EventSourceRegistration;
12 import org.opendaylight.yangtools.concepts.AbstractObjectRegistration;
13
14 import com.google.common.base.Preconditions;
15
16
17 class EventSourceRegistrationImpl <T extends EventSource> extends AbstractObjectRegistration<T> implements EventSourceRegistration<T>{
18
19     private final EventSourceTopology eventSourceTopology;
20
21     /**
22      * @param instance of EventSource that has been registered by {@link EventSourceRegistryImpl#registerEventSource(Node, EventSource)}
23      */
24     public EventSourceRegistrationImpl(T instance, EventSourceTopology eventSourceTopology) {
25         super(instance);
26         this.eventSourceTopology = Preconditions.checkNotNull(eventSourceTopology);
27     }
28
29     @Override
30     protected void removeRegistration() {
31         this.eventSourceTopology.unRegister(getInstance());
32     }
33
34 }