use of jmri.RouteManager in project JMRI by JMRI.
the class DefaultRouteManagerXml method replaceRouteManager.
/**
* Replace the current RouteManager, if there is one, with one newly created
* during a load operation. This is skipped if the present one is already of
* the right type
*/
protected void replaceRouteManager() {
RouteManager current = InstanceManager.getNullableDefault(jmri.RouteManager.class);
if (current != null && current.getClass().getName().equals(DefaultRouteManager.class.getName())) {
return;
}
// if old manager exists, remove it from configuration process
if (current != null) {
InstanceManager.getDefault(jmri.ConfigureManager.class).deregister(current);
InstanceManager.deregister(current, RouteManager.class);
}
// register new one with InstanceManager
DefaultRouteManager pManager = DefaultRouteManager.instance();
InstanceManager.store(pManager, RouteManager.class);
// register new one for configuration
InstanceManager.getDefault(jmri.ConfigureManager.class).registerConfig(pManager, jmri.Manager.ROUTES);
}
Aggregations