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.configuration.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.IClusterGlobalServices;
20 import org.opendaylight.controller.configuration.IConfigurationAware;
21 import org.opendaylight.controller.configuration.IConfigurationContainerAware;
22 import org.opendaylight.controller.configuration.IConfigurationContainerService;
23 import org.opendaylight.controller.configuration.IConfigurationService;
24 import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
25 import org.slf4j.Logger;
26 import org.slf4j.LoggerFactory;
29 * @file Activator.java
31 * @brief Component Activator for Configuration Management.
36 public class Activator extends ComponentActivatorAbstractBase {
37 protected static final Logger logger = LoggerFactory
38 .getLogger(Activator.class);
42 * Function that is used to communicate to dependency manager the
43 * list of known implementations for services inside a container
46 * @return An array containing all the CLASS objects that will be
47 * instantiated in order to get an fully working implementation
50 public Object[] getImplementations() {
51 Object[] res = { ConfigurationContainerImpl.class };
56 * Function that is called when configuration of the dependencies
59 * @param c dependency manager Component object, used for
60 * configuring the dependencies exported and imported
61 * @param imp Implementation class that is being configured,
62 * needed as long as the same routine can configure multiple
64 * @param containerName The containerName being configured, this allow
65 * also optional per-container different behavior if needed, usually
66 * should not be the case though.
68 public void configureInstance(Component c, Object imp, String containerName) {
69 if (imp.equals(ConfigurationContainerImpl.class)) {
71 c.setInterface(new String[] {
72 IConfigurationContainerService.class.getName(),
73 IConfigurationAware.class.getName() }, null);
75 c.add(createContainerServiceDependency(containerName).setService(
76 IConfigurationContainerAware.class).setCallbacks(
77 "addConfigurationContainerAware",
78 "removeConfigurationContainerAware").setRequired(false));
83 * Method which tells how many Global implementations are
84 * supported by the bundle. This way we can tune the number of
85 * components created. This components will be created ONLY at the
86 * time of bundle startup and will be destroyed only at time of
87 * bundle destruction, this is the major difference with the
88 * implementation retrieved via getImplementations where all of
89 * them are assumed to be in a container!
92 * @return The list of implementations the bundle will support,
95 protected Object[] getGlobalImplementations() {
96 Object[] res = { ConfigurationImpl.class };
101 * Configure the dependency for a given instance Global
103 * @param c Component assigned for this instance, this will be
104 * what will be used for configuration
105 * @param imp implementation to be configured
106 * @param containerName container on which the configuration happens
108 protected void configureGlobalInstance(Component c, Object imp) {
109 if (imp.equals(ConfigurationImpl.class)) {
110 Dictionary<String, Set<String>> props = new Hashtable<String, Set<String>>();
111 Set<String> propSet = new HashSet<String>();
112 propSet.add("config.event.save");
113 props.put("cachenames", propSet);
115 // export the service
117 new String[] { IConfigurationService.class.getName(),
118 ICacheUpdateAware.class.getName()},
121 c.add(createServiceDependency().setService(
122 IClusterGlobalServices.class).setCallbacks(
123 "setClusterServices", "unsetClusterServices").setRequired(
126 c.add(createServiceDependency().setService(
127 IConfigurationAware.class).setCallbacks(
128 "addConfigurationAware", "removeConfigurationAware")
129 .setRequired(false));