Fixed context management bug with server push.
This commit is contained in:
parent
4ed732b50c
commit
58ee1f6eda
|
@ -19,9 +19,6 @@ package org.adempiere.util;
|
||||||
|
|
||||||
import java.util.Properties;
|
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>
|
* @author <a href="mailto:agramdass@gmail.com">Ashley G Ramdass</a>
|
||||||
|
@ -43,7 +40,6 @@ public final class ServerContext
|
||||||
protected Properties initialValue()
|
protected Properties initialValue()
|
||||||
{
|
{
|
||||||
Properties ctx = new Properties();
|
Properties ctx = new Properties();
|
||||||
ctx.put(Env.LANGUAGE, Language.getBaseAD_Language());
|
|
||||||
return ctx;
|
return ctx;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -41,6 +41,15 @@ public class ServerContextCallback implements InvocationHandler, Serializable {
|
||||||
types[1] == String.class && args != null && args[0] instanceof String &&
|
types[1] == String.class && args != null && args[0] instanceof String &&
|
||||||
args[1] instanceof String)
|
args[1] instanceof String)
|
||||||
return context.getProperty((String)args[0], (String)args[1]);
|
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());
|
Method m = context.getClass().getMethod(method.getName(), method.getParameterTypes());
|
||||||
return m.invoke(context, args);
|
return m.invoke(context, args);
|
||||||
|
|
|
@ -129,6 +129,11 @@ public class SessionContextListener implements ExecutionInit,
|
||||||
public void prepare(Component comp, Event evt)
|
public void prepare(Component comp, Event evt)
|
||||||
{
|
{
|
||||||
//in servlet thread
|
//in servlet thread
|
||||||
|
//check is thread local context have been setup
|
||||||
|
if (ServerContext.getCurrentInstance().isEmpty())
|
||||||
|
{
|
||||||
|
setupExecutionContextFromSession(Executions.getCurrent());
|
||||||
|
}
|
||||||
_ctx = ServerContext.getCurrentInstance();
|
_ctx = ServerContext.getCurrentInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,6 +162,11 @@ public class SessionContextListener implements ExecutionInit,
|
||||||
public void beforeResume(Component comp, Event evt)
|
public void beforeResume(Component comp, Event evt)
|
||||||
{
|
{
|
||||||
//in servlet thread
|
//in servlet thread
|
||||||
|
//check is thread local context have been setup
|
||||||
|
if (ServerContext.getCurrentInstance().isEmpty())
|
||||||
|
{
|
||||||
|
setupExecutionContextFromSession(Executions.getCurrent());
|
||||||
|
}
|
||||||
_ctx = ServerContext.getCurrentInstance();
|
_ctx = ServerContext.getCurrentInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -247,6 +257,5 @@ public class SessionContextListener implements ExecutionInit,
|
||||||
{
|
{
|
||||||
//in event processing thread
|
//in event processing thread
|
||||||
_ctx = ServerContext.getCurrentInstance();
|
_ctx = ServerContext.getCurrentInstance();
|
||||||
// ServerContext.dispose();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue