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.IListenInventoryUpdates;
30 public class Activator extends ComponentActivatorAbstractBase {
31 protected static final Logger logger = LoggerFactory
32 .getLogger(Activator.class);
35 * Function called when the activator starts just after some
36 * initializations are done by the
37 * ComponentActivatorAbstractBase.
44 * Function called when the activator stops just before the
45 * cleanup done by ComponentActivatorAbstractBase
48 public void destroy() {
52 * Method which tells how many Global implementations are
53 * supported by the bundle. This way we can tune the number of
54 * components created. This components will be created ONLY at the
55 * time of bundle startup and will be destroyed only at time of
56 * bundle destruction, this is the major difference with the
57 * implementation retrieved via getImplementations where all of
58 * them are assumed to be in a container!
61 * @return The list of implementations the bundle will support,
64 protected Object[] getGlobalImplementations() {
65 Object[] res = { ConnectionManager.class };
70 * Configure the dependency for a given instance Global
72 * @param c Component assigned for this instance, this will be
73 * what will be used for configuration
74 * @param imp implementation to be configured
75 * @param containerName container on which the configuration happens
77 protected void configureGlobalInstance(Component c, Object imp) {
78 if (imp.equals(ConnectionManager.class)) {
79 Dictionary<String, Object> props = new Hashtable<String, Object>();
80 Set<String> propSet = new HashSet<String>();
81 for (ConnectionMgmtScheme scheme:ConnectionMgmtScheme.values()) {
82 propSet.add("connectionmanager."+scheme.name()+".nodeconnections");
84 props.put("cachenames", propSet);
85 props.put("scope", "Global");
88 c.setInterface(new String[] { IConnectionManager.class.getName(),
89 IConnectionListener.class.getName(),
90 ICoordinatorChangeAware.class.getName(),
91 IListenInventoryUpdates.class.getName(),
92 ICacheUpdateAware.class.getName()},
95 c.add(createServiceDependency()
96 .setService(IClusterGlobalServices.class)
97 .setCallbacks("setClusterServices", "unsetClusterServices")
100 c.add(createServiceDependency().setService(IConnectionService.class)
101 .setCallbacks("setConnectionService", "unsetConnectionService")