X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=source%2Fmir%2Fservlet%2FServletModuleDispatch.java;fp=source%2Fmir%2Fservlet%2FServletModuleDispatch.java;h=ee84259b4df1dfb89649c15d090af551f804eb19;hb=1149ec9b078b0f9175b9c2d006313e6810e46ffb;hp=76570e06ea5ae6bf75abdad3c810b28d80797312;hpb=0a0c4d83471bdab28a17d42f9efb74c25ca84681;p=mir.git diff --git a/source/mir/servlet/ServletModuleDispatch.java b/source/mir/servlet/ServletModuleDispatch.java index 76570e06..ee84259b 100755 --- a/source/mir/servlet/ServletModuleDispatch.java +++ b/source/mir/servlet/ServletModuleDispatch.java @@ -16,67 +16,68 @@ import mir.misc.*; */ public final class ServletModuleDispatch { - static Logfile theLog; + private static Logfile theLog; + private static final Class[] SIGNATURE = + { HttpServletRequest.class, HttpServletResponse.class }; - static { - theLog = Logfile.getInstance("/tmp/smod.dispatch"); - } - /** - * privater Konstruktor, um versehentliche Instantiierung zu verhindern - */ - private ServletModuleDispatch () { - } + static { + theLog = Logfile.getInstance("/tmp/smod.dispatch"); + } - /** - * 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) - */ + /** + * privater Konstruktor, um versehentliche Instantiierung zu verhindern + */ + private ServletModuleDispatch () { + } - public static void dispatch(ServletModule sMod, HttpServletRequest req, - HttpServletResponse res) throws ServletModuleException, ServletModuleUserException - { - //sMod.predeliver(req,res); + /** + * 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) + */ - 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!"); - } + public static void dispatch(ServletModule sMod, HttpServletRequest req, + HttpServletResponse res) throws ServletModuleException, ServletModuleUserException + { + //sMod.predeliver(req,res); - Class[] params= { HttpServletRequest.class, HttpServletResponse.class}; + 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!"); + } - try { - Method method = sMod.getClass().getMethod(doParam,params); - 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());} - //catch ( ServletModuleException e ) { throw new ServletModuleException(e.toString()); } + 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());} - throw new ServletModuleException("delivery failed! -- "); - } + //hopefully we don't get here ... + throw new ServletModuleException("delivery failed! -- "); + } }