src/main/java/de/uapcore/lightpit/AbstractLightPITServlet.java

changeset 36
0f4f8f255c32
parent 34
824d4042c857
child 38
cf85ef18f231
     1.1 --- a/src/main/java/de/uapcore/lightpit/AbstractLightPITServlet.java	Sun May 10 10:11:10 2020 +0200
     1.2 +++ b/src/main/java/de/uapcore/lightpit/AbstractLightPITServlet.java	Sun May 10 10:11:37 2020 +0200
     1.3 @@ -52,14 +52,9 @@
     1.4      private static final String HTML_FULL_DISPATCHER = Functions.jspPath("html_full");
     1.5  
     1.6      /**
     1.7 -     * Store a reference to the annotation for quicker access.
     1.8 -     */
     1.9 -    private LightPITModule moduleInfo = null;
    1.10 -
    1.11 -    /**
    1.12       * The EL proxy is necessary, because the EL resolver cannot handle annotation properties.
    1.13       */
    1.14 -    private LightPITModule.ELProxy moduleInfoELProxy = null;
    1.15 +    private LightPITModule.ELProxy moduleInfo = null;
    1.16  
    1.17  
    1.18      @FunctionalInterface
    1.19 @@ -88,15 +83,6 @@
    1.20      }
    1.21  
    1.22      /**
    1.23 -     * Returns the annotated module information.
    1.24 -     *
    1.25 -     * @return the module annotation
    1.26 -     */
    1.27 -    public final LightPITModule getModuleInfo() {
    1.28 -        return moduleInfo;
    1.29 -    }
    1.30 -
    1.31 -    /**
    1.32       * Gives implementing modules access to the {@link DatabaseFacade}.
    1.33       *
    1.34       * @return the database facade
    1.35 @@ -118,8 +104,8 @@
    1.36  
    1.37      @Override
    1.38      public void init() throws ServletException {
    1.39 -        moduleInfo = this.getClass().getAnnotation(LightPITModule.class);
    1.40 -        moduleInfoELProxy = moduleInfo == null ? null : LightPITModule.ELProxy.convert(moduleInfo);
    1.41 +        moduleInfo = Optional.ofNullable(this.getClass().getAnnotation(LightPITModule.class))
    1.42 +                .map(LightPITModule.ELProxy::new).orElse(null);
    1.43  
    1.44          if (moduleInfo != null) {
    1.45              scanForRequestMappings();
    1.46 @@ -228,7 +214,7 @@
    1.47      private void forwardToFullView(HttpServletRequest req, HttpServletResponse resp)
    1.48              throws IOException, ServletException {
    1.49  
    1.50 -        req.setAttribute(Constants.REQ_ATTR_MENU, getModuleManager().getMainMenu(getDatabaseFacade()));
    1.51 +        req.setAttribute(Constants.REQ_ATTR_MENU, getModuleManager().getMainMenu());
    1.52          req.getRequestDispatcher(HTML_FULL_DISPATCHER).forward(req, resp);
    1.53      }
    1.54  
    1.55 @@ -255,9 +241,6 @@
    1.56      private void doProcess(HttpMethod method, HttpServletRequest req, HttpServletResponse resp)
    1.57              throws ServletException, IOException {
    1.58  
    1.59 -        // Synchronize module information with database
    1.60 -        getModuleManager().syncWithDatabase(getDatabaseFacade());
    1.61 -
    1.62          // choose the requested language as session language (if available) or fall back to english, otherwise
    1.63          HttpSession session = req.getSession();
    1.64          if (session.getAttribute(Constants.SESSION_ATTR_LANGUAGE) == null) {
    1.65 @@ -275,7 +258,7 @@
    1.66          // set some internal request attributes
    1.67          req.setAttribute(Constants.REQ_ATTR_PATH, Functions.fullPath(req));
    1.68          req.setAttribute(Constants.REQ_ATTR_MODULE_CLASSNAME, this.getClass().getName());
    1.69 -        Optional.ofNullable(moduleInfoELProxy).ifPresent((proxy) -> req.setAttribute(Constants.REQ_ATTR_MODULE_INFO, proxy));
    1.70 +        Optional.ofNullable(moduleInfo).ifPresent((proxy) -> req.setAttribute(Constants.REQ_ATTR_MODULE_INFO, proxy));
    1.71  
    1.72  
    1.73          // call the handler, if available, or send an HTTP 404 error

mercurial