X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=source%2Fmir%2Fservlet%2FServletModuleDispatch.java;h=f5e841bbec77694a865adf5e8ce7cb26689eb1ff;hb=aa507bfd18e723d21e63454a26af3320bb8c27f2;hp=77c49cbb71e47163930dd9a140514336ee96265f;hpb=9af9180576ade4481f9a2f61379fb3ba1191f202;p=mir.git
diff --git a/source/mir/servlet/ServletModuleDispatch.java b/source/mir/servlet/ServletModuleDispatch.java
index 77c49cbb..f5e841bb 100755
--- a/source/mir/servlet/ServletModuleDispatch.java
+++ b/source/mir/servlet/ServletModuleDispatch.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2001, 2002 The Mir-coders group
+ * Copyright (C) 2001, 2002 The Mir-coders group
*
* This file is part of Mir.
*
@@ -18,31 +18,31 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, The Mir-coders gives permission to link
- * the code of this program with the com.oreilly.servlet library, any library
- * licensed under the Apache Software License, The Sun (tm) Java Advanced
- * Imaging library (JAI), The Sun JIMI library (or with modified versions of
- * the above that use the same license as the above), and distribute linked
- * combinations including the two. You must obey the GNU General Public
- * License in all respects for all of the code used other than the above
- * mentioned libraries. If you modify this file, you may extend this exception
- * to your version of the file, but you are not obligated to do so. If you do
- * not wish to do so, delete this exception statement from your version.
+ * the code of this program with any library licensed under the Apache Software License,
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library
+ * (or with modified versions of the above that use the same license as the above),
+ * and distribute linked combinations including the two. You must obey the
+ * GNU General Public License in all respects for all of the code used other than
+ * the above mentioned libraries. If you modify this file, you may extend this
+ * exception to your version of the file, but you are not obligated to do so.
+ * If you do not wish to do so, delete this exception statement from your version.
*/
-
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.10 2002/11/30 19:45:56 zapata Exp $
+ * @version $Id: ServletModuleDispatch.java,v 1.15.2.1 2003/09/03 17:49:38 zapata Exp $
*
* @Author rk
*
@@ -52,70 +52,53 @@ public final class ServletModuleDispatch {
private static LoggerWrapper logger = new LoggerWrapper("ServletModule.Dispatch");
private static final Class[] SIGNATURE = { HttpServletRequest.class, HttpServletResponse.class };
- /**
- * private constructor to prevent unwanted instantiation;
- */
+ /**
+ * private parameter-less constructor to prevent unwanted instantiation
+ */
private ServletModuleDispatch () {
}
- /**
- * Die Dispatch-Routine ruft das von dem Hauptservlet kommende ServletModule
- * mit dem per HttpServletRequest angegebenen Paramter do
auf.
- * Ist kein Parameter angegeben, so wird versucht, in die defaultAction
- * des ServletModules zu springen.
- *
- * @param req Http-Request, das vom Dispatcher an die Methode des
- * ServletModules durchgereicht wird
- * @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)
- */
+ /**
+ * Method to dispatch servletmodule requests.
+ *
+ * @param aServletModule
+ * @param aRequest
+ * @param aResponse
+ * @throws ServletModuleExc
+ * @throws ServletModuleUserExc
+ * @throws ServletModuleFailure
+ */
- public static void dispatch(ServletModule sMod, HttpServletRequest req,
- HttpServletResponse res) throws ServletModuleException, ServletModuleUserException
+ public static void dispatch(ServletModule aServletModule, HttpServletRequest aRequest,
+ HttpServletResponse aResponse) throws ServletModuleExc, ServletModuleUserExc, ServletModuleFailure
{
- //sMod.predeliver(req,res);
-
- String doParam = req.getParameter("do");
- logger.info("ServletModuleDispatch: " + sMod.toString() + " with method " + doParam);
+ String doParam = aRequest.getParameter("do");
+ logger.info("ServletModuleDispatch: " + aServletModule.toString() + " with method " + doParam);
if (doParam == null) {
- if (sMod.defaultAction() != null)
- doParam = sMod.defaultAction();
+ if (aServletModule.defaultAction() != null)
+ doParam = aServletModule.defaultAction();
else
- throw new ServletModuleException("no parameter do supplied!");
+ throw new ServletModuleExc("no parameter do supplied!");
}
try {
- Method method = sMod.getClass().getMethod(doParam,SIGNATURE);
+ Method method = aServletModule.getClass().getMethod(doParam,SIGNATURE);
if (method != null) {
- method.invoke(sMod,new Object[] {req,res} );
+ method.invoke(aServletModule,new Object[] {aRequest,aResponse} );
return;
}
else logger.debug("method lookup unsuccesful");
}
- catch ( NoSuchMethodException e) {
- throw new ServletModuleException("no such method '"+doParam+"' (" + e.getMessage() + ")");
- }
- catch ( SecurityException e) {
- throw new ServletModuleException("method not allowed!" + e.getMessage());
- }
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.error( "invocation target exception: " + e.toString());
+ e.getTargetException().printStackTrace(logger.asPrintWriter(LoggerWrapper.DEBUG_MESSAGE));
+
+ throw new ServletModuleFailure(e.getTargetException().getMessage(), e.getTargetException());
}
- catch ( IllegalAccessException e) {
- throw new ServletModuleException("illegal method not allowed!" + e.getMessage());
+ catch (Throwable t) {
+ logger.error( "ServletModuleDispatch: " + t.toString());
+ throw new ServletModuleFailure(t);
}
-
-//hopefully we don't get here ...
- throw new ServletModuleException("delivery failed! -- ");
}
}