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.apache.felix.dm.Component;
12 import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
13 import org.opendaylight.controller.sal.flowprogrammer.IFlowProgrammerListener;
14 import org.opendaylight.controller.sal.flowprogrammer.IFlowProgrammerService;
15 import org.opendaylight.controller.sal.flowprogrammer.IPluginInFlowProgrammerService;
16 import org.opendaylight.controller.sal.flowprogrammer.IPluginOutFlowProgrammerService;
17 import org.opendaylight.controller.sal.inventory.IInventoryService;
18 import org.opendaylight.controller.sal.inventory.IListenInventoryUpdates;
19 import org.opendaylight.controller.sal.inventory.IPluginInInventoryService;
20 import org.opendaylight.controller.sal.inventory.IPluginOutInventoryService;
21 import org.opendaylight.controller.sal.packet.IDataPacketService;
22 import org.opendaylight.controller.sal.packet.IListenDataPacket;
23 import org.opendaylight.controller.sal.packet.IPluginInDataPacketService;
24 import org.opendaylight.controller.sal.packet.IPluginOutDataPacketService;
25 import org.opendaylight.controller.sal.reader.IPluginInReadService;
26 import org.opendaylight.controller.sal.reader.IPluginOutReadService;
27 import org.opendaylight.controller.sal.reader.IReadService;
28 import org.opendaylight.controller.sal.reader.IReadServiceListener;
29 import org.opendaylight.controller.sal.topology.IListenTopoUpdates;
30 import org.opendaylight.controller.sal.topology.IPluginInTopologyService;
31 import org.opendaylight.controller.sal.topology.IPluginOutTopologyService;
32 import org.opendaylight.controller.sal.topology.ITopologyService;
33 import org.slf4j.Logger;
34 import org.slf4j.LoggerFactory;
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.
51 * Function called when the activator stops just before the cleanup done by
52 * ComponentActivatorAbstractBase
56 public void destroy() {
61 * Function that is used to communicate to dependency manager the list of
62 * known implementations for services inside a container
65 * @return An array containing all the CLASS objects that will be
66 * instantiated in order to get an fully working implementation
70 public Object[] getImplementations() {
71 Object[] res = { Topology.class, Inventory.class,
72 FlowProgrammerService.class, ReadService.class,
73 DataPacketService.class };
78 * Function that is called when configuration of the dependencies is
82 * dependency manager Component object, used for configuring the
83 * dependencies exported and imported
85 * Implementation class that is being configured, needed as long
86 * as the same routine can configure multiple implementations
87 * @param containerName
88 * The containerName being configured, this allow also optional
89 * per-container different behavior if needed, usually should not
93 public void configureInstance(Component c, Object imp, String containerName) {
94 if (imp.equals(Topology.class)) {
95 // export the service for Apps and Plugins
97 new String[] { IPluginOutTopologyService.class.getName(),
98 ITopologyService.class.getName() }, null);
100 // There can be multiple Topology listeners or there could
101 // be none, hence the dependency is optional
102 c.add(createContainerServiceDependency(containerName)
103 .setService(IListenTopoUpdates.class)
104 .setCallbacks("setUpdateService", "unsetUpdateService")
105 .setRequired(false));
107 // There can be multiple southbound plugins or there could
108 // be none, the dependency is optional
109 c.add(createContainerServiceDependency(containerName)
110 .setService(IPluginInTopologyService.class)
111 .setCallbacks("setPluginService", "unsetPluginService")
112 .setRequired(false));
115 if (imp.equals(Inventory.class)) {
116 // export the service
118 new String[] { IPluginOutInventoryService.class.getName(),
119 IInventoryService.class.getName() }, null);
121 // Now lets add a service dependency to make sure the
122 // provider of service exists
123 c.add(createContainerServiceDependency(containerName)
124 .setService(IListenInventoryUpdates.class)
125 .setCallbacks("setUpdateService", "unsetUpdateService")
126 .setRequired(false));
127 c.add(createContainerServiceDependency(containerName)
128 .setService(IPluginInInventoryService.class)
129 .setCallbacks("setPluginService", "unsetPluginService")
130 .setRequired(false));
133 if (imp.equals(FlowProgrammerService.class)) {
135 new String[] { IFlowProgrammerService.class.getName(),
136 IPluginOutFlowProgrammerService.class.getName() },
139 c.add(createServiceDependency()
140 .setService(IPluginInFlowProgrammerService.class)
141 .setCallbacks("setService", "unsetService")
142 .setRequired(false));
143 c.add(createContainerServiceDependency(containerName)
144 .setService(IFlowProgrammerListener.class)
145 .setCallbacks("setListener", "unsetListener")
146 .setRequired(false));
149 if (imp.equals(ReadService.class)) {
151 c.setInterface(new String[] {
152 IReadService.class.getName(),IPluginOutReadService.class.getName()}, null);
154 // It is also the consumer of IPluginInReadService
155 c.add(createContainerServiceDependency(containerName)
156 .setService(IPluginInReadService.class)
157 .setCallbacks("setService", "unsetService")
158 .setRequired(false));
160 //consumes plugins' reader updates
161 c.add(createContainerServiceDependency(containerName)
162 .setService(IReadServiceListener.class)
163 .setCallbacks("setReaderListener", "unsetReaderListener")
164 .setRequired(false));
168 /************************/
169 /* DATA PACKET SERVICES */
170 /************************/
171 if (imp.equals(DataPacketService.class)) {
173 new String[] { IPluginOutDataPacketService.class.getName(),
174 IDataPacketService.class.getName() }, null);
176 // Optionally use PluginInDataService if any southbound
177 // protocol plugin exists
178 c.add(createContainerServiceDependency(containerName)
179 .setService(IPluginInDataPacketService.class)
180 .setCallbacks("setPluginInDataService",
181 "unsetPluginInDataService").setRequired(false));
183 // Optionally listed to IListenDataPacket services
184 c.add(createContainerServiceDependency(containerName)
185 .setService(IListenDataPacket.class)
186 .setCallbacks("setListenDataPacket",
187 "unsetListenDataPacket").setRequired(false));