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 org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
12 import org.opendaylight.controller.sal.flowprogrammer.IFlowProgrammerListener;
13 import org.opendaylight.controller.sal.flowprogrammer.IFlowProgrammerService;
14 import org.opendaylight.controller.sal.flowprogrammer.IPluginInFlowProgrammerService;
15 import org.opendaylight.controller.sal.flowprogrammer.IPluginOutFlowProgrammerService;
16 import org.opendaylight.controller.sal.inventory.IInventoryService;
17 import org.opendaylight.controller.sal.inventory.IListenInventoryUpdates;
18 import org.opendaylight.controller.sal.inventory.IPluginInInventoryService;
19 import org.opendaylight.controller.sal.inventory.IPluginOutInventoryService;
20 import org.opendaylight.controller.sal.packet.IDataPacketService;
21 import org.opendaylight.controller.sal.packet.IListenDataPacket;
22 import org.opendaylight.controller.sal.packet.IPluginInDataPacketService;
23 import org.opendaylight.controller.sal.packet.IPluginOutDataPacketService;
24 import org.opendaylight.controller.sal.reader.IPluginInReadService;
25 import org.opendaylight.controller.sal.reader.IReadService;
26 import org.opendaylight.controller.sal.topology.IListenTopoUpdates;
27 import org.opendaylight.controller.sal.topology.IPluginInTopologyService;
28 import org.opendaylight.controller.sal.topology.IPluginOutTopologyService;
29 import org.opendaylight.controller.sal.topology.ITopologyService;
30 import org.slf4j.Logger;
31 import org.slf4j.LoggerFactory;
32 import org.apache.felix.dm.Component;
34 public class Activator extends ComponentActivatorAbstractBase {
35 protected static final Logger logger = LoggerFactory
36 .getLogger(Activator.class);
39 * Function called when the activator starts just after some initializations
40 * are done by the ComponentActivatorAbstractBase.
48 * Function called when the activator stops just before the cleanup done by
49 * ComponentActivatorAbstractBase
52 public void destroy() {
57 * Function that is used to communicate to dependency manager the list of
58 * known implementations for services inside a container
61 * @return An array containing all the CLASS objects that will be
62 * instantiated in order to get an fully working implementation
65 public Object[] getImplementations() {
66 Object[] res = { Topology.class, Inventory.class,
67 FlowProgrammerService.class, ReadService.class,
68 DataPacketService.class };
73 * Function that is called when configuration of the dependencies is
77 * dependency manager Component object, used for configuring the
78 * dependencies exported and imported
80 * Implementation class that is being configured, needed as long
81 * as the same routine can configure multiple implementations
82 * @param containerName
83 * The containerName being configured, this allow also optional
84 * per-container different behavior if needed, usually should not
87 public void configureInstance(Component c, Object imp, String containerName) {
88 if (imp.equals(Topology.class)) {
89 // export the service for Apps and Plugins
91 new String[] { IPluginOutTopologyService.class.getName(),
92 ITopologyService.class.getName() }, null);
94 // There can be multiple Topology listeners or there could
95 // be none, hence the dependency is optional
96 c.add(createContainerServiceDependency(containerName)
97 .setService(IListenTopoUpdates.class)
98 .setCallbacks("setUpdateService", "unsetUpdateService")
101 // There can be multiple southbound plugins or there could
102 // be none, the dependency is optional
103 c.add(createContainerServiceDependency(containerName)
104 .setService(IPluginInTopologyService.class)
105 .setCallbacks("setPluginService", "unsetPluginService")
106 .setRequired(false));
109 if (imp.equals(Inventory.class)) {
110 // export the service
112 new String[] { IPluginOutInventoryService.class.getName(),
113 IInventoryService.class.getName() }, null);
115 // Now lets add a service dependency to make sure the
116 // provider of service exists
117 c.add(createContainerServiceDependency(containerName)
118 .setService(IListenInventoryUpdates.class)
119 .setCallbacks("setUpdateService", "unsetUpdateService")
120 .setRequired(false));
121 c.add(createContainerServiceDependency(containerName)
122 .setService(IPluginInInventoryService.class)
123 .setCallbacks("setPluginService", "unsetPluginService")
127 if (imp.equals(FlowProgrammerService.class)) {
129 new String[] { IFlowProgrammerService.class.getName(),
130 IPluginOutFlowProgrammerService.class.getName() },
133 c.add(createServiceDependency()
134 .setService(IPluginInFlowProgrammerService.class)
135 .setCallbacks("setService", "unsetService")
136 .setRequired(false));
137 c.add(createServiceDependency()
138 .setService(IFlowProgrammerListener.class)
139 .setCallbacks("setListener", "unsetListener")
140 .setRequired(false));
143 if (imp.equals(ReadService.class)) {
144 // It is the provider of IReadService
145 c.setInterface(IReadService.class.getName(), null);
147 // It is also the consumer of IPluginInReadService
148 c.add(createContainerServiceDependency(containerName)
149 .setService(IPluginInReadService.class)
150 .setCallbacks("setService", "unsetService")
154 /************************/
155 /* DATA PACKET SERVICES */
156 /************************/
157 if (imp.equals(DataPacketService.class)) {
159 new String[] { IPluginOutDataPacketService.class.getName(),
160 IDataPacketService.class.getName() }, null);
162 // Optionally use PluginInDataService if any southbound
163 // protocol plugin exists
164 c.add(createContainerServiceDependency(containerName)
165 .setService(IPluginInDataPacketService.class)
166 .setCallbacks("setPluginInDataService",
167 "unsetPluginInDataService").setRequired(false));
169 // Optionally listed to IListenDataPacket services
170 c.add(createContainerServiceDependency(containerName)
171 .setService(IListenDataPacket.class)
172 .setCallbacks("setListenDataPacket",
173 "unsetListenDataPacket").setRequired(false));