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