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;
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.networkconfig.bridgedomain.IPluginInBridgeDomainConfigService;
24 import org.opendaylight.controller.sal.utils.GlobalConstants;
25 import org.opendaylight.controller.sal.utils.INodeConnectorFactory;
26 import org.opendaylight.controller.sal.utils.INodeFactory;
27 import org.opendaylight.ovsdb.lib.OvsdbConnection;
28 import org.slf4j.Logger;
29 import org.slf4j.LoggerFactory;
32 * OVSDB protocol plugin Activator
36 public class Activator extends ComponentActivatorAbstractBase {
37 protected static final Logger logger = LoggerFactory
38 .getLogger(Activator.class);
41 * Function called when the activator starts just after some initializations
42 * are done by the ComponentActivatorAbstractBase.
43 * Here it registers the node Type
48 Node.NodeIDType.registerIDType("OVS", String.class);
49 NodeConnector.NodeConnectorIDType.registerIDType("OVS", String.class, "OVS");
53 * Function called when the activator stops just before the cleanup done by
54 * ComponentActivatorAbstractBase
58 public void destroy() {
59 Node.NodeIDType.unRegisterIDType("OVS");
60 NodeConnector.NodeConnectorIDType.unRegisterIDType("OVS");
63 public Object[] getGlobalImplementations() {
64 Object[] res = { ConnectionService.class, ConfigurationService.class, NodeFactory.class, NodeConnectorFactory.class, InventoryService.class };
69 public void configureGlobalInstance(Component c, Object imp){
70 if (imp.equals(ConfigurationService.class)) {
71 // export the service to be used by SAL
72 Dictionary<String, Object> props = new Hashtable<String, Object>();
73 // Set the protocolPluginType property which will be used
75 props.put(GlobalConstants.PROTOCOLPLUGINTYPE.toString(), "OVS");
76 c.setInterface(new String[] { IPluginInBridgeDomainConfigService.class.getName(),
77 OVSDBConfigService.class.getName()}, props);
79 c.add(createServiceDependency()
80 .setService(IConnectionServiceInternal.class)
81 .setCallbacks("setConnectionServiceInternal", "unsetConnectionServiceInternal")
83 c.add(createServiceDependency()
84 .setService(InventoryServiceInternal.class)
85 .setCallbacks("setInventoryServiceInternal", "unsetInventoryServiceInternal")
89 if (imp.equals(ConnectionService.class)) {
90 // export the service to be used by SAL
91 Dictionary<String, Object> props = new Hashtable<String, Object>();
92 // Set the protocolPluginType property which will be used
94 props.put(GlobalConstants.PROTOCOLPLUGINTYPE.toString(), "OVS");
96 new String[] {IPluginInConnectionService.class.getName(),
97 IConnectionServiceInternal.class.getName()}, props);
99 c.add(createServiceDependency()
100 .setService(InventoryServiceInternal.class)
101 .setCallbacks("setInventoryServiceInternal", "unsetInventoryServiceInternal")
103 c.add(createServiceDependency()
104 .setService(IClusterGlobalServices.class)
105 .setCallbacks("setClusterServices", "unsetClusterServices")
106 .setRequired(false));
107 c.add(createServiceDependency()
108 .setService(OvsdbConnection.class)
109 .setCallbacks("setOvsdbConnection", "unsetOvsdbConnection")
113 if (imp.equals(InventoryService.class)) {
114 Dictionary<String, Object> props = new Hashtable<String, Object>();
115 props.put(GlobalConstants.PROTOCOLPLUGINTYPE.toString(), "OVS");
117 new String[] {IPluginInInventoryService.class.getName(),
118 InventoryServiceInternal.class.getName()}, props);
119 c.add(createServiceDependency()
120 .setService(IPluginOutInventoryService.class, "(scope=Global)")
121 .setCallbacks("setPluginOutInventoryServices",
122 "unsetPluginOutInventoryServices")
126 if (imp.equals(NodeFactory.class)) {
127 // export the service to be used by SAL
128 Dictionary<String, Object> props = new Hashtable<String, Object>();
129 // Set the protocolPluginType property which will be used
131 props.put(GlobalConstants.PROTOCOLPLUGINTYPE.toString(), "OVS");
132 props.put("protocolName", "OVS");
133 c.setInterface(INodeFactory.class.getName(), props);
135 if (imp.equals(NodeConnectorFactory.class)) {
136 // export the service to be used by SAL
137 Dictionary<String, Object> props = new Hashtable<String, Object>();
138 // Set the protocolPluginType property which will be used
140 props.put(GlobalConstants.PROTOCOLPLUGINTYPE.toString(), "OVS");
141 props.put("protocolName", "OVS");
142 c.setInterface(INodeConnectorFactory.class.getName(), props);