a4397537486e738b482184ab6dc768270594e413
[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      * Function called when the activator starts just after some
35      * initializations are done by the
36      * ComponentActivatorAbstractBase.
37      *
38      */
39     public void init() {
40
41     }
42
43     /**
44      * Function called when the activator stops just before the
45      * cleanup done by ComponentActivatorAbstractBase
46      *
47      */
48     public void destroy() {
49
50     }
51
52     /**
53      * Function that is used to communicate to dependency manager the
54      * list of known implementations for services inside a container
55      *
56      *
57      * @return An array containing all the CLASS objects that will be
58      * instantiated in order to get an fully working implementation
59      * Object
60      */
61     public Object[] getImplementations() {
62         Object[] res = { StaticRoutingImplementation.class };
63         return res;
64     }
65
66     /**
67      * Function that is called when configuration of the dependencies
68      * is required.
69      *
70      * @param c dependency manager Component object, used for
71      * configuring the dependencies exported and imported
72      * @param imp Implementation class that is being configured,
73      * needed as long as the same routine can configure multiple
74      * implementations
75      * @param containerName The containerName being configured, this allow
76      * also optional per-container different behavior if needed, usually
77      * should not be the case though.
78      */
79     public void configureInstance(Component c, Object imp, String containerName) {
80         if (imp.equals(StaticRoutingImplementation.class)) {
81             c.setInterface(new String[] {
82                     IForwardingStaticRouting.class.getName(),
83                     IfNewHostNotify.class.getName(),
84                     IConfigurationContainerAware.class.getName() }, null);
85
86             c.add(createContainerServiceDependency(containerName).setService(
87                     IClusterContainerServices.class).setCallbacks(
88                     "setClusterContainerService",
89                     "unsetClusterContainerService").setRequired(true));
90
91             c.add(createContainerServiceDependency(containerName).setService(
92                     IfIptoHost.class).setCallbacks("setHostTracker",
93                     "unsetHostTracker").setRequired(true));
94
95             // Static routing aware there could be many
96             c.add(createContainerServiceDependency(containerName).setService(
97                     IStaticRoutingAware.class).setCallbacks(
98                     "setStaticRoutingAware", "unsetStaticRoutingAware")
99                     .setRequired(false));
100         }
101     }
102 }