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.
49 * Function called when the activator stops just before the cleanup done by
50 * ComponentActivatorAbstractBase
54 public void destroy() {
59 * Function that is used to communicate to dependency manager the list of
60 * known implementations for services inside a container
63 * @return An array containing all the CLASS objects that will be
64 * instantiated in order to get an fully working implementation
68 public Object[] getImplementations() {
69 Object[] res = { Topology.class, Inventory.class,
70 FlowProgrammerService.class, ReadService.class,
71 DataPacketService.class };
76 * Function that is called when configuration of the dependencies is
80 * dependency manager Component object, used for configuring the
81 * dependencies exported and imported
83 * Implementation class that is being configured, needed as long
84 * as the same routine can configure multiple implementations
85 * @param containerName
86 * The containerName being configured, this allow also optional
87 * per-container different behavior if needed, usually should not
91 public void configureInstance(Component c, Object imp, String containerName) {
92 if (imp.equals(Topology.class)) {
93 // export the service for Apps and Plugins
95 new String[] { IPluginOutTopologyService.class.getName(),
96 ITopologyService.class.getName() }, null);
98 // There can be multiple Topology listeners or there could
99 // be none, hence the dependency is optional
100 c.add(createContainerServiceDependency(containerName)
101 .setService(IListenTopoUpdates.class)
102 .setCallbacks("setUpdateService", "unsetUpdateService")
103 .setRequired(false));
105 // There can be multiple southbound plugins or there could
106 // be none, the dependency is optional
107 c.add(createContainerServiceDependency(containerName)
108 .setService(IPluginInTopologyService.class)
109 .setCallbacks("setPluginService", "unsetPluginService")
110 .setRequired(false));
113 if (imp.equals(Inventory.class)) {
114 // export the service
116 new String[] { IPluginOutInventoryService.class.getName(),
117 IInventoryService.class.getName() }, null);
119 // Now lets add a service dependency to make sure the
120 // provider of service exists
121 c.add(createContainerServiceDependency(containerName)
122 .setService(IListenInventoryUpdates.class)
123 .setCallbacks("setUpdateService", "unsetUpdateService")
124 .setRequired(false));
125 c.add(createContainerServiceDependency(containerName)
126 .setService(IPluginInInventoryService.class)
127 .setCallbacks("setPluginService", "unsetPluginService")
131 if (imp.equals(FlowProgrammerService.class)) {
133 new String[] { IFlowProgrammerService.class.getName(),
134 IPluginOutFlowProgrammerService.class.getName() },
137 c.add(createServiceDependency()
138 .setService(IPluginInFlowProgrammerService.class)
139 .setCallbacks("setService", "unsetService")
140 .setRequired(false));
141 c.add(createServiceDependency()
142 .setService(IFlowProgrammerListener.class)
143 .setCallbacks("setListener", "unsetListener")
144 .setRequired(false));
147 if (imp.equals(ReadService.class)) {
148 // It is the provider of IReadService
149 c.setInterface(IReadService.class.getName(), null);
151 // It is also the consumer of IPluginInReadService
152 c.add(createContainerServiceDependency(containerName)
153 .setService(IPluginInReadService.class)
154 .setCallbacks("setService", "unsetService")
158 /************************/
159 /* DATA PACKET SERVICES */
160 /************************/
161 if (imp.equals(DataPacketService.class)) {
163 new String[] { IPluginOutDataPacketService.class.getName(),
164 IDataPacketService.class.getName() }, null);
166 // Optionally use PluginInDataService if any southbound
167 // protocol plugin exists
168 c.add(createContainerServiceDependency(containerName)
169 .setService(IPluginInDataPacketService.class)
170 .setCallbacks("setPluginInDataService",
171 "unsetPluginInDataService").setRequired(false));
173 // Optionally listed to IListenDataPacket services
174 c.add(createContainerServiceDependency(containerName)
175 .setService(IListenDataPacket.class)
176 .setCallbacks("setListenDataPacket",
177 "unsetListenDataPacket").setRequired(false));