Merge "Sonar clean-up: OF13Provider"
[netvirt.git] / ovsdb-plugin-compatibility-layer / src / main / java / org / opendaylight / ovsdb / compatibility / plugin / impl / ConnectionServiceImpl.java
1 /*
2  * Copyright (c) 2015 Brocade Communications Systems, 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.ovsdb.compatibility.plugin.impl;
9
10 import java.util.List;
11 import java.util.Map;
12
13 import org.opendaylight.controller.sal.core.Node;
14 import org.opendaylight.ovsdb.compatibility.plugin.api.NodeUtils;
15 import org.opendaylight.ovsdb.compatibility.plugin.api.OvsdbConnectionService;
16 import org.opendaylight.ovsdb.plugin.api.Connection;
17 import org.opendaylight.ovsdb.plugin.api.ConnectionConstants;
18 import org.slf4j.Logger;
19 import org.slf4j.LoggerFactory;
20
21 /**
22  * This is a proxy class for ovsdb plugin's OvsdbConnectionService class
23  * It just forward the call to OvsdbConnectionService instance and pass
24  * back the response to the caller.
25  *
26  * @author Anil Vishnoi (vishnoianil@gmail.com)
27  *
28  */
29 public class ConnectionServiceImpl implements OvsdbConnectionService{
30     protected static final Logger logger = LoggerFactory.getLogger(ConnectionServiceImpl.class);
31
32     private volatile org.opendaylight.ovsdb.plugin.api.OvsdbConnectionService pluginOvsdbConnectionService;
33
34     public void init() {
35     }
36
37     /**
38      * Function called by the dependency manager when at least one dependency
39      * become unsatisfied or when the component is shutting down because for
40      * example bundle is being stopped.
41      */
42     void destroy() {
43     }
44
45     /**
46      * Function called by dependency manager after "init ()" is called and after
47      * the services provided by the class are registered in the service registry
48      */
49     void start() {
50     }
51
52     /**
53      * Function called by the dependency manager before the services exported by
54      * the component are unregistered, this will be followed by a "destroy ()"
55      * calls
56      */
57     void stopping() {
58     }
59
60     public void setOvsdbConnectionService(org.opendaylight.ovsdb.plugin.api.OvsdbConnectionService pluginOvsdbConnectionService){
61         this.pluginOvsdbConnectionService = pluginOvsdbConnectionService;
62     }
63
64     public void unsetOvsdbConnectionService(org.opendaylight.ovsdb.plugin.api.OvsdbConnectionService pluginOvsdbConnectionService){
65         this.pluginOvsdbConnectionService = null;
66     }
67
68     @Override
69     public Connection getConnection(Node node) {
70         return pluginOvsdbConnectionService.getConnection(NodeUtils.getMdsalNode(node));
71     }
72
73     @Override
74     public Node getNode (String identifier) {
75         return NodeUtils.getSalNode(pluginOvsdbConnectionService.getNode(identifier));
76     }
77
78     @Override
79     public List<Node> getNodes() {
80         return NodeUtils.getSalNodes(pluginOvsdbConnectionService.getNodes());
81     }
82
83     @Override
84     public Node connect(String identifier, Map<ConnectionConstants, String> params) {
85         return NodeUtils.getSalNode(pluginOvsdbConnectionService.connect(identifier, params));
86     }
87
88 }