Mercurial Hosting > luan
diff src/luan/tools/WebServlet.java @ 90:b1e87f1bcc13
make module names uppercase;
WebServlet improvements;
git-svn-id: https://luan-java.googlecode.com/svn/trunk@91 21e917c8-12df-6dd8-5cb6-c86387c605b9
author | fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9> |
---|---|
date | Sat, 02 Mar 2013 05:02:56 +0000 |
parents | 6db8f286fa6c |
children | f537ff5e511d |
line wrap: on
line diff
--- a/src/luan/tools/WebServlet.java Thu Feb 28 09:47:38 2013 +0000 +++ b/src/luan/tools/WebServlet.java Sat Mar 02 05:02:56 2013 +0000 @@ -25,39 +25,38 @@ protected LuanState luanState = null; - protected void loadLibs(LuanState luan) throws LuanException { + protected LuanState newLuanState() throws LuanException { + LuanState luan = LuanCompiler.newLuanState(); luan.load(BasicLib.NAME,BasicLib.LOADER); luan.load(PackageLib.NAME,PackageLib.LOADER); luan.load(MathLib.NAME,MathLib.LOADER); luan.load(StringLib.NAME,StringLib.LOADER); luan.load(TableLib.NAME,TableLib.LOADER); luan.load(HtmlLib.NAME,HtmlLib.LOADER); - } - - protected LuanState newLuanState() throws LuanException { - LuanState luan = LuanCompiler.newLuanState(); - loadLibs(luan); - HttpLib.load(luan); return luan; } - protected LuanState getLuanState(HttpServletRequest request) throws LuanException { - synchronized(this) { - if( luanState == null ) - luanState = newLuanState(); - } - return luanState.deepClone(); - } - @Override protected void service(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException { try { - LuanState luan = getLuanState(request); - HttpLib.service(luan,request,response); + synchronized(this) { + if( luanState == null ) { + luanState = newLuanState(); + HttpLib.load(luanState); + } + } + LuanState luan = luanState.deepClone(); + service(request,response,luan); } catch(LuanException e) { throw new LuanRuntimeException(e); } } + protected void service(HttpServletRequest request,HttpServletResponse response,LuanState luan) + throws ServletException, IOException, LuanException + { + HttpLib.service(luan,request,response); + } + }