use of jmri.managers.DefaultLogixManager in project JMRI by JMRI.
the class DefaultLogixManagerXml method replaceLogixManager.
/**
* Replace the current LogixManager, if there is one, with one newly created
* during a load operation. This is skipped if they are of the same absolute
* type.
*/
protected void replaceLogixManager() {
if (InstanceManager.getDefault(jmri.LogixManager.class).getClass().getName().equals(DefaultLogixManager.class.getName())) {
return;
}
// if old manager exists, remove it from configuration process
if (InstanceManager.getNullableDefault(jmri.LogixManager.class) != null) {
ConfigureManager cmOD = InstanceManager.getNullableDefault(jmri.ConfigureManager.class);
if (cmOD != null) {
cmOD.deregister(InstanceManager.getDefault(jmri.LogixManager.class));
}
}
// register new one with InstanceManager
DefaultLogixManager pManager = DefaultLogixManager.instance();
InstanceManager.store(pManager, LogixManager.class);
// register new one for configuration
ConfigureManager cmOD = InstanceManager.getNullableDefault(jmri.ConfigureManager.class);
if (cmOD != null) {
cmOD.registerConfig(pManager, jmri.Manager.LOGIXS);
}
}
Aggregations