
org.openxma.rwt.bridge.SessionFunctions Maven / Gradle / Ivy
The newest version!
package org.openxma.rwt.bridge;
import javax.servlet.http.HttpSession;
import at.spardat.xma.boot.component.IComponent;
public class SessionFunctions {
public static final String componentAttributName = "openXMA_root_component";
public static final String componentUrlAttributName = "openXMA_url";
public static final String appManagerAttributName = "openXMA_AppManager";
public static void cleanUpSession(HttpSession httpSession) {
System.out.println("Clean up session: "+httpSession);
IComponent comp = SessionFunctions.getComponentFromSession(httpSession);
if (comp != null) {
System.out.println("Dispose component: "+comp+" ...");
try {
comp.dispose();
} catch (Exception ex) {
System.out.println("Can not dispose component: "+comp+" ...");
ex.printStackTrace();
} finally {
httpSession.removeAttribute(SessionFunctions.componentAttributName);
}
System.out.println("Component: "+comp+" disposed.");
} else {
System.out.println("Found no component to dispose in session: "+httpSession);
}
httpSession.removeAttribute(SessionFunctions.appManagerAttributName);
}
public static void setComponentUrlToSession(HttpSession httpSession, String componentUrl) {
if (componentUrl != null) {
System.out.println("Set component url to session: "+httpSession+" -> "+componentUrl);
//COMPONENT_URL.set(componentUrl);
httpSession.setAttribute(componentUrlAttributName,componentUrl);
}
}
public static String getComponentUrlFromSession(HttpSession httpSession) {
//return COMPONENT_URL.get();
return (String)httpSession.getAttribute(SessionFunctions.componentUrlAttributName);
}
protected static IComponent getComponentFromSession(HttpSession httpSession) {
IComponent comp = (IComponent)httpSession.getAttribute(SessionFunctions.componentAttributName);
return comp;
}
public static void setComponentToSession(HttpSession httpSession, IComponent component) {
if (component != null) {
httpSession.setAttribute(componentAttributName,component);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy