IDEMPIERE-356 Change Role. Refactoring, reduce min thread pool size and added timeout setting.

This commit is contained in:
Heng Sin Low 2012-08-23 16:27:39 +08:00
parent 1123aec6d1
commit 287e78722f
3 changed files with 37 additions and 31 deletions

View File

@ -567,10 +567,11 @@ public final class Adempiere
max = 200;
}
if (min < 0) {
min = 20;
min = 10;
}
// start thread pool
threadPoolExecutor = new ThreadPoolExecutor(min, max, 0, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>());
threadPoolExecutor = new ThreadPoolExecutor(min, max, 1, TimeUnit.MINUTES, new LinkedBlockingQueue<Runnable>());
threadPoolExecutor.allowCoreThreadTimeOut(true);
}
/**

View File

@ -344,18 +344,34 @@ public class AdempiereWebUI extends Window implements EventListener<Event>, IWeb
*/
public void logout()
{
appDesktop.logout();
Executions.getCurrent().getDesktop().getSession().getAttributes().clear();
Session session = logout0();
AEnv.logout();
//clear context, invalidate session
Env.getCtx().clear();
session.invalidate();
SessionManager.clearSession();
super.getChildren().clear();
Page page = this.getPage();
page.removeComponents();
//redirect to login page
Executions.sendRedirect("index.zul");
}
protected Session logout0() {
Session session = Executions.getCurrent().getDesktop().getSession();
//stop background thread
appDesktop.logout();
//clear remove all children and root component
getChildren().clear();
getPage().removeComponents();
//clear session attributes
session.getAttributes().clear();
//logout ad_session
AEnv.logout();
return session;
}
/**
* @return IDesktop
*/
@ -426,6 +442,7 @@ public class AdempiereWebUI extends Window implements EventListener<Event>, IWeb
@Override
public void changeRole(MUser user) {
//save context for re-login
Properties properties = new Properties();
Env.setContext(properties, Env.AD_CLIENT_ID, Env.getAD_Client_ID(Env.getCtx()));
Env.setContext(properties, Env.AD_ORG_ID, Env.getAD_Org_ID(Env.getCtx()));
@ -438,17 +455,16 @@ public class AdempiereWebUI extends Window implements EventListener<Event>, IWeb
Env.setContext(properties, Env.LANGUAGE, Env.getContext(Env.getCtx(), Env.LANGUAGE));
Env.setContext(properties, AEnv.LOCALE, Env.getContext(Env.getCtx(), AEnv.LOCALE));
Locale locale = (Locale) Executions.getCurrent().getSession().getAttribute(Attributes.PREFERRED_LOCALE);
appDesktop.logout();
Locale locale = (Locale) Executions.getCurrent().getDesktop().getSession().getAttribute(Attributes.PREFERRED_LOCALE);
HttpServletRequest httpRequest = (HttpServletRequest) Executions.getCurrent().getNativeRequest();
Session session = Executions.getCurrent().getDesktop().getSession();
session.getAttributes().clear();
AEnv.logout();
((SessionCtrl)session).invalidateNow();
Session session = logout0();
//clear context and invalidate session
Env.getCtx().clear();
((SessionCtrl)session).invalidateNow();
//put saved context into new session
Map<String, Object> map = new HashMap<String, Object>();
map.put("context", properties);
map.put("locale", locale);

View File

@ -78,17 +78,6 @@ public class SessionManager
return app;
}
public static void clearSession()
{
Env.getCtx().clear();
Session session = getSession();
if (session != null)
{
session.removeAttribute(SessionContextListener.SESSION_CTX);
session.invalidate();
}
}
public static void logoutSession()
{
IWebClient app = getSessionApplication();