Changeset 12277


Ignore:
Timestamp:
11/11/09 23:24:57 (14 years ago)
Author:
ehuelsmann
Message:

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

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 
    601package abcl_ae;
    612
     
    8324        return;
    8425       
    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");
    9028     
    9129      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 
    511package abcl_ae;
    522
     
    6010import org.armedbear.lisp.Symbol;
    6111import org.armedbear.lisp.SpecialBinding;
    62 import org.armedbear.lisp.ConditionThrowable;
    6312import org.armedbear.lisp.Load;
     13import org.armedbear.lisp.Stream;
    6414
    6515public class HelloWorldServlet extends HttpServlet {
     
    6919  public void init() throws ServletException {
    7020    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");
    7522  }
    7623
     
    8128    LispThread currentThread = LispThread.currentThread();
    8229
    83     SpecialBinding lastSpecialBinding = currentThread.lastSpecialBinding;
     30    SpecialBindingsMark mark = currentThread.markSpecialBindings();
    8431    currentThread.bindSpecial(
    8532      Symbol.STANDARD_OUTPUT,
    86       new org.armedbear.lisp.Stream(resp.getOutputStream(), Symbol.CHARACTER, false));
     33      new Stream(resp.getOutputStream(), Symbol.CHARACTER, false));
    8734
    8835    try {
    8936      currentThread.execute(doGet);
    90     } catch (ConditionThrowable condition) {
    91       resp.setContentType("text/plain");
    92       resp.getWriter().println(condition.toString());
    9337    } finally {
    94       currentThread.lastSpecialBinding = lastSpecialBinding;
     38      currentThread.resetSpecialBindings(mark);
    9539    }
    9640  }
Note: See TracChangeset for help on using the changeset viewer.