Merge "Make BridgeName strongly typed"
[ovsdb.git] / ovsdb-plugin-compatibility-layer / src / main / java / org / opendaylight / ovsdb / compatibility / plugin / internal / Activator.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.internal;
9
10 import java.util.Dictionary;
11 import java.util.Hashtable;
12
13 import org.apache.felix.dm.Component;
14 import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
15 import org.opendaylight.ovsdb.compatibility.plugin.api.OvsdbConfigurationService;
16 import org.opendaylight.ovsdb.compatibility.plugin.api.OvsdbConnectionService;
17 import org.opendaylight.ovsdb.compatibility.plugin.api.OvsdbInventoryListener;
18 import org.opendaylight.ovsdb.compatibility.plugin.api.OvsdbInventoryService;
19 import org.opendaylight.ovsdb.compatibility.plugin.impl.ConfigurationServiceImpl;
20 import org.opendaylight.ovsdb.compatibility.plugin.impl.ConnectionServiceImpl;
21 import org.opendaylight.ovsdb.compatibility.plugin.impl.InventoryServiceImpl;
22 import org.slf4j.Logger;
23 import org.slf4j.LoggerFactory;
24
25 /**
26  * Activator for ovsdb plugin compatibility layer
27  * @author Anil Vishnoi (vishnoianil@gmail.com)
28  *
29  */
30 public class Activator extends ComponentActivatorAbstractBase {
31     protected static final Logger logger = LoggerFactory
32             .getLogger(Activator.class);
33
34     /**
35      * Function called when the activator starts just after some initializations
36      * are done by the ComponentActivatorAbstractBase.
37      * Here it registers the node Type
38      *
39      */
40     @Override
41     public void init() {
42     }
43
44     /**
45      * Function called when the activator stops just before the cleanup done by
46      * ComponentActivatorAbstractBase
47      *
48      */
49     @Override
50     public void destroy() {
51     }
52     @Override
53     public Object[] getGlobalImplementations() {
54         Object[] res = { ConnectionServiceImpl.class, ConfigurationServiceImpl.class, InventoryServiceImpl.class };
55         return res;
56     }
57
58     @Override
59     public void configureGlobalInstance(Component c, Object imp){
60         if (imp.equals(ConfigurationServiceImpl.class)) {
61             // export the service to be used by SAL
62             Dictionary<String, Object> props = new Hashtable<String, Object>();
63             c.setInterface(new String[] { OvsdbConfigurationService.class.getName()}, props);
64             c.add(createServiceDependency()
65                     .setService(org.opendaylight.ovsdb.plugin.api.OvsdbConfigurationService.class)
66                     .setCallbacks("setOvsdbConfigurationService", "unsetOvsdbConfigurationService")
67                     .setRequired(true));
68         }
69
70         if (imp.equals(ConnectionServiceImpl.class)) {
71             // export the service to be used by SAL
72             Dictionary<String, Object> props = new Hashtable<String, Object>();
73             c.setInterface(
74                     new String[] {OvsdbConnectionService.class.getName()}, props);
75             c.add(createServiceDependency()
76                     .setService(org.opendaylight.ovsdb.plugin.api.OvsdbConnectionService.class)
77                     .setCallbacks("setOvsdbConnectionService", "unsetOvsdbConnectionService")
78                     .setRequired(true));
79         }
80
81         if (imp.equals(InventoryServiceImpl.class)) {
82             Dictionary<String, Object> props = new Hashtable<>();
83             c.setInterface(
84                     new String[]{OvsdbInventoryService.class.getName(),
85                             org.opendaylight.ovsdb.plugin.api.OvsdbInventoryListener.class.getName()}, props);
86             c.add(createServiceDependency()
87                     .setService(org.opendaylight.ovsdb.plugin.api.OvsdbInventoryService.class)
88                     .setCallbacks("setOvsdbInventoryService", "unsetOvsdbInventoryService")
89                     .setRequired(true));
90             c.add(createServiceDependency()
91                     .setService(OvsdbInventoryListener.class)
92                     .setCallbacks("addOvsdbInventoryListener", "removeOvsdbInventoryListener")
93                     .setRequired(true));
94         }
95
96     }
97 }