comparison src/luan/modules/http/LuanDomainHandler.java @ 1333:25746915a241

merge Luan and LuanState
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 12 Feb 2019 22:33:40 -0700
parents 11b7e11f9ed5
children 7483108154bb
comparison
equal deleted inserted replaced
1332:11b7e11f9ed5 1333:25746915a241
2 2
3 import luan.webserver.Request; 3 import luan.webserver.Request;
4 import luan.webserver.Response; 4 import luan.webserver.Response;
5 import luan.webserver.Handler; 5 import luan.webserver.Handler;
6 import luan.webserver.handlers.DomainHandler; 6 import luan.webserver.handlers.DomainHandler;
7 import luan.LuanState; 7 import luan.Luan;
8 import luan.LuanTable; 8 import luan.LuanTable;
9 import luan.LuanCloner; 9 import luan.LuanCloner;
10 import luan.LuanException; 10 import luan.LuanException;
11 import luan.modules.logging.Log4j; 11 import luan.modules.logging.Log4j;
12 12
13 13
14 public class LuanDomainHandler implements Handler, DomainHandler.Factory { 14 public class LuanDomainHandler implements Handler, DomainHandler.Factory {
15 15
16 private final LuanState luanInit; 16 private final Luan luanInit;
17 private final DomainHandler domainHandler = new DomainHandler(this); 17 private final DomainHandler domainHandler = new DomainHandler(this);
18 18
19 public LuanDomainHandler(LuanState luanInit) { 19 public LuanDomainHandler(Luan luanInit) {
20 LuanCloner cloner = new LuanCloner(LuanCloner.Type.COMPLETE); 20 LuanCloner cloner = new LuanCloner(LuanCloner.Type.COMPLETE);
21 this.luanInit = (LuanState)cloner.clone(luanInit); 21 this.luanInit = (Luan)cloner.clone(luanInit);
22 } 22 }
23 23
24 @Override public Handler newHandler(String domain) { 24 @Override public Handler newHandler(String domain) {
25 LuanState luan = newLuan(domain); 25 Luan luan = newLuan(domain);
26 return new LuanHandler(luan); 26 return new LuanHandler(luan);
27 } 27 }
28 28
29 protected void newLoggerRepository(LuanState luan) throws LuanException { 29 protected void newLoggerRepository(Luan luan) throws LuanException {
30 Log4j.newLoggerRepository(luan); 30 Log4j.newLoggerRepository(luan);
31 } 31 }
32 32
33 protected LuanState newLuan(String domain) { 33 protected Luan newLuan(String domain) {
34 LuanCloner cloner = new LuanCloner(LuanCloner.Type.COMPLETE); 34 LuanCloner cloner = new LuanCloner(LuanCloner.Type.COMPLETE);
35 LuanState luan = (LuanState)cloner.clone(luanInit); 35 Luan luan = (Luan)cloner.clone(luanInit);
36 try { 36 try {
37 newLoggerRepository(luan); 37 newLoggerRepository(luan);
38 LuanTable Http = (LuanTable)luan.require("luan:http/Http.luan"); 38 LuanTable Http = (LuanTable)luan.require("luan:http/Http.luan");
39 Http.put( "domain", domain ); 39 Http.put( "domain", domain );
40 } catch(LuanException e) { 40 } catch(LuanException e) {