@Override
public UIApplication restoreUIRootComponent(WebuiRequestContext context) throws Exception {
context.setStateManager(this);
//
WebuiApplication app = (WebuiApplication) context.getApplication();
//
ApplicationState appState = null;
HttpSession session = getSession(context);
String key = getKey(context);
if (session != null) {
appState = (ApplicationState) session.getAttribute(APPLICATION_ATTRIBUTE_PREFIX + key);
}
UIApplication uiapp = null;
if (appState != null) {
if (log.isDebugEnabled()) {
log.debug("Found application " + key + " :" + appState.getApplication());
}
if (Safe.equals(context.getRemoteUser(), appState.getUserName())) {
uiapp = appState.getApplication();
}
} else {
log.debug("Application " + key + " not found");
}
//
if (uiapp == null) {
ConfigurationManager cmanager = app.getConfigurationManager();
String uirootClass = cmanager.getApplication().getUIRootComponent().trim();
Class<? extends UIApplication> type = (Class<UIApplication>) Thread.currentThread().getContextClassLoader()
.loadClass(uirootClass);
uiapp = app.createUIComponent(type, null, null, context);
}
//
return uiapp;
}