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;
*/
* @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);
if (sMod.defaultAction() != null)
doParam = sMod.defaultAction();
else
- throw new ServletModuleException("no parameter do supplied!");
+ throw new ServletModuleExc("no parameter do supplied!");
}
try {
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! -- ");
}
}