working on encoding
[mir.git] / source / mir / servlet / ServletModuleDispatch.java
index b98d35f..1c58dd9 100755 (executable)
 
 package  mir.servlet;
 
-import  java.lang.reflect.*;
-import  javax.servlet.http.*;
-import  mir.servlet.ServletModuleException;
-import  mir.misc.*;
-import  mir.log.*;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import mir.log.LoggerWrapper;
 
 
 /**
  * Dispatcher, calls the method passed to ServletModule Class, through the "do"
  * Parameter (via POST or GET)
  *
- * @version $Id: ServletModuleDispatch.java,v 1.8 2002/10/25 03:25:15 zapata Exp $
+ * @version $Id: ServletModuleDispatch.java,v 1.13 2003/03/06 05:40:39 zapata Exp $
  *
  * @Author rk
  *
  */
 public final class ServletModuleDispatch {
 
-  private static LoggerWrapper logger;
+  private static LoggerWrapper logger = new LoggerWrapper("ServletModule.Dispatch");
   private static final Class[] SIGNATURE = { HttpServletRequest.class, HttpServletResponse.class };
 
-  static {
-    logger = new LoggerWrapper("servlet.dispatch");
-  }
-
  /**
   * private constructor to prevent unwanted instantiation;
   */
@@ -74,11 +72,11 @@ public final class ServletModuleDispatch {
          * @param res Http-Response, die vom Dispatcher an die Methode des
          *    ServletModules durchgereicht wird
          * @param sMod ServletModule, an das dispatched wird.
-         * @param mod Name des Modules als String (fΓΌr Logfile)
+         * @param mod Name des Modules als String (f?r Logfile)
          */
 
   public static void dispatch(ServletModule sMod, HttpServletRequest req,
-                              HttpServletResponse res) throws ServletModuleException, ServletModuleUserException
+          HttpServletResponse res) throws ServletModuleExc, ServletModuleUserExc, ServletModuleFailure
   {
     //sMod.predeliver(req,res);
 
@@ -88,7 +86,7 @@ public final class ServletModuleDispatch {
       if (sMod.defaultAction() != null)
         doParam = sMod.defaultAction();
       else
-        throw new ServletModuleException("no parameter do supplied!");
+        throw new ServletModuleExc("no parameter do supplied!");
     }
 
     try {
@@ -100,26 +98,21 @@ public final class ServletModuleDispatch {
       else logger.debug("method lookup unsuccesful");
     }
     catch ( NoSuchMethodException e) {
-      throw new ServletModuleException("no such method '"+doParam+"' (" + e.getMessage() + ")");
+      throw new ServletModuleFailure("no such method '"+doParam+"' (" + e.getMessage() + ")", e);
     }
     catch ( SecurityException e) {
-      throw new ServletModuleException("method not allowed!" + e.getMessage());
+      throw new ServletModuleFailure("method not allowed!" + e.getMessage(), e);
     }
     catch ( InvocationTargetException e) {
-      System.out.println(e.getMessage());
-      if (e.getTargetException() instanceof ServletModuleUserException) {
-        throw new ServletModuleUserException(e.getTargetException().getMessage());
-      }
-      else {
-        e.printStackTrace();
-        throw new ServletModuleException(e.getTargetException().getMessage());
-      }
+      logger.debug( "invocation target exception: " + e.getMessage());
+
+      throw new ServletModuleFailure(e.getTargetException().getMessage(), e.getTargetException());
     }
     catch ( IllegalAccessException e) {
-      throw new ServletModuleException("illegal method not allowed!" + e.getMessage());
+      throw new ServletModuleFailure("illegal method not allowed!" + e.getMessage(), e);
+    }
+    catch (Throwable t) {
+      throw new ServletModuleFailure(t);
     }
-
-//hopefully we don't get here ...
-    throw new ServletModuleException("delivery failed! -- ");
   }
 }