dac4f8fee8025afe31778c6908dbdb160047024e
[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 com.google.common.base.Preconditions;
11 import org.opendaylight.controller.messagebus.spi.EventSource;
12 import org.opendaylight.controller.messagebus.spi.EventSourceRegistration;
13 import org.opendaylight.yangtools.concepts.AbstractObjectRegistration;
14
15 class EventSourceRegistrationImpl<T extends EventSource> extends AbstractObjectRegistration<T>
16         implements EventSourceRegistration<T> {
17
18     private final EventSourceTopology eventSourceTopology;
19
20     /**
21      * Constructor.
22      *
23      * @param instance of EventSource that has been registered by
24      *     {@link EventSourceRegistryImpl#registerEventSource(Node, EventSource)}
25      */
26     EventSourceRegistrationImpl(T instance, EventSourceTopology eventSourceTopology) {
27         super(instance);
28         this.eventSourceTopology = Preconditions.checkNotNull(eventSourceTopology);
29     }
30
31     @Override
32     protected void removeRegistration() {
33         this.eventSourceTopology.unRegister(getInstance());
34     }
35 }