Update stubRenderer
[transportpce.git] / servicehandler / src / main / java / org / opendaylight / transportpce / servicehandler / impl / ServicehandlerProvider.java
1 /*
2  * Copyright © 2017 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
9 package org.opendaylight.transportpce.servicehandler.impl;
10
11 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
12 import org.opendaylight.controller.md.sal.binding.api.NotificationService;
13 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RpcRegistration;
14 import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
15 import org.opendaylight.transportpce.pce.service.PathComputationService;
16 import org.opendaylight.transportpce.renderer.NetworkModelWavelengthService;
17 import org.opendaylight.transportpce.renderer.provisiondevice.RendererServiceOperations;
18 import org.opendaylight.transportpce.servicehandler.listeners.PceListenerImpl;
19 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev170426.TransportpcePceListener;
20 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.OrgOpenroadmServiceService;
21 import org.opendaylight.yangtools.concepts.ListenerRegistration;
22 import org.slf4j.Logger;
23 import org.slf4j.LoggerFactory;
24
25 /**
26  * Class to register
27  * Servicehandler Service and Notification.
28  * @author Martial Coulibaly ( martial.coulibaly@gfi.com ) on behalf of Orange
29  *
30  */
31 public class ServicehandlerProvider {
32
33     private static final Logger LOG = LoggerFactory.getLogger(ServicehandlerProvider.class);
34
35     private final DataBroker dataBroker;
36     private final RpcProviderRegistry rpcRegistry;
37     private final NotificationService notificationService;
38     private final NetworkModelWavelengthService networkModelWavelengthService;
39     private ListenerRegistration<TransportpcePceListener> pcelistenerRegistration;
40     private RpcRegistration<OrgOpenroadmServiceService> rpcRegistration;
41     private PathComputationService pathComputationService;
42     private RendererServiceOperations rendererServiceOperations;
43
44     public ServicehandlerProvider(final DataBroker dataBroker, RpcProviderRegistry rpcProviderRegistry,
45             NotificationService notificationService, PathComputationService pathComputationService,
46             RendererServiceOperations rendererServiceOperations,
47             NetworkModelWavelengthService networkModelWavelengthService) {
48         this.dataBroker = dataBroker;
49         this.rpcRegistry = rpcProviderRegistry;
50         this.notificationService = notificationService;
51         this.pathComputationService = pathComputationService;
52         this.rendererServiceOperations = rendererServiceOperations;
53         this.networkModelWavelengthService = networkModelWavelengthService;
54     }
55
56     /**
57      * Method called when the blueprint container is created.
58      */
59     public void init() {
60         LOG.info("ServicehandlerProvider Session Initiated");
61         final ServicehandlerImpl servicehandler = new ServicehandlerImpl(dataBroker, pathComputationService,
62                 rendererServiceOperations, networkModelWavelengthService);
63         final PceListenerImpl pceListener = new PceListenerImpl();
64         rpcRegistration = rpcRegistry.addRpcImplementation(OrgOpenroadmServiceService.class, servicehandler);
65     }
66
67     /**
68      * Method called when the blueprint container is destroyed.
69      */
70     public void close() {
71         LOG.info("ServicehandlerProvider Closed");
72         pcelistenerRegistration.close();
73         rpcRegistration.close();
74     }
75
76 }