3 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
5 * This program and the accompanying materials are made available under the
6 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
7 * and is available at http://www.eclipse.org/legal/epl-v10.html
10 package org.opendaylight.controller.sal.implementation.internal;
12 import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
13 import org.opendaylight.controller.sal.flowprogrammer.IFlowProgrammerService;
14 import org.opendaylight.controller.sal.flowprogrammer.IPluginInFlowProgrammerService;
15 import org.opendaylight.controller.sal.inventory.IInventoryService;
16 import org.opendaylight.controller.sal.inventory.IListenInventoryUpdates;
17 import org.opendaylight.controller.sal.inventory.IPluginInInventoryService;
18 import org.opendaylight.controller.sal.inventory.IPluginOutInventoryService;
19 import org.opendaylight.controller.sal.packet.IDataPacketService;
20 import org.opendaylight.controller.sal.packet.IListenDataPacket;
21 import org.opendaylight.controller.sal.packet.IPluginInDataPacketService;
22 import org.opendaylight.controller.sal.packet.IPluginOutDataPacketService;
23 import org.opendaylight.controller.sal.reader.IPluginInReadService;
24 import org.opendaylight.controller.sal.reader.IReadService;
25 import org.opendaylight.controller.sal.topology.IListenTopoUpdates;
26 import org.opendaylight.controller.sal.topology.IPluginInTopologyService;
27 import org.opendaylight.controller.sal.topology.IPluginOutTopologyService;
28 import org.opendaylight.controller.sal.topology.ITopologyService;
29 import org.slf4j.Logger;
30 import org.slf4j.LoggerFactory;
31 import org.apache.felix.dm.Component;
33 public class Activator extends ComponentActivatorAbstractBase {
34 protected static final Logger logger = LoggerFactory
35 .getLogger(Activator.class);
38 * Function called when the activator starts just after some
39 * initializations are done by the
40 * ComponentActivatorAbstractBase.
48 * Function called when the activator stops just before the
49 * cleanup done by ComponentActivatorAbstractBase
52 public void destroy() {
57 * Function that is used to communicate to dependency manager the
58 * list of 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
76 * @param c dependency manager Component object, used for
77 * configuring the dependencies exported and imported
78 * @param imp Implementation class that is being configured,
79 * needed as long as the same routine can configure multiple
81 * @param containerName The containerName being configured, this allow
82 * also optional per-container different behavior if needed, usually
83 * should not be the case though.
85 public void configureInstance(Component c, Object imp, String containerName) {
86 if (imp.equals(Topology.class)) {
87 // export the service for Apps and Plugins
88 c.setInterface(new String[] {
89 IPluginOutTopologyService.class.getName(),
90 ITopologyService.class.getName() }, null);
92 // There can be multiple Topology listeners or there could
93 // be none, hence the dependency is optional
94 c.add(createContainerServiceDependency(containerName).setService(
95 IListenTopoUpdates.class).setCallbacks("setUpdateService",
96 "unsetUpdateService").setRequired(false));
98 // There can be multiple southbound plugins or there could
99 // be none, the dependency is optional
100 c.add(createContainerServiceDependency(containerName).setService(
101 IPluginInTopologyService.class).setCallbacks(
102 "setPluginService", "unsetPluginService")
103 .setRequired(false));
106 if (imp.equals(Inventory.class)) {
107 // export the service
108 c.setInterface(new String[] {
109 IPluginOutInventoryService.class.getName(),
110 IInventoryService.class.getName() }, null);
112 // Now lets add a service dependency to make sure the
113 // provider of service exists
114 c.add(createContainerServiceDependency(containerName).setService(
115 IListenInventoryUpdates.class).setCallbacks(
116 "setUpdateService", "unsetUpdateService")
117 .setRequired(false));
119 .add(createContainerServiceDependency(containerName)
120 .setService(IPluginInInventoryService.class)
121 .setCallbacks("setPluginService",
122 "unsetPluginService").setRequired(true));
125 if (imp.equals(FlowProgrammerService.class)) {
126 // It is the provider of IFlowProgrammerService
127 c.setInterface(IFlowProgrammerService.class.getName(), null);
128 //It is also the consumer of IPluginInFlowProgrammerService
129 c.add(createServiceDependency().setService(
130 IPluginInFlowProgrammerService.class).setCallbacks(
131 "setService", "unsetService").setRequired(true));
134 if (imp.equals(ReadService.class)) {
135 // It is the provider of IReadService
136 c.setInterface(IReadService.class.getName(), null);
138 //It is also the consumer of IPluginInReadService
139 c.add(createContainerServiceDependency(containerName).setService(
140 IPluginInReadService.class).setCallbacks("setService",
141 "unsetService").setRequired(true));
144 /************************/
145 /* DATA PACKET SERVICES */
146 /************************/
147 if (imp.equals(DataPacketService.class)) {
148 c.setInterface(new String[] {
149 IPluginOutDataPacketService.class.getName(),
150 IDataPacketService.class.getName() }, null);
152 // Optionally use PluginInDataService if any southbound
153 // protocol plugin exists
154 c.add(createContainerServiceDependency(containerName).setService(
155 IPluginInDataPacketService.class).setCallbacks(
156 "setPluginInDataService", "unsetPluginInDataService")
157 .setRequired(false));
159 // Optionally listed to IListenDataPacket services
160 c.add(createContainerServiceDependency(containerName).setService(
161 IListenDataPacket.class).setCallbacks(
162 "setListenDataPacket", "unsetListenDataPacket")
163 .setRequired(false));