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.hosttracker.internal;
11 import org.apache.felix.dm.Component;
12 import org.opendaylight.controller.clustering.services.IClusterContainerServices;
13 import org.opendaylight.controller.hosttracker.IfHostListener;
14 import org.opendaylight.controller.hosttracker.IfIptoHost;
15 import org.opendaylight.controller.hosttracker.IfNewHostNotify;
16 import org.opendaylight.controller.hosttracker.hostAware.IHostFinder;
17 import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
18 import org.opendaylight.controller.switchmanager.IInventoryListener;
19 import org.opendaylight.controller.switchmanager.ISwitchManager;
20 import org.opendaylight.controller.switchmanager.ISwitchManagerAware;
21 import org.opendaylight.controller.topologymanager.ITopologyManager;
22 import org.opendaylight.controller.topologymanager.ITopologyManagerAware;
23 import org.slf4j.Logger;
24 import org.slf4j.LoggerFactory;
26 public class Activator extends ComponentActivatorAbstractBase {
27 protected static final Logger logger = LoggerFactory
28 .getLogger(Activator.class);
31 * Function called when the activator starts just after some initializations
32 * are done by the ComponentActivatorAbstractBase.
39 * Function called when the activator stops just before the cleanup done by
40 * ComponentActivatorAbstractBase
43 public void destroy() {
47 * Function that is used to communicate to dependency manager the list of
48 * known implementations for services inside a container
51 * @return An array containing all the CLASS objects that will be
52 * instantiated in order to get an fully working implementation
55 public Object[] getImplementations() {
56 Object[] res = { HostTracker.class };
61 * Function that is called when configuration of the dependencies is
65 * dependency manager Component object, used for configuring the
66 * dependencies exported and imported
68 * Implementation class that is being configured, needed as long
69 * as the same routine can configure multiple implementations
70 * @param containerName
71 * The containerName being configured, this allow also optional
72 * per-container different behavior if needed, usually should not
75 public void configureInstance(Component c, Object imp, String containerName) {
76 if (imp.equals(HostTracker.class)) {
79 new String[] { ISwitchManagerAware.class.getName(),
80 IInventoryListener.class.getName(),
81 IfIptoHost.class.getName(),
82 IfHostListener.class.getName(),
83 ITopologyManagerAware.class.getName() }, null);
85 c.add(createContainerServiceDependency(containerName)
86 .setService(ISwitchManager.class)
87 .setCallbacks("setSwitchManager", "unsetSwitchManager")
89 c.add(createContainerServiceDependency(containerName)
90 .setService(IClusterContainerServices.class)
91 .setCallbacks("setClusterContainerService",
92 "unsetClusterContainerService").setRequired(true));
93 c.add(createContainerServiceDependency(containerName)
94 .setService(IHostFinder.class)
95 .setCallbacks("setArpHandler", "unsetArpHandler")
97 c.add(createContainerServiceDependency(containerName)
98 .setService(ITopologyManager.class)
99 .setCallbacks("setTopologyManager", "unsetTopologyManager")
100 .setRequired(false));
101 c.add(createContainerServiceDependency(containerName)
102 .setService(IfNewHostNotify.class)
103 .setCallbacks("setnewHostNotify", "unsetnewHostNotify")
104 .setRequired(false));
109 * Method which tells how many Global implementations are supported by the
110 * bundle. This way we can tune the number of components created. This
111 * components will be created ONLY at the time of bundle startup and will be
112 * destroyed only at time of bundle destruction, this is the major
113 * difference with the implementation retrieved via getImplementations where
114 * all of them are assumed to be in a container !
117 * @return The list of implementations the bundle will support, in Global
120 protected Object[] getGlobalImplementations() {
125 * Configure the dependency for a given instance Global
128 * Component assigned for this instance, this will be what will
129 * be used for configuration
131 * implementation to be configured
132 * @param containerName
133 * container on which the configuration happens
135 protected void configureGlobalInstance(Component c, Object imp) {
136 if (imp.equals(HostTracker.class)) {