001package jmri.util.startup;
002
003import java.io.File;
004
005import jmri.JmriException;
006import jmri.script.JmriScriptEngineManager;
007
008import org.slf4j.Logger;
009import org.slf4j.LoggerFactory;
010
011/**
012 * A PerformScriptModel object runs a script when the program is started.
013 *
014 * @author Bob Jacobsen Copyright 2003
015 * @author Randall Wood (c) 2016
016 * @see jmri.util.startup.PerformScriptModelFactory
017 */
018public class PerformScriptModel extends AbstractStartupModel {
019
020    private final static Logger log = LoggerFactory.getLogger(PerformScriptModel.class);
021
022    public String getFileName() {
023        return this.getName();
024    }
025
026    public void setFileName(String n) {
027        this.setName(n);
028    }
029
030    @Override
031    public void performAction() throws JmriException {
032        log.info("Running script {}", this.getFileName());
033        JmriScriptEngineManager.getDefault().runScript(new File(this.getFileName()));
034    }
035}