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.Collections;
13 import java.util.HashSet;
16 import org.opendaylight.controller.clustering.services.IClusterGlobalServices;
17 import org.opendaylight.controller.configuration.IConfigurationAware;
18 import org.opendaylight.controller.configuration.IConfigurationService;
19 import org.opendaylight.controller.sal.utils.StatusCode;
20 import org.opendaylight.controller.sal.utils.Status;
21 import org.slf4j.Logger;
22 import org.slf4j.LoggerFactory;
25 * @file ConfigurationImpl.java
27 * @brief Backend functionality for all Configuration related tasks.
32 public class ConfigurationImpl implements IConfigurationService {
33 private static final Logger logger = LoggerFactory
34 .getLogger(ConfigurationImpl.class);
35 private IClusterGlobalServices clusterServices;
37 * Collection containing the configuration objects.
38 * This is configuration world: container names (also the map key)
39 * are maintained as they were configured by user, same case
41 private Set<IConfigurationAware> configurationAwareList = (Set<IConfigurationAware>) Collections
42 .synchronizedSet(new HashSet<IConfigurationAware>());
45 public int getConfigurationAwareListSize() {
46 return this.configurationAwareList.size();
49 public void addConfigurationAware(IConfigurationAware configurationAware) {
50 if (!this.configurationAwareList.contains(configurationAware)) {
51 this.configurationAwareList.add(configurationAware);
55 public void removeConfigurationAware(IConfigurationAware configurationAware) {
56 this.configurationAwareList.remove(configurationAware);
59 public void setClusterServices(IClusterGlobalServices i) {
60 this.clusterServices = i;
61 logger.debug("IClusterServices set");
64 public void unsetClusterServices(IClusterGlobalServices i) {
65 if (this.clusterServices == i) {
66 this.clusterServices = null;
67 logger.debug("IClusterServices Unset");
72 logger.info("ContainerManager startup....");
75 public void destroy() {
77 this.configurationAwareList.clear();
81 public Status saveConfigurations() {
82 boolean success = true;
83 for (IConfigurationAware configurationAware : configurationAwareList) {
84 Status status = configurationAware.saveConfiguration();
85 if (!status.isSuccess()) {
87 logger.info("Failed to save config for {}",
88 configurationAware.getClass().getName());
92 return new Status(StatusCode.SUCCESS, null);
94 return new Status(StatusCode.INTERNALERROR,
95 "Failed to Save All Configurations");