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 org.apache.felix.dm.Component;
13 import org.opendaylight.controller.clustering.services.IClusterGlobalServices;
14 import org.opendaylight.controller.configuration.IConfigurationAware;
15 import org.opendaylight.controller.configuration.IConfigurationContainerAware;
16 import org.opendaylight.controller.configuration.IConfigurationContainerService;
17 import org.opendaylight.controller.configuration.IConfigurationService;
18 import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
19 import org.slf4j.Logger;
20 import org.slf4j.LoggerFactory;
23 * @file Activator.java
25 * @brief Component Activator for Configuration Management.
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 * Function that is used to communicate to dependency manager the
53 * list of known implementations for services inside a container
56 * @return An array containing all the CLASS objects that will be
57 * instantiated in order to get an fully working implementation
60 public Object[] getImplementations() {
61 Object[] res = { ConfigurationContainerImpl.class };
66 * Function that is called when configuration of the dependencies
69 * @param c dependency manager Component object, used for
70 * configuring the dependencies exported and imported
71 * @param imp Implementation class that is being configured,
72 * needed as long as the same routine can configure multiple
74 * @param containerName The containerName being configured, this allow
75 * also optional per-container different behavior if needed, usually
76 * should not be the case though.
78 public void configureInstance(Component c, Object imp, String containerName) {
79 if (imp.equals(ConfigurationContainerImpl.class)) {
81 c.setInterface(new String[] {
82 IConfigurationContainerService.class.getName(),
83 IConfigurationAware.class.getName() }, null);
85 c.add(createContainerServiceDependency(containerName).setService(
86 IConfigurationContainerAware.class).setCallbacks(
87 "addConfigurationContainerAware",
88 "removeConfigurationContainerAware").setRequired(false));
93 * Method which tells how many Global implementations are
94 * supported by the bundle. This way we can tune the number of
95 * components created. This components will be created ONLY at the
96 * time of bundle startup and will be destroyed only at time of
97 * bundle destruction, this is the major difference with the
98 * implementation retrieved via getImplementations where all of
99 * them are assumed to be in a container!
102 * @return The list of implementations the bundle will support,
105 protected Object[] getGlobalImplementations() {
106 Object[] res = { ConfigurationImpl.class };
111 * Configure the dependency for a given instance Global
113 * @param c Component assigned for this instance, this will be
114 * what will be used for configuration
115 * @param imp implementation to be configured
116 * @param containerName container on which the configuration happens
118 protected void configureGlobalInstance(Component c, Object imp) {
119 if (imp.equals(ConfigurationImpl.class)) {
121 // export the service
123 new String[] { IConfigurationService.class.getName() },
126 c.add(createServiceDependency().setService(
127 IClusterGlobalServices.class).setCallbacks(
128 "setClusterServices", "unsetClusterServices").setRequired(
131 c.add(createServiceDependency().setService(
132 IConfigurationAware.class).setCallbacks(
133 "addConfigurationAware", "removeConfigurationAware")
134 .setRequired(false));