/**
* Reloading a view in response to a configuration change.
*/
public void reloadView() {
final ViewFactorySource factorySource = mock(ViewFactorySource.class);
final ViewRegistry viewRegistry = mock(ViewRegistry.class);
// A changed (and persisted) configuration created by an admin
final ViewConfig config = mock(ViewConfig.class);
final ViewFactory factory = factorySource.getFactory(config.getFactoryName());
final View newView = factory.createView(config);
// De-register the existing view
final View existingView = viewRegistry.findViewByName(config.getViewName());
if (existingView != null) {
viewRegistry.unregisterView(existingView);
}
// Register its replacement
viewRegistry.registerView(newView);
}