TAPI topology creation for 100GE Transponder
[transportpce.git] / tapi / src / main / java / org / opendaylight / transportpce / tapi / impl / TapiProvider.java
1 /*
2  * Copyright © 2018 Orange, 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.transportpce.tapi.impl;
9
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.servicehandler.service.ServiceHandlerOperations;
16 import org.opendaylight.transportpce.tapi.topology.TapiTopologyImpl;
17 import org.opendaylight.transportpce.tapi.utils.TapiListener;
18 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.TapiConnectivityService;
19 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.TapiTopologyService;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.tapi.rev180928.ServiceInterfacePoints;
21 import org.opendaylight.yangtools.concepts.ListenerRegistration;
22 import org.opendaylight.yangtools.concepts.ObjectRegistration;
23 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
24 import org.slf4j.Logger;
25 import org.slf4j.LoggerFactory;
26
27 /**
28  * Class to register TAPI interface Service and Notification.
29  *
30  * @author Gilles Thouenon (gilles.thouenon@orange.com) on behalf of Orange
31  *
32  */
33 public class TapiProvider {
34
35     private static final Logger LOG = LoggerFactory.getLogger(TapiProvider.class);
36
37     private final DataBroker dataBroker;
38     private final RpcProviderService rpcProviderService;
39     private ObjectRegistration<TapiConnectivityService> rpcRegistration;
40     private ObjectRegistration<TapiTopologyService> rpcRegistration2;
41     private final ServiceHandlerOperations serviceHandler;
42     private ListenerRegistration<TapiListener> listenerRegistration;
43     private final TapiListener tapiListener;
44
45     public TapiProvider(DataBroker dataBroker, RpcProviderService rpcProviderService,
46             ServiceHandlerOperations serviceHanlder, TapiListener tapiListener) {
47         this.dataBroker = dataBroker;
48         this.rpcProviderService = rpcProviderService;
49         this.serviceHandler = serviceHanlder;
50         this.tapiListener = tapiListener;
51     }
52
53     /**
54      * Method called when the blueprint container is created.
55      */
56     public void init() {
57         LOG.info("TapiProvider Session Initiated");
58         TapiImpl tapi = new TapiImpl(this.serviceHandler);
59         TapiTopologyImpl topo = new TapiTopologyImpl(this.dataBroker);
60         rpcRegistration = rpcProviderService.registerRpcImplementation(TapiConnectivityService.class, tapi);
61         rpcRegistration2 = rpcProviderService.registerRpcImplementation(TapiTopologyService.class, topo);
62         @NonNull
63         InstanceIdentifier<ServiceInterfacePoints> sipIID = InstanceIdentifier.create(ServiceInterfacePoints.class);
64         listenerRegistration = dataBroker.registerDataTreeChangeListener(DataTreeIdentifier.create(
65             LogicalDatastoreType.CONFIGURATION, sipIID), tapiListener);
66     }
67
68     /**
69      * Method called when the blueprint container is destroyed.
70      */
71     public void close() {
72         LOG.info("TapiProvider Session Closed");
73         // pcelistenerRegistration.close();
74         rpcRegistration.close();
75     }
76
77 }