Mercurial Hosting > luan
diff src/luan/tools/WebServlet.java @ 77:4bf3d0c0b6b9
make LuanState cloneable
git-svn-id: https://luan-java.googlecode.com/svn/trunk@78 21e917c8-12df-6dd8-5cb6-c86387c605b9
author | fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9> |
---|---|
date | Fri, 15 Feb 2013 09:55:17 +0000 |
parents | 97b03fc807ad |
children | 9df729fa4419 |
line wrap: on
line diff
--- a/src/luan/tools/WebServlet.java Fri Feb 15 04:52:16 2013 +0000 +++ b/src/luan/tools/WebServlet.java Fri Feb 15 09:55:17 2013 +0000 @@ -25,6 +25,8 @@ public static final String HTTP_SERVER = "http_server"; + protected LuanState luanState = null; + protected void loadLibs(LuanState luan) throws LuanException { luan.load(BasicLib.LOADER,BasicLib.NAME); luan.load(PackageLib.LOADER,PackageLib.NAME); @@ -36,7 +38,7 @@ protected void loadLuan(LuanState luan) throws LuanException { PackageLib.require(luan,HTTP_SERVER); - Object fn = luan.global.get(HttpLib.FN_NAME); + Object fn = luan.global().get(HttpLib.FN_NAME); if( !(fn instanceof LuanFunction) ) throw new LuanException( luan, LuanElement.JAVA, "function '"+HttpLib.FN_NAME+"' not defined" ); } @@ -48,8 +50,12 @@ return luan; } - protected LuanState getLuanState() throws LuanException { - return newLuanState(); + protected LuanState getLuanState() throws LuanException { + synchronized(this) { + if( luanState == null ) + luanState = newLuanState(); + } + return luanState.deepClone(); } protected void service(HttpServletRequest request,HttpServletResponse response)