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