Changeset 12277
- Timestamp:
- 11/11/09 23:24:57 (14 years ago)
- Location:
- trunk/abcl/examples/abcl/abcl_appengine/src/abcl_ae
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abcl/examples/abcl/abcl_appengine/src/abcl_ae/AbclInit.java
r12231 r12277 1 /*package abcl_ae;2 3 import java.io.FileInputStream;4 import java.io.PrintWriter;5 import java.io.StringWriter;6 import java.io.File;7 //import java.io.IOException;8 //import java.io.FileNotFoundException;9 10 import org.armedbear.lisp.Lisp;11 import org.armedbear.lisp.Interpreter;12 import org.armedbear.lisp.Symbol;13 import org.armedbear.lisp.Pathname;14 import org.armedbear.lisp.Stream;15 import org.armedbear.lisp.Load;16 import org.armedbear.lisp.ConditionThrowable;17 18 public final class AbclInit {19 static Symbol doGet = null;20 static boolean hasErrors = false;21 static String message = "Success";22 23 static {24 FileInputStream in = null;25 26 try {27 in = new FileInputStream("fasls/first-servlet.abcl");28 Load.load("fasls/first-servlet.abcl");29 30 doGet = Lisp.internInPackage("FIRST-SERVLET", "DO-GET");31 } catch (ConditionThrowable condition) {32 // How do we handle exceptions?33 hasErrors = true;34 message = condition.toString();35 } catch (Exception e) {36 // How do we handle exceptions?37 hasErrors = true;38 StringWriter sw = new StringWriter();39 PrintWriter pw = new PrintWriter(sw, true);40 e.printStackTrace(pw);41 pw.flush();42 sw.flush();43 message = sw.toString();44 } finally {45 try {46 in.close();47 } catch (Exception e) {48 hasErrors = true;49 StringWriter sw = new StringWriter();50 PrintWriter pw = new PrintWriter(sw, true);51 e.printStackTrace(pw);52 pw.flush();53 sw.flush();54 message = sw.toString();55 }56 }57 }58 }*/59 60 1 package abcl_ae; 61 2 … … 83 24 return; 84 25 85 try { 86 Interpreter.initializeLisp(); 87 Load.load("fasls/first-servlet.abcl"); 88 } 89 catch (ConditionThrowable ct) { } 26 Interpreter.initializeLisp(); 27 Load.load("fasls/first-servlet.abcl"); 90 28 91 29 initialized = true; -
trunk/abcl/examples/abcl/abcl_appengine/src/abcl_ae/HelloWorldServlet.java
r12231 r12277 1 /*package abcl_ae;2 3 import java.io.IOException;4 import javax.servlet.http.*;5 6 import org.armedbear.lisp.LispThread;7 import org.armedbear.lisp.Lisp;8 import org.armedbear.lisp.Symbol;9 import org.armedbear.lisp.Stream;10 import org.armedbear.lisp.SpecialBinding;11 import org.armedbear.lisp.ConditionThrowable;12 13 public class HelloWorldServlet extends HttpServlet {14 public void doGet(HttpServletRequest req, HttpServletResponse resp)15 throws IOException {16 17 if (AbclInit.hasErrors)18 {19 resp.setContentType("text/plain");20 resp.getWriter().println(AbclInit.message);21 return;22 }23 24 // Set the default Lisp output stream to the servlet's output stream.25 LispThread currentThread = LispThread.currentThread();26 SpecialBinding lastSpecialBinding = currentThread.lastSpecialBinding;27 Stream out = new Stream(resp.getOutputStream(), Symbol.CHARACTER, false);28 29 currentThread.bindSpecial(Symbol.STANDARD_OUTPUT, out);30 31 try {32 if (AbclInit.doGet == null)33 {34 resp.setContentType("text/plain");35 resp.getWriter().println(AbclInit.message);36 return;37 }38 39 // Run the Lisp handler.40 currentThread.execute(AbclInit.doGet);41 } catch (ConditionThrowable condition) {42 resp.setContentType("text/plain");43 resp.getWriter().println(condition.toString());44 } finally {45 // Restore the default Lisp output stream.46 currentThread.lastSpecialBinding = lastSpecialBinding;47 }48 }49 }*/50 51 1 package abcl_ae; 52 2 … … 60 10 import org.armedbear.lisp.Symbol; 61 11 import org.armedbear.lisp.SpecialBinding; 62 import org.armedbear.lisp.ConditionThrowable;63 12 import org.armedbear.lisp.Load; 13 import org.armedbear.lisp.Stream; 64 14 65 15 public class HelloWorldServlet extends HttpServlet { … … 69 19 public void init() throws ServletException { 70 20 AbclInit.init(); 71 try { 72 doGet = Lisp.internInPackage("DO-GET", "FIRST-SERVLET"); 73 } 74 catch (ConditionThrowable ct) { } 21 doGet = Lisp.internInPackage("DO-GET", "FIRST-SERVLET"); 75 22 } 76 23 … … 81 28 LispThread currentThread = LispThread.currentThread(); 82 29 83 SpecialBinding lastSpecialBinding = currentThread.lastSpecialBinding;30 SpecialBindingsMark mark = currentThread.markSpecialBindings(); 84 31 currentThread.bindSpecial( 85 32 Symbol.STANDARD_OUTPUT, 86 new org.armedbear.lisp.Stream(resp.getOutputStream(), Symbol.CHARACTER, false));33 new Stream(resp.getOutputStream(), Symbol.CHARACTER, false)); 87 34 88 35 try { 89 36 currentThread.execute(doGet); 90 } catch (ConditionThrowable condition) {91 resp.setContentType("text/plain");92 resp.getWriter().println(condition.toString());93 37 } finally { 94 currentThread. lastSpecialBinding = lastSpecialBinding;38 currentThread.resetSpecialBindings(mark); 95 39 } 96 40 }
Note: See TracChangeset
for help on using the changeset viewer.