7e1e79a17c60ebaed89c7f7ff979c7ab28c6a149
[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.IClusterContainerServices;
25 import org.opendaylight.controller.configuration.IConfigurationContainerAware;
26 import org.opendaylight.controller.hosttracker.IfIptoHost;
27 import org.opendaylight.controller.hosttracker.IfNewHostNotify;
28
29 public class Activator extends ComponentActivatorAbstractBase {
30     protected static final Logger logger = LoggerFactory
31             .getLogger(Activator.class);
32
33
34     /**
35      * Function that is used to communicate to dependency manager the
36      * list of known implementations for services inside a container
37      *
38      *
39      * @return An array containing all the CLASS objects that will be
40      * instantiated in order to get an fully working implementation
41      * Object
42      */
43     public Object[] getImplementations() {
44         Object[] res = { StaticRoutingImplementation.class };
45         return res;
46     }
47
48     /**
49      * Function that is called when configuration of the dependencies
50      * is required.
51      *
52      * @param c dependency manager Component object, used for
53      * configuring the dependencies exported and imported
54      * @param imp Implementation class that is being configured,
55      * needed as long as the same routine can configure multiple
56      * implementations
57      * @param containerName The containerName being configured, this allow
58      * also optional per-container different behavior if needed, usually
59      * should not be the case though.
60      */
61     public void configureInstance(Component c, Object imp, String containerName) {
62         if (imp.equals(StaticRoutingImplementation.class)) {
63             c.setInterface(new String[] {
64                     IForwardingStaticRouting.class.getName(),
65                     IfNewHostNotify.class.getName(),
66                     IConfigurationContainerAware.class.getName() }, null);
67
68             c.add(createContainerServiceDependency(containerName).setService(
69                     IClusterContainerServices.class).setCallbacks(
70                     "setClusterContainerService",
71                     "unsetClusterContainerService").setRequired(true));
72
73             c.add(createContainerServiceDependency(containerName).setService(
74                     IfIptoHost.class).setCallbacks("setHostTracker",
75                     "unsetHostTracker").setRequired(true));
76
77             // Static routing aware there could be many
78             c.add(createContainerServiceDependency(containerName).setService(
79                     IStaticRoutingAware.class).setCallbacks(
80                     "setStaticRoutingAware", "unsetStaticRoutingAware")
81                     .setRequired(false));
82         }
83     }
84 }