Move init and destroy empty impl from Activator classes. Have only one
[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     /**
28      * Function that is used to communicate to dependency manager the list of
29      * known implementations for services inside a container
30      *
31      *
32      * @return An array containing all the CLASS objects that will be
33      *         instantiated in order to get an fully working implementation
34      *         Object
35      */
36     public Object[] getImplementations() {
37         Object[] res = { StatisticsManager.class };
38         return res;
39     }
40
41     /**
42      * Function that is called when configuration of the dependencies is
43      * required.
44      *
45      * @param c
46      *            dependency manager Component object, used for configuring the
47      *            dependencies exported and imported
48      * @param imp
49      *            Implementation class that is being configured, needed as long
50      *            as the same routine can configure multiple implementations
51      * @param containerName
52      *            The containerName being configured, this allow also optional
53      *            per-container different behavior if needed, usually should not
54      *            be the case though.
55      */
56     public void configureInstance(Component c, Object imp, String containerName) {
57         if (imp.equals(StatisticsManager.class)) {
58             // export the service
59             c.setInterface(new String[] {
60                     IStatisticsManager.class.getName(),
61                     IReadServiceListener.class.getName(),
62                     IListenInventoryUpdates.class.getName() }, null);
63
64             c.add(createContainerServiceDependency(containerName).setService(IReadService.class)
65                     .setCallbacks("setReaderService", "unsetReaderService").setRequired(true));
66             c.add(createContainerServiceDependency(containerName).setService(IClusterContainerServices.class)
67                     .setCallbacks("setClusterContainerService", "unsetClusterContainerService").setRequired(true));
68             c.add(createContainerServiceDependency(containerName).setService(IContainer.class)
69                     .setCallbacks("setIContainer", "unsetIContainer").setRequired(true));
70
71         }
72     }
73 }