comparison http/src/luan/modules/http/HttpServicer.java @ 504:dbdf4b8193a8

add Http.per_session()
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 21 May 2015 01:09:35 -0600
parents ab9c2afefb47
children 7bc63886d4f2
comparison
equal deleted inserted replaced
503:92c3d22745b8 504:dbdf4b8193a8
45 public static boolean service(LuanState luan,HttpServletRequest request,HttpServletResponse response,String modName) 45 public static boolean service(LuanState luan,HttpServletRequest request,HttpServletResponse response,String modName)
46 throws LuanException 46 throws LuanException
47 { 47 {
48 LuanFunction fn; 48 LuanFunction fn;
49 synchronized(luan) { 49 synchronized(luan) {
50 LuanTable module = (LuanTable)PackageLuan.require(luan,"luan:http/Http");
51 LuanTable per_session_pages = (LuanTable)module.rawGet("per_session_pages");
50 Object mod = PackageLuan.load(luan,modName); 52 Object mod = PackageLuan.load(luan,modName);
51 if( mod==null ) 53 if( mod==null )
52 return false; 54 return false;
53 if( !(mod instanceof LuanTable) ) 55 if( !(mod instanceof LuanTable) )
54 throw luan.exception( "module '"+modName+"' must return a table" ); 56 throw luan.exception( "module '"+modName+"' must return a table" );
55 LuanTable tbl = (LuanTable)mod; 57 LuanTable tbl = (LuanTable)mod;
56 if( Boolean.TRUE.equals(tbl.get(luan,"per_session")) ) { 58 if( Boolean.TRUE.equals(per_session_pages.rawGet(mod)) ) {
57 HttpSession session = request.getSession(); 59 HttpSession session = request.getSession();
58 LuanState sessionLuan = (LuanState)session.getValue("luan"); 60 LuanState sessionLuan = (LuanState)session.getValue("luan");
59 if( sessionLuan!=null ) { 61 if( sessionLuan!=null ) {
60 luan = sessionLuan; 62 luan = sessionLuan;
61 } else { 63 } else {