2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
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
9 package org.opendaylight.controller.sal.implementation.internal;
11 import java.util.Dictionary;
12 import java.util.Hashtable;
14 import org.apache.felix.dm.Component;
15 import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
16 import org.opendaylight.controller.sal.flowprogrammer.IFlowProgrammerListener;
17 import org.opendaylight.controller.sal.flowprogrammer.IFlowProgrammerService;
18 import org.opendaylight.controller.sal.flowprogrammer.IPluginInFlowProgrammerService;
19 import org.opendaylight.controller.sal.flowprogrammer.IPluginOutFlowProgrammerService;
20 import org.opendaylight.controller.sal.inventory.IInventoryService;
21 import org.opendaylight.controller.sal.inventory.IListenInventoryUpdates;
22 import org.opendaylight.controller.sal.inventory.IPluginInInventoryService;
23 import org.opendaylight.controller.sal.inventory.IPluginOutInventoryService;
24 import org.opendaylight.controller.sal.packet.IDataPacketService;
25 import org.opendaylight.controller.sal.packet.IListenDataPacket;
26 import org.opendaylight.controller.sal.packet.IPluginInDataPacketService;
27 import org.opendaylight.controller.sal.packet.IPluginOutDataPacketService;
28 import org.opendaylight.controller.sal.reader.IPluginInReadService;
29 import org.opendaylight.controller.sal.reader.IPluginOutReadService;
30 import org.opendaylight.controller.sal.reader.IReadService;
31 import org.opendaylight.controller.sal.reader.IReadServiceListener;
32 import org.opendaylight.controller.sal.topology.IListenTopoUpdates;
33 import org.opendaylight.controller.sal.topology.IPluginInTopologyService;
34 import org.opendaylight.controller.sal.topology.IPluginOutTopologyService;
35 import org.opendaylight.controller.sal.topology.ITopologyService;
36 import org.slf4j.Logger;
37 import org.slf4j.LoggerFactory;
39 public class Activator extends ComponentActivatorAbstractBase {
40 protected static final Logger logger = LoggerFactory
41 .getLogger(Activator.class);
45 * Function that is used to communicate to dependency manager the list of
46 * known Global implementations
49 * @return An array containing all the CLASS objects that will be
50 * instantiated in order to get an fully working implementation
53 public Object[] getGlobalImplementations() {
54 Object[] res = { Inventory.class };
59 * Function that is called when configuration of the dependencies is required.
62 * dependency manager Component object, used for configuring the
63 * dependencies exported and imported
65 * Implementation class that is being configured, needed as long
66 * as the same routine can configure multiple implementations
68 public void configureGlobalInstance(Component c, Object imp) {
69 if (imp.equals(Inventory.class)) {
70 Dictionary<String, Object> props = new Hashtable<String, Object>();
71 props.put("scope", "Global");
74 new String[] { IPluginOutInventoryService.class.getName(),
75 IInventoryService.class.getName() }, props);
77 // Now lets add a service dependency to make sure the
78 // provider of service exists
79 c.add(createServiceDependency()
80 .setService(IListenInventoryUpdates.class, "(scope=Global)")
81 .setCallbacks("setUpdateService", "unsetUpdateService")
83 c.add(createServiceDependency()
84 .setService(IPluginInInventoryService.class, "(scope=Global)")
85 .setCallbacks("setPluginService", "unsetPluginService")
91 * Function that is used to communicate to dependency manager the list of
92 * known implementations for services inside a container
95 * @return An array containing all the CLASS objects that will be
96 * instantiated in order to get an fully working implementation
100 public Object[] getImplementations() {
101 Object[] res = { Topology.class, Inventory.class,
102 FlowProgrammerService.class, ReadService.class,
103 DataPacketService.class };
108 * Function that is called when configuration of the dependencies is
112 * dependency manager Component object, used for configuring the
113 * dependencies exported and imported
115 * Implementation class that is being configured, needed as long
116 * as the same routine can configure multiple implementations
117 * @param containerName
118 * The containerName being configured, this allow also optional
119 * per-container different behavior if needed, usually should not
120 * be the case though.
123 public void configureInstance(Component c, Object imp, String containerName) {
124 if (imp.equals(Topology.class)) {
125 // export the service for Apps and Plugins
127 new String[] { IPluginOutTopologyService.class.getName(),
128 ITopologyService.class.getName() }, null);
130 // There can be multiple Topology listeners or there could
131 // be none, hence the dependency is optional
132 c.add(createContainerServiceDependency(containerName)
133 .setService(IListenTopoUpdates.class)
134 .setCallbacks("setUpdateService", "unsetUpdateService")
135 .setRequired(false));
137 // There can be multiple southbound plugins or there could
138 // be none, the dependency is optional
139 c.add(createContainerServiceDependency(containerName)
140 .setService(IPluginInTopologyService.class)
141 .setCallbacks("setPluginService", "unsetPluginService")
142 .setRequired(false));
145 if (imp.equals(Inventory.class)) {
146 // export the service
148 new String[] { IPluginOutInventoryService.class.getName(),
149 IInventoryService.class.getName() }, null);
151 // Now lets add a service dependency to make sure the
152 // provider of service exists
153 c.add(createContainerServiceDependency(containerName)
154 .setService(IListenInventoryUpdates.class)
155 .setCallbacks("setUpdateService", "unsetUpdateService")
156 .setRequired(false));
157 c.add(createContainerServiceDependency(containerName)
158 .setService(IPluginInInventoryService.class)
159 .setCallbacks("setPluginService", "unsetPluginService")
160 .setRequired(false));
163 if (imp.equals(FlowProgrammerService.class)) {
165 new String[] { IFlowProgrammerService.class.getName(),
166 IPluginOutFlowProgrammerService.class.getName() },
169 c.add(createServiceDependency()
170 .setService(IPluginInFlowProgrammerService.class)
171 .setCallbacks("setService", "unsetService")
172 .setRequired(false));
173 c.add(createContainerServiceDependency(containerName)
174 .setService(IFlowProgrammerListener.class)
175 .setCallbacks("setListener", "unsetListener")
176 .setRequired(false));
179 if (imp.equals(ReadService.class)) {
181 c.setInterface(new String[] {
182 IReadService.class.getName(),IPluginOutReadService.class.getName()}, null);
184 // It is also the consumer of IPluginInReadService
185 c.add(createContainerServiceDependency(containerName)
186 .setService(IPluginInReadService.class)
187 .setCallbacks("setService", "unsetService")
188 .setRequired(false));
190 //consumes plugins' reader updates
191 c.add(createContainerServiceDependency(containerName)
192 .setService(IReadServiceListener.class)
193 .setCallbacks("setReaderListener", "unsetReaderListener")
194 .setRequired(false));
198 /************************/
199 /* DATA PACKET SERVICES */
200 /************************/
201 if (imp.equals(DataPacketService.class)) {
203 new String[] { IPluginOutDataPacketService.class.getName(),
204 IDataPacketService.class.getName() }, null);
206 // Optionally use PluginInDataService if any southbound
207 // protocol plugin exists
208 c.add(createContainerServiceDependency(containerName)
209 .setService(IPluginInDataPacketService.class)
210 .setCallbacks("setPluginInDataService",
211 "unsetPluginInDataService").setRequired(false));
213 // Optionally listed to IListenDataPacket services
214 c.add(createContainerServiceDependency(containerName)
215 .setService(IListenDataPacket.class)
216 .setCallbacks("setListenDataPacket",
217 "unsetListenDataPacket").setRequired(false));