001package jmri.util.startup;
002
003import java.io.File;
004
005import jmri.ConfigureManager;
006import jmri.InstanceManager;
007import jmri.JmriException;
008
009import org.slf4j.Logger;
010import org.slf4j.LoggerFactory;
011
012/**
013 * A PerformFileModel object loads an xml file when the program is started.
014 *
015 * @author Bob Jacobsen Copyright 2003
016 * @author Randall Wood (c) 2016
017 * @see jmri.util.startup.PerformFileModelFactory
018 */
019public class PerformFileModel extends AbstractStartupModel {
020
021    private final static Logger log = LoggerFactory.getLogger(PerformFileModel.class);
022
023    public String getFileName() {
024        return this.getName();
025    }
026
027    public void setFileName(String n) {
028        this.setName(n);
029    }
030
031    @Override
032    public void performAction() throws JmriException {
033        log.info("Loading file {}", this.getFileName());
034
035        // load the file
036        File file = new File(this.getFileName());
037        ConfigureManager cm = InstanceManager.getNullableDefault(ConfigureManager.class);
038        if (cm != null) {
039            cm.load(file);
040        }
041    }
042}