2 * Copyright (C) 2013 Red Hat, Inc.
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
8 * Authors : Madhu Venugopal, Brent Salisbury
10 package org.opendaylight.ovsdb.plugin.internal;
12 import java.util.Dictionary;
13 import java.util.Hashtable;
15 import org.apache.felix.dm.Component;
16 import org.opendaylight.controller.clustering.services.IClusterGlobalServices;
17 import org.opendaylight.controller.sal.connection.IPluginInConnectionService;
18 import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
19 import org.opendaylight.controller.sal.core.Node;
20 import org.opendaylight.controller.sal.core.NodeConnector;
21 import org.opendaylight.controller.sal.inventory.IPluginInInventoryService;
22 import org.opendaylight.controller.sal.inventory.IPluginOutInventoryService;
23 import org.opendaylight.controller.sal.utils.GlobalConstants;
24 import org.opendaylight.controller.sal.utils.INodeConnectorFactory;
25 import org.opendaylight.controller.sal.utils.INodeFactory;
26 import org.opendaylight.ovsdb.lib.OvsdbConnection;
27 import org.opendaylight.ovsdb.lib.OvsdbConnectionListener;
28 import org.opendaylight.ovsdb.plugin.api.OvsdbConfigurationService;
29 import org.opendaylight.ovsdb.plugin.api.OvsdbConnectionService;
30 import org.opendaylight.ovsdb.plugin.api.OvsdbInventoryListener;
31 import org.opendaylight.ovsdb.plugin.api.OvsdbInventoryService;
32 import org.opendaylight.ovsdb.plugin.impl.ConfigurationServiceImpl;
33 import org.opendaylight.ovsdb.plugin.impl.ConnectionServiceImpl;
34 import org.opendaylight.ovsdb.plugin.impl.InventoryServiceImpl;
35 import org.opendaylight.ovsdb.plugin.impl.NodeConnectorFactory;
36 import org.opendaylight.ovsdb.plugin.impl.NodeFactory;
38 import org.slf4j.Logger;
39 import org.slf4j.LoggerFactory;
42 * OVSDB protocol plugin Activator
46 public class Activator extends ComponentActivatorAbstractBase {
47 protected static final Logger logger = LoggerFactory
48 .getLogger(Activator.class);
51 * Function called when the activator starts just after some initializations
52 * are done by the ComponentActivatorAbstractBase.
53 * Here it registers the node Type
58 Node.NodeIDType.registerIDType("OVS", String.class);
59 NodeConnector.NodeConnectorIDType.registerIDType("OVS", String.class, "OVS");
63 * Function called when the activator stops just before the cleanup done by
64 * ComponentActivatorAbstractBase
68 public void destroy() {
69 Node.NodeIDType.unRegisterIDType("OVS");
70 NodeConnector.NodeConnectorIDType.unRegisterIDType("OVS");
73 public Object[] getGlobalImplementations() {
74 Object[] res = { ConnectionServiceImpl.class, ConfigurationServiceImpl.class, NodeFactory.class, NodeConnectorFactory.class, InventoryServiceImpl.class };
79 public void configureGlobalInstance(Component c, Object imp){
80 if (imp.equals(ConfigurationServiceImpl.class)) {
81 // export the service to be used by SAL
82 Dictionary<String, Object> props = new Hashtable<String, Object>();
83 // Set the protocolPluginType property which will be used
85 props.put(GlobalConstants.PROTOCOLPLUGINTYPE.toString(), "OVS");
86 c.setInterface(new String[] { OvsdbConfigurationService.class.getName()}, props);
88 c.add(createServiceDependency()
89 .setService(OvsdbConnectionService.class)
91 c.add(createServiceDependency()
92 .setService(OvsdbInventoryService.class)
94 c.add(createServiceDependency()
95 .setService(IClusterGlobalServices.class)
96 .setCallbacks("setClusterServices", "unsetClusterServices")
100 if (imp.equals(ConnectionServiceImpl.class)) {
101 // export the service to be used by SAL
102 Dictionary<String, Object> props = new Hashtable<String, Object>();
103 // Set the protocolPluginType property which will be used
105 props.put(GlobalConstants.PROTOCOLPLUGINTYPE.toString(), "OVS");
107 new String[] {IPluginInConnectionService.class.getName(),
108 OvsdbConnectionService.class.getName(),
109 OvsdbConnectionListener.class.getName()}, props);
110 c.add(createServiceDependency()
111 .setService(OvsdbInventoryService.class)
113 c.add(createServiceDependency()
114 .setService(OvsdbConnection.class)
118 if (imp.equals(InventoryServiceImpl.class)) {
119 Dictionary<String, Object> props = new Hashtable<>();
120 props.put(GlobalConstants.PROTOCOLPLUGINTYPE.toString(), "OVS");
121 props.put("scope", "Global");
123 new String[]{IPluginInInventoryService.class.getName(),
124 OvsdbInventoryService.class.getName()}, props);
125 c.add(createServiceDependency()
126 .setService(IPluginOutInventoryService.class, "(scope=Global)")
127 .setCallbacks("setPluginOutInventoryServices",
128 "unsetPluginOutInventoryServices")
130 c.add(createServiceDependency()
131 .setService(OvsdbInventoryListener.class)
132 .setCallbacks("listenerAdded", "listenerRemoved"));
133 c.add(createServiceDependency()
134 .setService(OvsdbConfigurationService.class)
135 .setRequired(false));
138 if (imp.equals(NodeFactory.class)) {
139 // export the service to be used by SAL
140 Dictionary<String, Object> props = new Hashtable<String, Object>();
141 // Set the protocolPluginType property which will be used
143 props.put(GlobalConstants.PROTOCOLPLUGINTYPE.toString(), "OVS");
144 props.put("protocolName", "OVS");
145 c.setInterface(INodeFactory.class.getName(), props);
147 if (imp.equals(NodeConnectorFactory.class)) {
148 // export the service to be used by SAL
149 Dictionary<String, Object> props = new Hashtable<String, Object>();
150 // Set the protocolPluginType property which will be used
152 props.put(GlobalConstants.PROTOCOLPLUGINTYPE.toString(), "OVS");
153 props.put("protocolName", "OVS");
154 c.setInterface(INodeConnectorFactory.class.getName(), props);