use of jmri.implementation.DefaultSignalSystem in project JMRI by JMRI.
the class DefaultSignalSystemManager method makeBean.
SignalSystem makeBean(String name) {
//First check to see if the bean is in the default system directory
URL path = FileUtil.findURL("xml/signals/" + name + "/aspects.xml", FileUtil.Location.INSTALLED);
log.debug("load from {}", path);
XmlFile xf = new AspectFile();
if (path != null) {
try {
Element root = xf.rootFromURL(path);
DefaultSignalSystem s = new DefaultSignalSystem(name);
loadBean(s, root);
return s;
} catch (IOException | JDOMException e) {
log.error("Could not parse aspect file \"{}\" due to: {}", path, e);
}
}
//if the file doesn't exist or fails the load from the default location then try the user directory
path = FileUtil.findURL("signals/" + name + "/aspects.xml", FileUtil.Location.USER, "xml", "resources");
log.debug("load from {}", path);
if (path != null) {
xf = new AspectFile();
try {
Element root = xf.rootFromURL(path);
DefaultSignalSystem s = new DefaultSignalSystem(name);
loadBean(s, root);
return s;
} catch (IOException | JDOMException e) {
log.error("Could not parse aspect file \"{}\" due to: {}", path, e);
}
}
return null;
}
Aggregations