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