r9585 - helma-ng/trunk/src/org/helma/web

[email protected]
Newsgroups gmane.comp.java.helma.cvs
Message-ID <20090408112433.8EEC03D0D6@mia>
Author: hannes
Date: 2009-04-08 13:24:33 +0200 (Wed, 08 Apr 2009)
New Revision: 9585

Modified:
   helma-ng/trunk/src/org/helma/web/HelmaServlet.java
Log:
Simplify HelmaServlet for now by removing all the advanced thread-pool stuff, because it won't run on Google App Engine. If needed, it can be added later, or in a specialized subclass.

Details at http://dev.helma.org/trac/helma/changeset/9585

Modified: helma-ng/trunk/src/org/helma/web/HelmaServlet.java
===================================================================
--- helma-ng/trunk/src/org/helma/web/HelmaServlet.java	2009-04-08 11:24:30 UTC (rev 9584)
+++ helma-ng/trunk/src/org/helma/web/HelmaServlet.java	2009-04-08 11:24:33 UTC (rev 9585)
@@ -18,7 +18,6 @@
 import org.helma.repository.FileRepository;
 import org.helma.repository.Repository;
 import org.helma.repository.WebappRepository;
-import org.mozilla.javascript.WrappedException;
 
 import javax.servlet.ServletConfig;
 import javax.servlet.ServletException;
@@ -27,7 +26,6 @@
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
 import java.io.FileNotFoundException;
-import java.util.concurrent.*;
 
 /**
  * Helma servlet class used to access helma from a web server.
@@ -36,8 +34,6 @@
 
     protected RhinoEngine engine;
 
-    private ExecutorService pool;
-
     private int requestTimeout = 30;
 
     private String moduleName, functionName;
@@ -67,8 +63,6 @@
     }
 
     public void init(ServletConfig servletConfig) throws ServletException {
-        // pool = Executors.newFixedThreadPool(8);
-        pool = Executors.newCachedThreadPool();
         moduleName = servletConfig.getInitParameter("moduleName");
         if (moduleName == null) {
             throw new ServletException("moduleName servlet parameter not defined");
@@ -113,34 +107,12 @@
     protected void service(final HttpServletRequest req,
                            final HttpServletResponse res)
             throws ServletException, IOException {
-        Future<Status> future = pool.submit(new Callable<Status>() {
-            public Status call() {
-                Status status = new Status();
-                try {
-                    engine.invoke(moduleName, functionName, new Request(req), new Response(res));
-                } catch (RedirectException redir) {
-                    status.redirect = redir.getMessage();
-                } catch (WrappedException wx) {
-                    status.exception = wx.getWrappedException();
-                } catch (Exception x) {
-                    status.exception = x;
-                }
-                return status;
-            }
-        });
         try {
-            Status status = future.get(requestTimeout, TimeUnit.SECONDS);
-            if (status.redirect != null) {
-                res.sendRedirect(status.redirect);
-            } else if (status.exception != null) {
-                throw new ServletException(status.exception);
-            }
-        } catch (InterruptedException x) {
-            throw new ServletException("Interrupted", x);
-        } catch (ExecutionException x) {
-            throw new ServletException("Execution Error", x);
-        } catch (TimeoutException x) {
-            throw new ServletException("Request timed out", x);
+            engine.invoke(moduleName, functionName, new Request(req), new Response(res));
+        } catch (RedirectException redir) {
+            res.sendRedirect(redir.getMessage());
+        } catch (NoSuchMethodException x) {
+            throw new ServletException("Method not found", x);
         }
     }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.