日期:2014-05-16 浏览次数:20372 次
(function() { var imp, dirs, defaults, server, context; try { importer(); consts(); loadScripts(); startMonit(); startServer(); } catch (e) { print(e); } function importer() { imp = JavaImporter( java.io, org.eclipse.jetty.server, org.eclipse.jetty.servlet, com.purejs.lib); } function consts() { dirs = ["scripts/lib", "webapp/js/both", "scripts/app"]; defaults = "*.js,*.css,*.ico,*.txt,*.png,*.jpg,*.gif,*.htm,*.html,*.swf"; } function loadScripts() { print("Loading Scripts ..."); load("scripts/config.js"); loadDirs(dirs); } function startMonit() { print("Starting Monit ..."); pure.each = each; pure.monit(dirs, function(file){ file = imp.File(file); if(file.exists() && file.file) { load(file); } }); } function startServer() { print("Starting Server ..."); createServer(); server.start(); server.join(); } // 以下省略... }());
(function() { var servlet = javax.servlet.http.HttpServlet; pure.apiServlet = servlet({ service: service }); function service(req, res) { var result; try { result = run(req, res); } catch (e) { print(e); result = { error: e.toString(), success: false } } if (result != null) { res.setContentType("text/html; charset=UTF8"); res.getWriter().write(JSON.stringify(result)); } } function run(req, res) { // 省略 ... } }());