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