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.forwarding.staticrouting.internal;
12 import java.util.Dictionary;
13 import java.util.HashSet;
14 import java.util.Hashtable;
17 import org.apache.felix.dm.Component;
18 import org.opendaylight.controller.forwarding.staticrouting.IForwardingStaticRouting;
19 import org.opendaylight.controller.forwarding.staticrouting.IStaticRoutingAware;
20 import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
21 import org.slf4j.Logger;
22 import org.slf4j.LoggerFactory;
24 import org.opendaylight.controller.clustering.services.ICacheUpdateAware;
25 import org.opendaylight.controller.clustering.services.IClusterContainerServices;
26 import org.opendaylight.controller.configuration.IConfigurationContainerAware;
27 import org.opendaylight.controller.hosttracker.IfIptoHost;
28 import org.opendaylight.controller.hosttracker.IfNewHostNotify;
30 public class Activator extends ComponentActivatorAbstractBase {
31 protected static final Logger logger = LoggerFactory
32 .getLogger(Activator.class);
35 * Function called when the activator starts just after some
36 * initializations are done by the
37 * ComponentActivatorAbstractBase.
45 * Function called when the activator stops just before the
46 * cleanup done by ComponentActivatorAbstractBase
49 public void destroy() {
54 * Function that is used to communicate to dependency manager the
55 * list of known implementations for services inside a container
58 * @return An array containing all the CLASS objects that will be
59 * instantiated in order to get an fully working implementation
62 public Object[] getImplementations() {
63 Object[] res = { StaticRoutingImplementation.class };
68 * Function that is called when configuration of the dependencies
71 * @param c dependency manager Component object, used for
72 * configuring the dependencies exported and imported
73 * @param imp Implementation class that is being configured,
74 * needed as long as the same routine can configure multiple
76 * @param containerName The containerName being configured, this allow
77 * also optional per-container different behavior if needed, usually
78 * should not be the case though.
80 public void configureInstance(Component c, Object imp, String containerName) {
81 if (imp.equals(StaticRoutingImplementation.class)) {
82 Dictionary<String, Set<String>> props = new Hashtable<String, Set<String>>();
83 Set<String> propSet = new HashSet<String>();
84 propSet.add("forwarding.staticrouting.configSaveEvent");
85 props.put("cachenames", propSet);
88 c.setInterface(new String[] { ICacheUpdateAware.class.getName(),
89 IForwardingStaticRouting.class.getName(),
90 IfNewHostNotify.class.getName(),
91 IConfigurationContainerAware.class.getName() }, props);
93 c.add(createContainerServiceDependency(containerName).setService(
94 IClusterContainerServices.class).setCallbacks(
95 "setClusterContainerService",
96 "unsetClusterContainerService").setRequired(true));
98 c.add(createContainerServiceDependency(containerName).setService(
99 IfIptoHost.class).setCallbacks("setHostTracker",
100 "unsetHostTracker").setRequired(true));
102 // Static routing aware there could be many
103 c.add(createContainerServiceDependency(containerName).setService(
104 IStaticRoutingAware.class).setCallbacks(
105 "setStaticRoutingAware", "unsetStaticRoutingAware")
106 .setRequired(false));