X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=source%2Fmir%2Fservlet%2FServletModuleDispatch.java;h=b98d35f2d75234827a908740c9d7cddbfc40a23b;hb=bd509ef78e9f9fdf45915a2e98e8021882a6cfba;hp=944defe8adf13317449eab6f5c716981a0076fe8;hpb=8563841098b6ab3e6233f61519e58b41dcc30266;p=mir.git
diff --git a/source/mir/servlet/ServletModuleDispatch.java b/source/mir/servlet/ServletModuleDispatch.java
index 944defe8..b98d35f2 100755
--- a/source/mir/servlet/ServletModuleDispatch.java
+++ b/source/mir/servlet/ServletModuleDispatch.java
@@ -35,81 +35,91 @@ import java.lang.reflect.*;
import javax.servlet.http.*;
import mir.servlet.ServletModuleException;
import mir.misc.*;
+import mir.log.*;
/**
* Dispatcher, calls the method passed to ServletModule Class, through the "do"
* Parameter (via POST or GET)
*
- * @version $Id: ServletModuleDispatch.java,v 1.7 2002/09/01 22:05:52 mh Exp $
+ * @version $Id: ServletModuleDispatch.java,v 1.8 2002/10/25 03:25:15 zapata Exp $
*
* @Author rk
*
*/
public final class ServletModuleDispatch {
- private static Logfile theLog;
- private static final Class[] SIGNATURE =
- { HttpServletRequest.class, HttpServletResponse.class };
+ private static LoggerWrapper logger;
+ private static final Class[] SIGNATURE = { HttpServletRequest.class, HttpServletResponse.class };
+ static {
+ logger = new LoggerWrapper("servlet.dispatch");
+ }
- static {
- theLog = Logfile.getInstance("/tmp/smod.dispatch");
- }
+ /**
+ * private constructor to prevent unwanted instantiation;
+ */
- /**
- * privater Konstruktor, um versehentliche Instantiierung zu verhindern
- */
- private ServletModuleDispatch () {
- }
+ 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)
- */
+ /**
+ * 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)
+ */
- public static void dispatch(ServletModule sMod, HttpServletRequest req,
- HttpServletResponse res) throws ServletModuleException, ServletModuleUserException
- {
- //sMod.predeliver(req,res);
+ public static void dispatch(ServletModule sMod, HttpServletRequest req,
+ HttpServletResponse res) throws ServletModuleException, ServletModuleUserException
+ {
+ //sMod.predeliver(req,res);
- String doParam = req.getParameter("do");
- theLog.printInfo("SerletModuleDispatch: " + sMod.toString() + " with method " + doParam);
- if (doParam == null) {
- if (sMod.defaultAction() != null) doParam = sMod.defaultAction();
- else throw new ServletModuleException("no parameter do supplied!");
- }
+ String doParam = req.getParameter("do");
+ logger.info("ServletModuleDispatch: " + sMod.toString() + " with method " + doParam);
+ if (doParam == null) {
+ if (sMod.defaultAction() != null)
+ doParam = sMod.defaultAction();
+ else
+ throw new ServletModuleException("no parameter do supplied!");
+ }
- try {
- Method method = sMod.getClass().getMethod(doParam,SIGNATURE);
- if (method != null) {
- method.invoke(sMod,new Object[] {req,res} );
- return;
- }
- else theLog.printDebugInfo("method lookup unsuccesful");
- }
- catch ( NoSuchMethodException e) { throw new ServletModuleException("no such method!" + e.toString());}
- catch ( SecurityException e) { throw new ServletModuleException("method not allowed!" + e.toString());}
- catch ( InvocationTargetException e) {
- if (e.getTargetException().getClass().getName().equals("mir.servlet.ServletModuleUserException")) {
- throw new ServletModuleUserException(((ServletModuleUserException)e.getTargetException()).getMsg());
- } else {
- e.printStackTrace();
- throw new ServletModuleException(e.getTargetException().toString());
- }
- }
- catch ( IllegalAccessException e) { throw new ServletModuleException("illegal method not allowed!" + e.toString());}
+ try {
+ Method method = sMod.getClass().getMethod(doParam,SIGNATURE);
+ if (method != null) {
+ method.invoke(sMod,new Object[] {req,res} );
+ 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());
+ }
+ }
+ catch ( IllegalAccessException e) {
+ throw new ServletModuleException("illegal method not allowed!" + e.getMessage());
+ }
- //hopefully we don't get here ...
- throw new ServletModuleException("delivery failed! -- ");
- }
+//hopefully we don't get here ...
+ throw new ServletModuleException("delivery failed! -- ");
+ }
}