OpenDaylight Controller functional modules.
[controller.git] / opendaylight / forwarding / staticrouting / src / main / java / org / opendaylight / controller / forwarding / staticrouting / internal / Activator.java
1
2 /*
3  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
4  *
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
8  */
9
10 package org.opendaylight.controller.forwarding.staticrouting.internal;
11
12 import java.util.Dictionary;
13 import java.util.HashSet;
14 import java.util.Hashtable;
15 import java.util.Set;
16
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;
23
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;
29
30 public class Activator extends ComponentActivatorAbstractBase {
31     protected static final Logger logger = LoggerFactory
32             .getLogger(Activator.class);
33
34     /**
35      * Function called when the activator starts just after some
36      * initializations are done by the
37      * ComponentActivatorAbstractBase.
38      *
39      */
40     public void init() {
41
42     }
43
44     /**
45      * Function called when the activator stops just before the
46      * cleanup done by ComponentActivatorAbstractBase
47      *
48      */
49     public void destroy() {
50
51     }
52
53     /**
54      * Function that is used to communicate to dependency manager the
55      * list of known implementations for services inside a container
56      *
57      *
58      * @return An array containing all the CLASS objects that will be
59      * instantiated in order to get an fully working implementation
60      * Object
61      */
62     public Object[] getImplementations() {
63         Object[] res = { StaticRoutingImplementation.class };
64         return res;
65     }
66
67     /**
68      * Function that is called when configuration of the dependencies
69      * is required.
70      *
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
75      * implementations
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.
79      */
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);
86             // export the service
87
88             c.setInterface(new String[] { ICacheUpdateAware.class.getName(),
89                     IForwardingStaticRouting.class.getName(),
90                     IfNewHostNotify.class.getName(),
91                     IConfigurationContainerAware.class.getName() }, props);
92
93             c.add(createContainerServiceDependency(containerName).setService(
94                     IClusterContainerServices.class).setCallbacks(
95                     "setClusterContainerService",
96                     "unsetClusterContainerService").setRequired(true));
97
98             c.add(createContainerServiceDependency(containerName).setService(
99                     IfIptoHost.class).setCallbacks("setHostTracker",
100                     "unsetHostTracker").setRequired(true));
101
102             // Static routing aware there could be many
103             c.add(createContainerServiceDependency(containerName).setService(
104                     IStaticRoutingAware.class).setCallbacks(
105                     "setStaticRoutingAware", "unsetStaticRoutingAware")
106                     .setRequired(false));
107         }
108     }
109 }