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.slf4j.Logger;
28 import org.slf4j.LoggerFactory;
31 * OVSDB protocol plugin Activator
35 public class Activator extends ComponentActivatorAbstractBase {
36 protected static final Logger logger = LoggerFactory
37 .getLogger(Activator.class);
40 * Function called when the activator starts just after some initializations
41 * are done by the ComponentActivatorAbstractBase.
42 * Here it registers the node Type
47 Node.NodeIDType.registerIDType("OVS", String.class);
48 NodeConnector.NodeConnectorIDType.registerIDType("OVS", String.class, "OVS");
52 * Function called when the activator stops just before the cleanup done by
53 * ComponentActivatorAbstractBase
57 public void destroy() {
58 Node.NodeIDType.unRegisterIDType("OVS");
59 NodeConnector.NodeConnectorIDType.unRegisterIDType("OVS");
62 public Object[] getGlobalImplementations() {
63 Object[] res = { ConnectionService.class, ConfigurationService.class, NodeFactory.class, NodeConnectorFactory.class, InventoryService.class };
68 public void configureGlobalInstance(Component c, Object imp){
69 if (imp.equals(ConfigurationService.class)) {
70 // export the service to be used by SAL
71 Dictionary<String, Object> props = new Hashtable<String, Object>();
72 // Set the protocolPluginType property which will be used
74 props.put(GlobalConstants.PROTOCOLPLUGINTYPE.toString(), "OVS");
75 c.setInterface(new String[] { IPluginInBridgeDomainConfigService.class.getName(),
76 OVSDBConfigService.class.getName()}, props);
78 c.add(createServiceDependency()
79 .setService(IConnectionServiceInternal.class)
80 .setCallbacks("setConnectionServiceInternal", "unsetConnectionServiceInternal")
82 c.add(createServiceDependency()
83 .setService(InventoryServiceInternal.class)
84 .setCallbacks("setInventoryServiceInternal", "unsetInventoryServiceInternal")
88 if (imp.equals(ConnectionService.class)) {
89 // export the service to be used by SAL
90 Dictionary<String, Object> props = new Hashtable<String, Object>();
91 // Set the protocolPluginType property which will be used
93 props.put(GlobalConstants.PROTOCOLPLUGINTYPE.toString(), "OVS");
95 new String[] {IPluginInConnectionService.class.getName(),
96 IConnectionServiceInternal.class.getName()}, props);
97 c.add(createServiceDependency()
98 .setService(InventoryServiceInternal.class)
99 .setCallbacks("setInventoryServiceInternal", "unsetInventoryServiceInternal")
101 c.add(createServiceDependency()
102 .setService(IClusterGlobalServices.class)
103 .setCallbacks("setClusterServices", "unsetClusterServices")
104 .setRequired(false));
107 if (imp.equals(InventoryService.class)) {
108 Dictionary<String, Object> props = new Hashtable<String, Object>();
109 props.put(GlobalConstants.PROTOCOLPLUGINTYPE.toString(), "OVS");
111 new String[] {IPluginInInventoryService.class.getName(),
112 InventoryServiceInternal.class.getName()}, props);
113 c.add(createServiceDependency()
114 .setService(IPluginOutInventoryService.class, "(scope=Global)")
115 .setCallbacks("setPluginOutInventoryServices",
116 "unsetPluginOutInventoryServices")
120 if (imp.equals(NodeFactory.class)) {
121 // export the service to be used by SAL
122 Dictionary<String, Object> props = new Hashtable<String, Object>();
123 // Set the protocolPluginType property which will be used
125 props.put(GlobalConstants.PROTOCOLPLUGINTYPE.toString(), "OVS");
126 props.put("protocolName", "OVS");
127 c.setInterface(INodeFactory.class.getName(), props);
129 if (imp.equals(NodeConnectorFactory.class)) {
130 // export the service to be used by SAL
131 Dictionary<String, Object> props = new Hashtable<String, Object>();
132 // Set the protocolPluginType property which will be used
134 props.put(GlobalConstants.PROTOCOLPLUGINTYPE.toString(), "OVS");
135 props.put("protocolName", "OVS");
136 c.setInterface(INodeConnectorFactory.class.getName(), props);