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
12 package org.opendaylight.controller.protocol_plugins.stub.internal;
14 import org.apache.felix.dm.Component;
15 import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
16 import org.opendaylight.controller.sal.core.Node;
17 import org.opendaylight.controller.sal.core.NodeConnector;
18 import org.opendaylight.controller.sal.flowprogrammer.IPluginInFlowProgrammerService;
19 import org.opendaylight.controller.sal.inventory.IPluginInInventoryService;
20 import org.opendaylight.controller.sal.inventory.IPluginOutInventoryService;
21 import org.opendaylight.controller.sal.reader.IPluginInReadService;
22 import org.opendaylight.controller.sal.topology.IPluginInTopologyService;
23 import org.opendaylight.controller.sal.topology.IPluginOutTopologyService;
24 import org.opendaylight.controller.sal.utils.GlobalConstants;
25 import org.opendaylight.controller.sal.utils.INodeConnectorFactory;
26 import org.opendaylight.controller.sal.utils.INodeFactory;
27 import org.slf4j.Logger;
28 import org.slf4j.LoggerFactory;
30 import java.util.Dictionary;
31 import java.util.Hashtable;
34 * stub protocol plugin Activator
38 public class Activator extends ComponentActivatorAbstractBase {
39 protected static final Logger logger = LoggerFactory
40 .getLogger(Activator.class);
43 * Function called when the activator starts just after some initializations
44 * are done by the ComponentActivatorAbstractBase.
49 Node.NodeIDType.registerIDType("STUB", Integer.class);
50 NodeConnector.NodeConnectorIDType.registerIDType("STUB", Integer.class, "STUB");
54 * Function called when the activator stops just before the cleanup done by
55 * ComponentActivatorAbstractBase
59 public void destroy() {
60 Node.NodeIDType.unRegisterIDType("STUB");
61 NodeConnector.NodeConnectorIDType.unRegisterIDType("STUB");
65 * Function that is used to communicate to dependency manager the list of
66 * known implementations for services inside a container
69 * @return An array containing all the CLASS objects that will be
70 * instantiated in order to get an fully working implementation
74 public Object[] getImplementations() {
75 Object[] res = { ReadService.class, InventoryService.class, TopologyServices.class };
80 * Function that is called when configuration of the dependencies is
84 * dependency manager Component object, used for configuring the
85 * dependencies exported and imported
87 * Implementation class that is being configured, needed as long
88 * as the same routine can configure multiple implementations
89 * @param containerName
90 * The containerName being configured, this allow also optional
91 * per-container different behavior if needed, usually should not
95 public void configureInstance(Component c, Object imp, String containerName) {
96 if (imp.equals(ReadService.class)) {
97 // export the service to be used by SAL
98 Dictionary<String, Object> props = new Hashtable<String, Object>();
99 // Set the protocolPluginType property which will be used
101 props.put(GlobalConstants.PROTOCOLPLUGINTYPE.toString(), "STUB");
102 c.setInterface(IPluginInReadService.class.getName(), props);
105 if (imp.equals(InventoryService.class)) {
106 // export the service to be used by SAL
107 Dictionary<String, Object> props = new Hashtable<String, Object>();
108 // Set the protocolPluginType property which will be used
110 props.put(GlobalConstants.PROTOCOLPLUGINTYPE.toString(), "STUB");
111 c.setInterface(IPluginInInventoryService.class.getName(), props);
114 if(imp.equals(TopologyServices.class)){
115 Dictionary<String, Object> props = new Hashtable<String, Object>();
116 props.put(GlobalConstants.PROTOCOLPLUGINTYPE.toString(), "STUB");
117 c.setInterface(IPluginInTopologyService.class.getName(), props);
118 c.add(createServiceDependency().setService(IPluginOutTopologyService.class, "")
119 .setCallbacks("setPluginOutTopologyService", "unsetPluginOutTopologyService")
127 public Object[] getGlobalImplementations() {
130 FlowProgrammerService.class,
131 StubNodeFactory.class,
132 StubNodeConnectorFactory.class,
133 InventoryService.class
139 public void configureGlobalInstance(Component c, Object imp){
140 if (imp.equals(FlowProgrammerService.class)) {
141 // export the service to be used by SAL
142 Dictionary<String, Object> props = new Hashtable<String, Object>();
143 // Set the protocolPluginType property which will be used
145 props.put(GlobalConstants.PROTOCOLPLUGINTYPE.toString(), "STUB");
146 c.setInterface(IPluginInFlowProgrammerService.class.getName(), props);
148 if (imp.equals(StubNodeFactory.class)) {
149 // export the service to be used by SAL
150 Dictionary<String, Object> props = new Hashtable<String, Object>();
151 // Set the protocolPluginType property which will be used
153 props.put(GlobalConstants.PROTOCOLPLUGINTYPE.toString(), "STUB");
154 props.put("protocolName", "STUB");
155 c.setInterface(INodeFactory.class.getName(), props);
157 if (imp.equals(StubNodeConnectorFactory.class)) {
158 // export the service to be used by SAL
159 Dictionary<String, Object> props = new Hashtable<String, Object>();
160 // Set the protocolPluginType property which will be used
162 props.put(GlobalConstants.PROTOCOLPLUGINTYPE.toString(), "STUB");
163 props.put("protocolName", "STUB");
164 c.setInterface(INodeConnectorFactory.class.getName(), props);
166 if (imp.equals(InventoryService.class)) {
167 // export the service to be used by SAL
168 Dictionary<String, Object> props = new Hashtable<String, Object>();
169 // Set the protocolPluginType property which will be used
171 props.put(GlobalConstants.PROTOCOLPLUGINTYPE.toString(), "STUB");
172 props.put("scope", "Global");
173 c.setInterface(IPluginInInventoryService.class.getName(), props);
174 c.add(createServiceDependency().setService(IPluginOutInventoryService.class, "(scope=Global)")
175 .setCallbacks("setPluginOutInventoryServices", "unsetPluginOutInventoryServices")