[armedbear-cvs] r12277 - trunk/abcl/examples/abcl/abcl_appengine/src/abcl_ae

Erik Huelsmann ehuelsmann at common-lisp.net
Wed Nov 11 23:24:58 UTC 2009


Author: ehuelsmann
Date: Wed Nov 11 18:24:57 2009
New Revision: 12277

Log:
Adjust Google App Engine example to the "disappearance" of ConditionThrowable.

Modified:
   trunk/abcl/examples/abcl/abcl_appengine/src/abcl_ae/AbclInit.java
   trunk/abcl/examples/abcl/abcl_appengine/src/abcl_ae/HelloWorldServlet.java

Modified: trunk/abcl/examples/abcl/abcl_appengine/src/abcl_ae/AbclInit.java
==============================================================================
--- trunk/abcl/examples/abcl/abcl_appengine/src/abcl_ae/AbclInit.java	(original)
+++ trunk/abcl/examples/abcl/abcl_appengine/src/abcl_ae/AbclInit.java	Wed Nov 11 18:24:57 2009
@@ -1,62 +1,3 @@
-/*package abcl_ae;
-
-import java.io.FileInputStream;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.io.File;
-//import java.io.IOException;
-//import java.io.FileNotFoundException;
-
-import org.armedbear.lisp.Lisp;
-import org.armedbear.lisp.Interpreter;
-import org.armedbear.lisp.Symbol;
-import org.armedbear.lisp.Pathname;
-import org.armedbear.lisp.Stream;
-import org.armedbear.lisp.Load;
-import org.armedbear.lisp.ConditionThrowable;
-
-public final class AbclInit {
-	static Symbol doGet = null;
-	static boolean hasErrors = false;
-	static String message = "Success";
-	
-	static {
-		FileInputStream in = null;
-		
-		try {
-			in = new FileInputStream("fasls/first-servlet.abcl");
-			Load.load("fasls/first-servlet.abcl");
-			
-			doGet = Lisp.internInPackage("FIRST-SERVLET", "DO-GET");
-		} catch (ConditionThrowable condition) {
-			// How do we handle exceptions?
-			hasErrors = true;
-			message = condition.toString();
-		} catch (Exception e) {
-			// How do we handle exceptions?
-			hasErrors = true;
-			StringWriter sw = new StringWriter();
-			PrintWriter pw = new PrintWriter(sw, true);
-			e.printStackTrace(pw);
-			pw.flush();
-			sw.flush();
-			message = sw.toString();
-		} finally {
-			try {
-				in.close();
-			} catch (Exception e) {
-				hasErrors = true;
-				StringWriter sw = new StringWriter();
-				PrintWriter pw = new PrintWriter(sw, true);
-				e.printStackTrace(pw);
-				pw.flush();
-				sw.flush();
-				message = sw.toString();
-			}
-		}
-	}
-}*/
-
 package abcl_ae;
 
 import java.io.FileInputStream;
@@ -82,11 +23,8 @@
 			if (initialized)
 				return;
 				
-			try {
-				Interpreter.initializeLisp();
-				Load.load("fasls/first-servlet.abcl");
-			}
-			catch (ConditionThrowable ct) { }
+			Interpreter.initializeLisp();
+			Load.load("fasls/first-servlet.abcl");
 			
 			initialized = true;
 		}

Modified: trunk/abcl/examples/abcl/abcl_appengine/src/abcl_ae/HelloWorldServlet.java
==============================================================================
--- trunk/abcl/examples/abcl/abcl_appengine/src/abcl_ae/HelloWorldServlet.java	(original)
+++ trunk/abcl/examples/abcl/abcl_appengine/src/abcl_ae/HelloWorldServlet.java	Wed Nov 11 18:24:57 2009
@@ -1,53 +1,3 @@
-/*package abcl_ae;
-
-import java.io.IOException;
-import javax.servlet.http.*;
-
-import org.armedbear.lisp.LispThread;
-import org.armedbear.lisp.Lisp;
-import org.armedbear.lisp.Symbol;
-import org.armedbear.lisp.Stream;
-import org.armedbear.lisp.SpecialBinding;
-import org.armedbear.lisp.ConditionThrowable;
-
-public class HelloWorldServlet extends HttpServlet {
-	public void doGet(HttpServletRequest req, HttpServletResponse resp)
-		throws IOException {
-		
-		if (AbclInit.hasErrors)
-		{
-			resp.setContentType("text/plain");
-			resp.getWriter().println(AbclInit.message);
-			return;
-		}
-		
-		// Set the default Lisp output stream to the servlet's output stream.
-		LispThread currentThread = LispThread.currentThread();
-		SpecialBinding lastSpecialBinding = currentThread.lastSpecialBinding;
-		Stream out = new Stream(resp.getOutputStream(), Symbol.CHARACTER, false);
-		
-		currentThread.bindSpecial(Symbol.STANDARD_OUTPUT, out);
-		
-		try {
-			if (AbclInit.doGet == null)
-			{
-				resp.setContentType("text/plain");
-				resp.getWriter().println(AbclInit.message);
-				return;
-			}
-			
-			// Run the Lisp handler.
-			currentThread.execute(AbclInit.doGet);
-		} catch (ConditionThrowable condition) {
-			resp.setContentType("text/plain");
-			resp.getWriter().println(condition.toString());
-		} finally {
-			// Restore the default Lisp output stream.
-			currentThread.lastSpecialBinding = lastSpecialBinding;
-		}
-	}
-}*/
-
 package abcl_ae;
 
 import java.io.IOException;
@@ -59,8 +9,8 @@
 import org.armedbear.lisp.Lisp;
 import org.armedbear.lisp.Symbol;
 import org.armedbear.lisp.SpecialBinding;
-import org.armedbear.lisp.ConditionThrowable;
 import org.armedbear.lisp.Load;
+import org.armedbear.lisp.Stream;
 
 public class HelloWorldServlet extends HttpServlet {
 
@@ -68,10 +18,7 @@
 
 	public void init() throws ServletException {
 		AbclInit.init();
-		try {
-			doGet = Lisp.internInPackage("DO-GET", "FIRST-SERVLET");
-		}
-		catch (ConditionThrowable ct) { }
+		doGet = Lisp.internInPackage("DO-GET", "FIRST-SERVLET");
 	}
 
 
@@ -80,18 +27,15 @@
 
 		LispThread currentThread = LispThread.currentThread();
 
-		SpecialBinding lastSpecialBinding = currentThread.lastSpecialBinding;
+		SpecialBindingsMark mark = currentThread.markSpecialBindings();
 		currentThread.bindSpecial(
 			Symbol.STANDARD_OUTPUT, 
-			new org.armedbear.lisp.Stream(resp.getOutputStream(), Symbol.CHARACTER, false));
+			new Stream(resp.getOutputStream(), Symbol.CHARACTER, false));
 
 		try {
 			currentThread.execute(doGet);
-		} catch (ConditionThrowable condition) {
-			resp.setContentType("text/plain");
-			resp.getWriter().println(condition.toString());
 		} finally {
-			currentThread.lastSpecialBinding = lastSpecialBinding;
+			currentThread.resetSpecialBindings(mark);
 		}
 	}
 }
\ No newline at end of file




More information about the armedbear-cvs mailing list