public class MyApplication extends Application{
private static ThreadLocal<MyApplication> threadLocal = new ThreadLocal<MyApplication>();
public void init(){
setInstance(this);
Window w = new Window();
setMainWindow(w);
....
public static MyApplication getInstance() {
return threadLocal.get();
}
public static void setInstance(MyApplication application) {
threadLocal.set(application);
}
I think you actually don’t need the locale part at all because i think in the example they use another threadlocal called Lang.which you don’t have. It also seems like the top example is outdated and it is recommended to use the bottom one with HttpServletRequestListener.