2 * Copyright (c) 2013 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.config.persist.storage.directory;
11 import com.google.common.base.Preconditions;
12 import org.opendaylight.controller.config.persist.api.Persister;
13 import org.opendaylight.controller.config.persist.api.PropertiesProvider;
14 import org.opendaylight.controller.config.persist.api.StorageAdapter;
15 import org.slf4j.Logger;
16 import org.slf4j.LoggerFactory;
21 * StorageAdapter that retrieves initial configuration from a directory. If multiple files are present, snapshot and
22 * required capabilities will be merged together. Writing to this persister is not supported.
24 public class DirectoryStorageAdapter implements StorageAdapter {
25 private static final Logger logger = LoggerFactory.getLogger(DirectoryStorageAdapter.class);
27 public static final String DIRECTORY_STORAGE_PROP = "directoryStorage";
31 public Persister instantiate(PropertiesProvider propertiesProvider) {
32 String fileStorageProperty = propertiesProvider.getProperty(DIRECTORY_STORAGE_PROP);
33 Preconditions.checkNotNull(fileStorageProperty, "Unable to find " + propertiesProvider.getFullKeyForReporting(DIRECTORY_STORAGE_PROP));
34 File storage = new File(fileStorageProperty);
35 logger.debug("Using {}", storage);
36 return new DirectoryPersister(storage);