Mercurial Hosting > luan
comparison 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 |
comparison
equal
deleted
inserted
replaced
89:8ef2d6701541 | 90:b1e87f1bcc13 |
---|---|
23 | 23 |
24 public class WebServlet extends HttpServlet { | 24 public class WebServlet extends HttpServlet { |
25 | 25 |
26 protected LuanState luanState = null; | 26 protected LuanState luanState = null; |
27 | 27 |
28 protected void loadLibs(LuanState luan) throws LuanException { | 28 protected LuanState newLuanState() throws LuanException { |
29 LuanState luan = LuanCompiler.newLuanState(); | |
29 luan.load(BasicLib.NAME,BasicLib.LOADER); | 30 luan.load(BasicLib.NAME,BasicLib.LOADER); |
30 luan.load(PackageLib.NAME,PackageLib.LOADER); | 31 luan.load(PackageLib.NAME,PackageLib.LOADER); |
31 luan.load(MathLib.NAME,MathLib.LOADER); | 32 luan.load(MathLib.NAME,MathLib.LOADER); |
32 luan.load(StringLib.NAME,StringLib.LOADER); | 33 luan.load(StringLib.NAME,StringLib.LOADER); |
33 luan.load(TableLib.NAME,TableLib.LOADER); | 34 luan.load(TableLib.NAME,TableLib.LOADER); |
34 luan.load(HtmlLib.NAME,HtmlLib.LOADER); | 35 luan.load(HtmlLib.NAME,HtmlLib.LOADER); |
35 } | |
36 | |
37 protected LuanState newLuanState() throws LuanException { | |
38 LuanState luan = LuanCompiler.newLuanState(); | |
39 loadLibs(luan); | |
40 HttpLib.load(luan); | |
41 return luan; | 36 return luan; |
42 } | |
43 | |
44 protected LuanState getLuanState(HttpServletRequest request) throws LuanException { | |
45 synchronized(this) { | |
46 if( luanState == null ) | |
47 luanState = newLuanState(); | |
48 } | |
49 return luanState.deepClone(); | |
50 } | 37 } |
51 | 38 |
52 @Override protected void service(HttpServletRequest request,HttpServletResponse response) | 39 @Override protected void service(HttpServletRequest request,HttpServletResponse response) |
53 throws ServletException, IOException | 40 throws ServletException, IOException |
54 { | 41 { |
55 try { | 42 try { |
56 LuanState luan = getLuanState(request); | 43 synchronized(this) { |
57 HttpLib.service(luan,request,response); | 44 if( luanState == null ) { |
45 luanState = newLuanState(); | |
46 HttpLib.load(luanState); | |
47 } | |
48 } | |
49 LuanState luan = luanState.deepClone(); | |
50 service(request,response,luan); | |
58 } catch(LuanException e) { | 51 } catch(LuanException e) { |
59 throw new LuanRuntimeException(e); | 52 throw new LuanRuntimeException(e); |
60 } | 53 } |
61 } | 54 } |
62 | 55 |
56 protected void service(HttpServletRequest request,HttpServletResponse response,LuanState luan) | |
57 throws ServletException, IOException, LuanException | |
58 { | |
59 HttpLib.service(luan,request,response); | |
60 } | |
61 | |
63 } | 62 } |