X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=source%2FMir.java;h=5545de527764f8fbfdb7ee218c540c79f4ad14cf;hb=14127fccd05fd4dc20411d3c551908103fcd28a9;hp=7fdcd327a3a44f658cc31c9e61f2ba62cd9ea17c;hpb=1f0ad3f2013909116569c243abbc02dde6c7161a;p=mir.git diff --git a/source/Mir.java b/source/Mir.java index 7fdcd327..5545de52 100755 --- a/source/Mir.java +++ b/source/Mir.java @@ -43,7 +43,6 @@ import javax.servlet.http.*; import java.io.IOException; import java.io.PrintWriter; import java.io.StringWriter; -import java.lang.reflect.Method; import java.util.*; import mircoders.module.ModuleUsers; @@ -53,7 +52,7 @@ import mircoders.entity.EntityUsers; public class Mir extends AbstractServlet { private static ModuleUsers usersModule = null; - private final static Map servletModuleInstanceHash = new HashMap(); + private final static Map servletModules = new HashMap(); private static Locale fallbackLocale = null; private static List loginLanguages = null; @@ -153,9 +152,7 @@ public class Mir extends AbstractServlet { return user; } catch (Throwable t) { - t.printStackTrace(); - - throw new ServletException(t.toString()); + throw new ServletException(t.getMessage()); } } @@ -191,7 +188,6 @@ public class Mir extends AbstractServlet { moduleName="Admin"; } - if (moduleName.equals("login")) { String target = (String) session.getAttribute("login.target"); @@ -210,8 +206,8 @@ public class Mir extends AbstractServlet { } else { try { - ServletModule servletModule = getServletModuleForName(moduleName); - ServletModuleDispatch.dispatch(servletModule, aRequest, aResponse); + AdminServletModule servletModule = getServletModuleForName(moduleName); + servletModule.handleRequest(aRequest, aResponse); sessionConnectTime = System.currentTimeMillis() - startTime; logger.info("EXECTIME (" + moduleName + "): " + sessionConnectTime + " ms"); @@ -231,8 +227,6 @@ public class Mir extends AbstractServlet { } } catch (Throwable t) { - t.printStackTrace(logger.asPrintWriter(LoggerWrapper.DEBUG_MESSAGE)); - throw new ServletException(t.toString()); } } @@ -240,42 +234,12 @@ public class Mir extends AbstractServlet { /** * caching routine to get a module for a module name * - * @param moduleName the module name + * @param aModuleName the module name * @return the requested module * @throws ServletModuleExc */ - - private static ServletModule getServletModuleForName(String moduleName) throws ServletModuleExc { - // Instance in Map ? - if (!servletModuleInstanceHash.containsKey(moduleName)) { - // was not found in hash... - try { - Class theServletModuleClass = null; - - try { - // first we try to get ServletModule from stern.che3.servlet - theServletModuleClass = - Class.forName("mircoders.servlet.ServletModule" + moduleName); - } - catch (ClassNotFoundException e) { - // on failure, we try to get it from lib-layer - theServletModuleClass = - Class.forName("mir.servlet.ServletModule" + moduleName); - } - - Method m = theServletModuleClass.getMethod("getInstance", null); - ServletModule smod = (ServletModule) m.invoke(null, null); - - // we put it into map for further reference - servletModuleInstanceHash.put(moduleName, smod); - - return smod; - } - catch (Exception e) { - throw new ServletModuleExc("*** error resolving classname for " + moduleName + " -- " + e.getMessage()); - } - } - return (ServletModule) servletModuleInstanceHash.get(moduleName); + private static AdminServletModule getServletModuleForName(String aModuleName) throws ServletModuleExc { + return ServletHelper.getServletModule(aModuleName); } private void handleUserError(HttpServletRequest aRequest, HttpServletResponse aResponse, ServletModuleUserExc anException) {