Deprecate messagebus for removal
[controller.git] / opendaylight / md-sal / messagebus-impl / src / main / java / org / opendaylight / controller / messagebus / app / impl / OSGiEventSourceRegistry.java
1 /*
2  * Copyright (c) 2020 PANTHEON.tech, s.r.o. 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.annotations.Beta;
11 import org.opendaylight.controller.messagebus.spi.EventSource;
12 import org.opendaylight.controller.messagebus.spi.EventSourceRegistration;
13 import org.opendaylight.controller.messagebus.spi.EventSourceRegistry;
14 import org.opendaylight.mdsal.binding.api.DataBroker;
15 import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
16 import org.opendaylight.mdsal.binding.api.RpcProviderService;
17 import org.osgi.service.component.annotations.Activate;
18 import org.osgi.service.component.annotations.Component;
19 import org.osgi.service.component.annotations.Deactivate;
20 import org.osgi.service.component.annotations.Reference;
21 import org.slf4j.Logger;
22 import org.slf4j.LoggerFactory;
23
24 @Beta
25 @Component(immediate = true)
26 @Deprecated(forRemoval = true)
27 public final class OSGiEventSourceRegistry implements EventSourceRegistry {
28     private static final Logger LOG = LoggerFactory.getLogger(OSGiEventSourceRegistry.class);
29
30     @Reference
31     DataBroker dataBroker;
32     @Reference
33     RpcConsumerRegistry rpcConsumerRegistry;
34     @Reference
35     RpcProviderService rpcProviderService;
36
37     private EventSourceTopology delegate;
38
39     @Override
40     public <T extends EventSource> EventSourceRegistration<T> registerEventSource(final T eventSource) {
41         return delegate.registerEventSource(eventSource);
42     }
43
44     @Override
45     public void close() {
46         // Intentiational no-op
47     }
48
49     @Activate
50     void activate() {
51         delegate = new EventSourceTopology(dataBroker, rpcProviderService, rpcConsumerRegistry);
52         LOG.info("Event Source Registry started");
53     }
54
55     @Deactivate
56     void deactivate() {
57         LOG.info("Event Source Registry stopping");
58         delegate.close();
59         LOG.info("Event Source Registry stopped");
60     }
61 }