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.connectionmanager.internal;
12 import java.util.Dictionary;
13 import java.util.HashSet;
14 import java.util.Hashtable;
17 import org.opendaylight.controller.clustering.services.ICacheUpdateAware;
18 import org.opendaylight.controller.clustering.services.IClusterGlobalServices;
19 import org.opendaylight.controller.clustering.services.ICoordinatorChangeAware;
20 import org.opendaylight.controller.connectionmanager.ConnectionMgmtScheme;
21 import org.opendaylight.controller.connectionmanager.IConnectionManager;
22 import org.opendaylight.controller.sal.connection.IConnectionListener;
23 import org.opendaylight.controller.sal.connection.IConnectionService;
24 import org.apache.felix.dm.Component;
25 import org.slf4j.Logger;
26 import org.slf4j.LoggerFactory;
27 import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
28 import org.opendaylight.controller.sal.inventory.IInventoryService;
29 import org.opendaylight.controller.sal.inventory.IListenInventoryUpdates;
31 public class Activator extends ComponentActivatorAbstractBase {
32 protected static final Logger logger = LoggerFactory
33 .getLogger(Activator.class);
37 * Method which tells how many Global implementations are
38 * supported by the bundle. This way we can tune the number of
39 * components created. This components will be created ONLY at the
40 * time of bundle startup and will be destroyed only at time of
41 * bundle destruction, this is the major difference with the
42 * implementation retrieved via getImplementations where all of
43 * them are assumed to be in a container!
46 * @return The list of implementations the bundle will support,
50 protected Object[] getGlobalImplementations() {
51 Object[] res = { ConnectionManager.class };
56 * Configure the dependency for a given instance Global
58 * @param c Component assigned for this instance, this will be
59 * what will be used for configuration
60 * @param imp implementation to be configured
61 * @param containerName container on which the configuration happens
64 protected void configureGlobalInstance(Component c, Object imp) {
65 if (imp.equals(ConnectionManager.class)) {
66 Dictionary<String, Object> props = new Hashtable<String, Object>();
67 Set<String> propSet = new HashSet<String>();
68 for (ConnectionMgmtScheme scheme:ConnectionMgmtScheme.values()) {
69 propSet.add("connectionmanager."+scheme.name()+".nodeconnections");
71 props.put("cachenames", propSet);
72 props.put("scope", "Global");
75 c.setInterface(new String[] { IConnectionManager.class.getName(),
76 IConnectionListener.class.getName(),
77 ICoordinatorChangeAware.class.getName(),
78 IListenInventoryUpdates.class.getName(),
79 ICacheUpdateAware.class.getName()},
82 c.add(createServiceDependency()
83 .setService(IClusterGlobalServices.class)
84 .setCallbacks("setClusterServices", "unsetClusterServices")
87 c.add(createServiceDependency().setService(IConnectionService.class)
88 .setCallbacks("setConnectionService", "unsetConnectionService")
90 c.add(createServiceDependency().setService(IInventoryService.class, "(scope=Global)")
91 .setCallbacks("setInventoryService", "unsetInventoryService")