e26b6b87d8ace955a6647ce6524ff0b98c9f9630
[controller.git] / opendaylight / statisticsmanager / src / main / java / org / opendaylight / controller / statisticsmanager / 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.statisticsmanager.internal;
11
12 import org.apache.felix.dm.Component;
13 import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
14 import org.opendaylight.controller.sal.reader.IReadService;
15 import org.opendaylight.controller.statisticsmanager.IStatisticsManager;
16 import org.opendaylight.controller.statisticsmanager.StatisticsManager;
17 import org.slf4j.Logger;
18 import org.slf4j.LoggerFactory;
19
20 public class Activator extends ComponentActivatorAbstractBase {
21     protected static final Logger logger = LoggerFactory
22             .getLogger(Activator.class);
23
24     /**
25      * Function called when the activator starts just after some
26      * initializations are done by the
27      * ComponentActivatorAbstractBase.
28      *
29      */
30     public void init() {
31     }
32
33     /**
34      * Function called when the activator stops just before the
35      * cleanup done by ComponentActivatorAbstractBase
36      *
37      */
38     public void destroy() {
39     }
40
41     /**
42      * Function that is used to communicate to dependency manager the
43      * list of known implementations for services inside a container
44      *
45      *
46      * @return An array containing all the CLASS objects that will be
47      * instantiated in order to get an fully working implementation
48      * Object
49      */
50     public Object[] getImplementations() {
51         Object[] res = { StatisticsManager.class };
52         return res;
53     }
54
55     /**
56      * Function that is called when configuration of the dependencies
57      * is required.
58      *
59      * @param c dependency manager Component object, used for
60      * configuring the dependencies exported and imported
61      * @param imp Implementation class that is being configured,
62      * needed as long as the same routine can configure multiple
63      * implementations
64      * @param containerName The containerName being configured, this allow
65      * also optional per-container different behavior if needed, usually
66      * should not be the case though.
67      */
68     public void configureInstance(Component c, Object imp, String containerName) {
69         if (imp.equals(StatisticsManager.class)) {
70             // export the service
71             c.setInterface(new String[] { IStatisticsManager.class.getName() },
72                     null);
73
74             c.add(createContainerServiceDependency(containerName).setService(
75                     IReadService.class).setCallbacks("setReaderService",
76                     "unsetReaderService").setRequired(false));
77         }
78     }
79 }