2 * Copyright © 2018 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.tapi.impl;
10 import org.eclipse.jdt.annotation.NonNull;
11 import org.opendaylight.mdsal.binding.api.DataBroker;
12 import org.opendaylight.mdsal.binding.api.DataTreeIdentifier;
13 import org.opendaylight.mdsal.binding.api.RpcProviderService;
14 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
15 import org.opendaylight.transportpce.common.network.NetworkTransactionService;
16 import org.opendaylight.transportpce.tapi.connectivity.TapiConnectivityImpl;
17 import org.opendaylight.transportpce.tapi.topology.TapiTopologyImpl;
18 import org.opendaylight.transportpce.tapi.utils.TapiContext;
19 import org.opendaylight.transportpce.tapi.utils.TapiListener;
20 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.OrgOpenroadmServiceService;
21 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.TapiConnectivityService;
22 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.TapiTopologyService;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.tapi.rev180928.ServiceInterfacePoints;
24 import org.opendaylight.yangtools.concepts.ObjectRegistration;
25 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
26 import org.slf4j.Logger;
27 import org.slf4j.LoggerFactory;
30 * Class to register TAPI interface Service and Notification.
32 * @author Gilles Thouenon (gilles.thouenon@orange.com) on behalf of Orange
35 public class TapiProvider {
37 private static final Logger LOG = LoggerFactory.getLogger(TapiProvider.class);
39 private final DataBroker dataBroker;
40 private final RpcProviderService rpcProviderService;
41 private ObjectRegistration<TapiConnectivityService> rpcRegistration;
42 private final OrgOpenroadmServiceService serviceHandler;
43 private final TapiListener tapiListener;
44 private final NetworkTransactionService networkTransactionService;
46 public TapiProvider(DataBroker dataBroker, RpcProviderService rpcProviderService,
47 OrgOpenroadmServiceService serviceHandler, TapiListener tapiListener,
48 NetworkTransactionService networkTransactionService) {
49 this.dataBroker = dataBroker;
50 this.rpcProviderService = rpcProviderService;
51 this.serviceHandler = serviceHandler;
52 this.tapiListener = tapiListener;
53 this.networkTransactionService = networkTransactionService;
57 * Method called when the blueprint container is created.
60 LOG.info("TapiProvider Session Initiated");
61 TapiContext tapiContext = new TapiContext(this.networkTransactionService);
62 LOG.info("Empty TAPI context created: {}", tapiContext.getTapiContext());
63 TapiConnectivityImpl tapi = new TapiConnectivityImpl(this.serviceHandler);
64 TapiTopologyImpl topo = new TapiTopologyImpl(this.dataBroker);
65 rpcRegistration = rpcProviderService.registerRpcImplementation(TapiConnectivityService.class, tapi);
66 rpcProviderService.registerRpcImplementation(TapiTopologyService.class, topo);
68 InstanceIdentifier<ServiceInterfacePoints> sipIID = InstanceIdentifier.create(ServiceInterfacePoints.class);
69 dataBroker.registerDataTreeChangeListener(DataTreeIdentifier.create(
70 LogicalDatastoreType.CONFIGURATION, sipIID), tapiListener);
74 * Method called when the blueprint container is destroyed.
77 LOG.info("TapiProvider Session Closed");
78 rpcRegistration.close();