3 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
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
10 package org.opendaylight.controller.statisticsmanager.internal;
12 import java.util.Dictionary;
13 import java.util.HashSet;
14 import java.util.Hashtable;
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;
30 public class Activator extends ComponentActivatorAbstractBase {
31 protected static final Logger logger = LoggerFactory.getLogger(Activator.class);
35 * Function that is used to communicate to dependency manager the list of
36 * known implementations for services inside a container
39 * @return An array containing all the CLASS objects that will be
40 * instantiated in order to get an fully working implementation
43 public Object[] getImplementations() {
44 Object[] res = { StatisticsManager.class };
49 * Function that is called when configuration of the dependencies is
53 * dependency manager Component object, used for configuring the
54 * dependencies exported and imported
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
63 public void configureInstance(Component c, Object imp, String containerName) {
64 if (imp.equals(StatisticsManager.class)) {
66 Dictionary<String, Object> props = new Hashtable<String, Object>();
67 Set<String> propSet = new HashSet<String>();
69 propSet.add(StatisticsManager.TRIGGERS_CACHE);
70 // flow statistics cache
71 propSet.add(StatisticsManager.FLOW_STATISTICS_CACHE);
72 props.put("cachenames", propSet);
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);
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));