2 * Copyright (c) 2014, 2015 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.controller.cluster.common.actor;
11 import com.google.common.base.Preconditions;
12 import com.typesafe.config.Config;
13 import com.typesafe.config.ConfigFactory;
15 import java.util.HashMap;
18 public abstract class AbstractConfig implements UnifiedConfig {
20 private Config config;
22 public AbstractConfig(Config config){
31 public static abstract class Builder<T extends Builder<T>> {
32 protected Map<String, Object> configHolder;
33 protected Config fallback;
35 private final String actorSystemName;
37 public Builder(String actorSystemName){
38 Preconditions.checkArgument(actorSystemName != null, "Actor system name must not be null");
39 this.actorSystemName = actorSystemName;
40 configHolder = new HashMap<>();
43 public T withConfigReader(AkkaConfigurationReader reader){
44 fallback = reader.read().getConfig(actorSystemName);
48 protected Config merge(){
50 fallback = ConfigFactory.load().getConfig(actorSystemName);
52 return ConfigFactory.parseMap(configHolder).withFallback(fallback);