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