Merge "Fixed netconf monitoring."
[controller.git] / opendaylight / config / config-persister-directory-xml-adapter / src / main / java / org / opendaylight / controller / config / persist / storage / directory / xml / XmlDirectoryStorageAdapter.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8
9 package org.opendaylight.controller.config.persist.storage.directory.xml;
10
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;
17
18 import java.io.File;
19
20 /**
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.
23  */
24 public class XmlDirectoryStorageAdapter implements StorageAdapter {
25     private static final Logger logger = LoggerFactory.getLogger(XmlDirectoryStorageAdapter.class);
26
27     public static final String DIRECTORY_STORAGE_PROP = "directoryStorage";
28
29
30     @Override
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 XmlDirectoryPersister(storage);
37     }
38
39 }