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.NbiNotificationsHandler;
12 import org.opendaylight.yangtools.concepts.Registration;
13 import org.osgi.service.component.annotations.Activate;
14 import org.osgi.service.component.annotations.Component;
15 import org.osgi.service.component.annotations.Reference;
16 import org.osgi.service.metatype.annotations.AttributeDefinition;
17 import org.osgi.service.metatype.annotations.ObjectClassDefinition;
18 import org.slf4j.Logger;
19 import org.slf4j.LoggerFactory;
21 @Component(configurationPid = "org.opendaylight.transportpce.dmaap")
22 public class DmaapClientProvider {
24 @ObjectClassDefinition
25 public @interface Configuration {
27 String dmaapBaseUrl() default "http://localhost:8080";
29 String dmaapUsername() default "";
31 String dmaapPassword() default "";
34 private static final Logger LOG = LoggerFactory.getLogger(DmaapClientProvider.class);
35 private Registration listenerRegistration;
38 public DmaapClientProvider(@Reference NotificationService notificationService, Configuration config) {
39 this(notificationService, config.dmaapBaseUrl(), config.dmaapUsername(), config.dmaapPassword());
42 public DmaapClientProvider(NotificationService notificationService, String baseUrl,
43 String username, String password) {
44 final var listener = new NbiNotificationsHandler(baseUrl, username, password);
45 listenerRegistration = notificationService.registerCompositeListener(listener.getCompositeListener());
46 LOG.info("DmaapClientProvider Session Initiated");
50 * Method called when the blueprint container is destroyed.
53 listenerRegistration.close();
54 LOG.info("DmaapClientProvider Closed");