[armedbear-cvs] r12231 - in trunk/abcl/examples/abcl: . abcl_appengine abcl_appengine/src abcl_appengine/src/META-INF abcl_appengine/src/abcl_ae abcl_appengine/war abcl_appengine/war/WEB-INF abcl_appengine/war/WEB-INF/classes abcl_appengine/war/WEB-INF/classes/META-INF abcl_appengine/war/WEB-INF/classes/abcl_ae abcl_appengine/war/WEB-INF/lib abcl_appengine/war/fasls
Erik Huelsmann
ehuelsmann at common-lisp.net
Tue Oct 27 21:57:25 UTC 2009
Author: ehuelsmann
Date: Tue Oct 27 17:57:22 2009
New Revision: 12231
Log:
Google App Engine (GAE) basic Hello World application progress.
Most of the code by Alex Muscar.
Added:
trunk/abcl/examples/abcl/abcl_appengine/
trunk/abcl/examples/abcl/abcl_appengine/build.xml
trunk/abcl/examples/abcl/abcl_appengine/src/
trunk/abcl/examples/abcl/abcl_appengine/src/META-INF/
trunk/abcl/examples/abcl/abcl_appengine/src/abcl_ae/
trunk/abcl/examples/abcl/abcl_appengine/src/abcl_ae/AbclInit.java
trunk/abcl/examples/abcl/abcl_appengine/src/abcl_ae/HelloWorldServlet.java
trunk/abcl/examples/abcl/abcl_appengine/src/first-servlet.lisp
trunk/abcl/examples/abcl/abcl_appengine/war/
trunk/abcl/examples/abcl/abcl_appengine/war/WEB-INF/
trunk/abcl/examples/abcl/abcl_appengine/war/WEB-INF/appengine-web.xml
trunk/abcl/examples/abcl/abcl_appengine/war/WEB-INF/classes/
trunk/abcl/examples/abcl/abcl_appengine/war/WEB-INF/classes/META-INF/
trunk/abcl/examples/abcl/abcl_appengine/war/WEB-INF/classes/abcl_ae/
trunk/abcl/examples/abcl/abcl_appengine/war/WEB-INF/classes/first-servlet.lisp
trunk/abcl/examples/abcl/abcl_appengine/war/WEB-INF/lib/
trunk/abcl/examples/abcl/abcl_appengine/war/WEB-INF/web.xml
trunk/abcl/examples/abcl/abcl_appengine/war/fasls/
Modified:
trunk/abcl/examples/abcl/README
Modified: trunk/abcl/examples/abcl/README
==============================================================================
--- trunk/abcl/examples/abcl/README (original)
+++ trunk/abcl/examples/abcl/README Tue Oct 27 17:57:22 2009
@@ -1,33 +1,44 @@
-ABCL Examples Building and Running Instructions
-===============================================
-
-code by Ville Voutilainen
-instructions by Blake McBride
-updated by Mark Evenson
-
-In general, to compile a Java class file (like Main.java for example
-in the 'java_exception_in_lisp' subdirectory) use:
-
- cmd$ cd java_exception_in_lisp
- cmd$ javac -cp ../../../dist/abcl.jar Main.java
-
-where the "../../../dist/abcl.jar" represents the path to your
-abcl.jar file, which is built via the Ant based build. This path
-could be slightly different depending on how the system was
-constructed, and possibly due to operating system conventions for
-specifying relative paths. However you resolve this locally, we'll
-refer to this as '$ABCL_ROOT/dist/abcl.jar' for the rest of these
-instructions.
-
-This compiles the Java source file "Main.java" into a JVM runtime or
-class file named "Main.class".
-
-To run the example (Main.class for example) from a Unix-like OS use:
-
- cmd$ java -cp $ABCL_ROOT/dist/abcl.jar:. Main
-
-or in Windows use:
-
- cmd$ java -cp $ABCL_ROOT/dist/abcl.jar;. Main
-
-where "Main" is the initial class to run in your Java program.
+ABCL Examples Building and Running Instructions
+===============================================
+
+code by Ville Voutilainen
+(abcl_appengine code by Alex Muscar)
+instructions by Blake McBride
+updated by Mark Evenson
+
+In general, to compile a Java class file (like Main.java for example
+in the 'java_exception_in_lisp' subdirectory) use:
+
+ cmd$ cd java_exception_in_lisp
+ cmd$ javac -cp ../../../dist/abcl.jar Main.java
+
+where the "../../../dist/abcl.jar" represents the path to your
+abcl.jar file, which is built via the Ant based build. This path
+could be slightly different depending on how the system was
+constructed, and possibly due to operating system conventions for
+specifying relative paths. However you resolve this locally, we'll
+refer to this as '$ABCL_ROOT/dist/abcl.jar' for the rest of these
+instructions.
+
+This compiles the Java source file "Main.java" into a JVM runtime or
+class file named "Main.class".
+
+To run the example (Main.class for example) from a Unix-like OS use:
+
+ cmd$ java -cp $ABCL_ROOT/dist/abcl.jar:. Main
+
+or in Windows use:
+
+ cmd$ java -cp $ABCL_ROOT/dist/abcl.jar;. Main
+
+where "Main" is the initial class to run in your Java program.
+
+
+abcl_appengine
+==============
+
+This example shows how to run your servlet off ABCL in general
+and in Google App Engine (GAE) in particular.
+
+When uploading your code to the server, be sure to put abcl.jar
+in war/WEB-INF/lib.
Added: trunk/abcl/examples/abcl/abcl_appengine/build.xml
==============================================================================
--- (empty file)
+++ trunk/abcl/examples/abcl/abcl_appengine/build.xml Tue Oct 27 17:57:22 2009
@@ -0,0 +1,61 @@
+<project>
+ <property name="sdk.dir" location="../appengine-java-sdk" />
+ <import file="${sdk.dir}/config/user/ant-macros.xml" />
+ <path id="project.classpath">
+ <pathelement path="war/WEB-INF/classes" />
+ <fileset dir="war/WEB-INF/lib">
+ <include name="**/*.jar" />
+ </fileset>
+ <fileset dir="${sdk.dir}/lib">
+ <include name="shared/**/*.jar" />
+ </fileset>
+ </path>
+ <target name="copyjars"
+ description="Copies the App Engine and ABCL JARs to the WAR.">
+ <copy
+ todir="war/WEB-INF/lib"
+ flatten="true">
+ <fileset dir="${sdk.dir}/lib/user">
+ <include name="**/*.jar" />
+ </fileset>
+ <fileset dir="../abcl">
+ <include name="dist/*.jar" />
+ </fileset>
+ </copy>
+ <copy
+ todir="war/fasls">
+ <fileset dir="src">
+ <include name="*.abcl" />
+ </fileset>
+ </copy>
+ </target>
+ <target name="compile" depends="copyjars"
+ description="Compiles Java source and copies other source files to the WAR.">
+ <mkdir dir="war/WEB-INF/classes" />
+ <copy todir="war/WEB-INF/classes">
+ <fileset dir="src">
+ <exclude name="**/*.java" />
+ </fileset>
+ </copy>
+ <javac
+ srcdir="src"
+ destdir="war/WEB-INF/classes"
+ classpathref="project.classpath"
+ debug="on" />
+ </target>
+ <target name="clean" description="Cleans all the jars and fasls.">
+ <delete>
+ <fileset dir="." includes="**/*.jar" />
+ <fileset dir="." includes="**/*.class" />
+ <fileset dir="." includes="**/*.abcl" />
+ </delete>
+ </target>
+ <target name="runserver" depends="compile"
+ description="Starts the development server.">
+ <dev_appserver war="war" />
+ </target>
+ <target name="runserver-debug" depends="compile"
+ description="Starts the development server.">
+ <dev_appserver war="war" port="8888"/>
+ </target>
+</project>
\ No newline at end of file
Added: trunk/abcl/examples/abcl/abcl_appengine/src/abcl_ae/AbclInit.java
==============================================================================
--- (empty file)
+++ trunk/abcl/examples/abcl/abcl_appengine/src/abcl_ae/AbclInit.java Tue Oct 27 17:57:22 2009
@@ -0,0 +1,95 @@
+/*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;
+import java.io.IOException;
+
+import org.armedbear.lisp.Lisp;
+import org.armedbear.lisp.Load;
+import org.armedbear.lisp.Interpreter;
+import org.armedbear.lisp.Symbol;
+import org.armedbear.lisp.Pathname;
+import org.armedbear.lisp.ConditionThrowable;
+
+public final class AbclInit {
+ static private Object lock = new Object();
+ static private boolean initialized = false;
+
+ // package access level
+ static void init() {
+ if (initialized)
+ return;
+
+ synchronized (lock) {
+ if (initialized)
+ return;
+
+ try {
+ Interpreter.initializeLisp();
+ Load.load("fasls/first-servlet.abcl");
+ }
+ catch (ConditionThrowable ct) { }
+
+ initialized = true;
+ }
+ }
+
+}
\ No newline at end of file
Added: trunk/abcl/examples/abcl/abcl_appengine/src/abcl_ae/HelloWorldServlet.java
==============================================================================
--- (empty file)
+++ trunk/abcl/examples/abcl/abcl_appengine/src/abcl_ae/HelloWorldServlet.java Tue Oct 27 17:57:22 2009
@@ -0,0 +1,97 @@
+/*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;
+import javax.servlet.http.*;
+import javax.servlet.*;
+
+import org.armedbear.lisp.Interpreter;
+import org.armedbear.lisp.LispThread;
+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;
+
+public class HelloWorldServlet extends HttpServlet {
+
+ static private Symbol doGet = null;
+
+ public void init() throws ServletException {
+ AbclInit.init();
+ try {
+ doGet = Lisp.internInPackage("DO-GET", "FIRST-SERVLET");
+ }
+ catch (ConditionThrowable ct) { }
+ }
+
+
+ public void doGet(HttpServletRequest req, HttpServletResponse resp)
+ throws IOException {
+
+ LispThread currentThread = LispThread.currentThread();
+
+ SpecialBinding lastSpecialBinding = currentThread.lastSpecialBinding;
+ currentThread.bindSpecial(
+ Symbol.STANDARD_OUTPUT,
+ new org.armedbear.lisp.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;
+ }
+ }
+}
\ No newline at end of file
Added: trunk/abcl/examples/abcl/abcl_appengine/src/first-servlet.lisp
==============================================================================
--- (empty file)
+++ trunk/abcl/examples/abcl/abcl_appengine/src/first-servlet.lisp Tue Oct 27 17:57:22 2009
@@ -0,0 +1,8 @@
+(defpackage #:first-servlet
+ (:use :cl)
+ (:export #:do-get))
+
+(in-package #:first-servlet)
+
+(defun do-get ()
+ (format t "Hello, World!~%"))
\ No newline at end of file
Added: trunk/abcl/examples/abcl/abcl_appengine/war/WEB-INF/appengine-web.xml
==============================================================================
--- (empty file)
+++ trunk/abcl/examples/abcl/abcl_appengine/war/WEB-INF/appengine-web.xml Tue Oct 27 17:57:22 2009
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
+ <application>abcl-test</application>
+ <version>1</version>
+</appengine-web-app>
Added: trunk/abcl/examples/abcl/abcl_appengine/war/WEB-INF/classes/first-servlet.lisp
==============================================================================
--- (empty file)
+++ trunk/abcl/examples/abcl/abcl_appengine/war/WEB-INF/classes/first-servlet.lisp Tue Oct 27 17:57:22 2009
@@ -0,0 +1,8 @@
+(defpackage #:first-servlet
+ (:use :cl)
+ (:export #:do-get))
+
+(in-package #:first-servlet)
+
+(defun do-get ()
+ (format t "Hello, World!~%"))
\ No newline at end of file
Added: trunk/abcl/examples/abcl/abcl_appengine/war/WEB-INF/web.xml
==============================================================================
--- (empty file)
+++ trunk/abcl/examples/abcl/abcl_appengine/war/WEB-INF/web.xml Tue Oct 27 17:57:22 2009
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE web-app PUBLIC
+ "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
+ "http://java.sun.com/dtd/web-app_2_3.dtd">
+
+<web-app xmlns="http://java.sun.com/xml/ns/javaee" version="2.5">
+ <servlet>
+ <servlet-name>hello</servlet-name>
+ <servlet-class>abcl_ae.HelloWorldServlet</servlet-class>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>hello</servlet-name>
+ <url-pattern>/hello</url-pattern>
+ </servlet-mapping>
+ <welcome-file-list>
+ <welcome-file>/index.html</welcome-file>
+ </welcome-file-list>
+</web-app>
\ No newline at end of file
More information about the armedbear-cvs
mailing list