Fixed context management bug with server push.

This commit is contained in:
Heng Sin Low 2011-01-17 18:05:09 +08:00
parent 4ed732b50c
commit 58ee1f6eda
3 changed files with 19 additions and 5 deletions

View File

@ -19,9 +19,6 @@ package org.adempiere.util;
import java.util.Properties;
import org.compiere.util.Env;
import org.compiere.util.Language;
/**
*
* @author <a href="mailto:agramdass@gmail.com">Ashley G Ramdass</a>
@ -43,7 +40,6 @@ public final class ServerContext
protected Properties initialValue()
{
Properties ctx = new Properties();
ctx.put(Env.LANGUAGE, Language.getBaseAD_Language());
return ctx;
}
};

View File

@ -41,6 +41,15 @@ public class ServerContextCallback implements InvocationHandler, Serializable {
types[1] == String.class && args != null && args[0] instanceof String &&
args[1] instanceof String)
return context.getProperty((String)args[0], (String)args[1]);
} else if (method.getName().equals("setProperty")) {
Class<?>[] types = method.getParameterTypes();
if (types != null && types.length == 2 && types[0] == String.class &&
types[1] == String.class && args != null && args[0] instanceof String &&
args[1] instanceof String)
{
context.setProperty((String)args[0], (String)args[1]);
return null;
}
}
Method m = context.getClass().getMethod(method.getName(), method.getParameterTypes());
return m.invoke(context, args);

View File

@ -129,6 +129,11 @@ public class SessionContextListener implements ExecutionInit,
public void prepare(Component comp, Event evt)
{
//in servlet thread
//check is thread local context have been setup
if (ServerContext.getCurrentInstance().isEmpty())
{
setupExecutionContextFromSession(Executions.getCurrent());
}
_ctx = ServerContext.getCurrentInstance();
}
@ -157,6 +162,11 @@ public class SessionContextListener implements ExecutionInit,
public void beforeResume(Component comp, Event evt)
{
//in servlet thread
//check is thread local context have been setup
if (ServerContext.getCurrentInstance().isEmpty())
{
setupExecutionContextFromSession(Executions.getCurrent());
}
_ctx = ServerContext.getCurrentInstance();
}
@ -247,6 +257,5 @@ public class SessionContextListener implements ExecutionInit,
{
//in event processing thread
_ctx = ServerContext.getCurrentInstance();
// ServerContext.dispose();
}
}