IdManager implementation
[vpnservice.git] / idmanager / idmanager-impl / src / main / java / org / opendaylight / idmanager / IdManagerServiceProvider.java
1 /*
2  * Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. 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.idmanager;
10
11 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
12 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
13 import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
14
15 import org.slf4j.Logger;
16 import org.slf4j.LoggerFactory;
17
18
19 public class IdManagerServiceProvider implements BindingAwareProvider,
20             AutoCloseable {
21
22         private static final Logger LOG = LoggerFactory.getLogger(IdManagerServiceProvider.class);
23         private IdManager idManager;
24
25         @Override
26         public void onSessionInitiated(ProviderContext session){
27             LOG.info("IDManagerserviceProvider Session Initiated");
28             try {
29                 final  DataBroker dataBroker = session.getSALService(DataBroker.class);
30                 idManager = new IdManager(dataBroker);
31             } catch (Exception e) {
32                 LOG.error("Error initializing services", e);
33             }
34         }
35
36         @Override
37         public void close() throws Exception {
38             idManager.close();
39         }
40     }
41
42
43
44
45