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