2 * Copyright © 2021 Orange, 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.transportpce.dmaap.client.impl;
10 import org.opendaylight.mdsal.binding.api.NotificationService;
11 import org.opendaylight.transportpce.dmaap.client.listener.NbiNotificationsListenerImpl;
12 import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.NbiNotificationsListener;
13 import org.opendaylight.yangtools.concepts.ListenerRegistration;
14 import org.osgi.service.component.annotations.Activate;
15 import org.osgi.service.component.annotations.Component;
16 import org.osgi.service.component.annotations.Reference;
17 import org.osgi.service.metatype.annotations.AttributeDefinition;
18 import org.osgi.service.metatype.annotations.ObjectClassDefinition;
19 import org.slf4j.Logger;
20 import org.slf4j.LoggerFactory;
22 @Component(configurationPid = "org.opendaylight.transportpce.dmaap")
23 public class DmaapClientProvider {
25 @ObjectClassDefinition
26 public @interface Configuration {
28 String dmaapBaseUrl() default "http://localhost:8080";
30 String dmaapUsername() default "";
32 String dmaapPassword() default "";
35 private static final Logger LOG = LoggerFactory.getLogger(DmaapClientProvider.class);
36 private ListenerRegistration<NbiNotificationsListener> listenerRegistration;
39 public DmaapClientProvider(@Reference NotificationService notificationService, Configuration config) {
40 this(notificationService, config.dmaapBaseUrl(), config.dmaapUsername(), config.dmaapPassword());
43 public DmaapClientProvider(NotificationService notificationService, String baseUrl,
44 String username, String password) {
45 listenerRegistration = notificationService.registerNotificationListener(
46 new NbiNotificationsListenerImpl(baseUrl, username, password));
47 LOG.info("DmaapClientProvider Session Initiated");
51 * Method called when the blueprint container is destroyed.
54 listenerRegistration.close();
55 LOG.info("DmaapClientProvider Closed");