# HG changeset patch # User Mike Becker # Date 1590234724 -7200 # Node ID bb4c52bf34393ec3a82dcc766cfa5a1c6a998f68 # Parent 192298f8161f57e8c5ec55ec3d2ddcd601d3a6cb bloat removal 2/3 - moduleInfo diff -r 192298f8161f -r bb4c52bf3439 src/main/java/de/uapcore/lightpit/AbstractLightPITServlet.java --- a/src/main/java/de/uapcore/lightpit/AbstractLightPITServlet.java Sat May 23 13:34:41 2020 +0200 +++ b/src/main/java/de/uapcore/lightpit/AbstractLightPITServlet.java Sat May 23 13:52:04 2020 +0200 @@ -58,10 +58,6 @@ private static final String SITE_JSP = Functions.jspPath("site"); - /** - * The EL proxy is necessary, because the EL resolver cannot handle annotation properties. - */ - private LightPITModule.ELProxy moduleInfo = null; @FunctionalInterface protected interface SQLFindFunction { @@ -102,6 +98,12 @@ return (ModuleManager) getServletContext().getAttribute(ModuleManager.SC_ATTR_NAME); } + /** + * Returns the name of the resource bundle associated with this servlet. + * @return the resource bundle base name + */ + protected abstract String getResourceBundleName(); + /** * Creates a set of data access objects for the specified connection. @@ -150,12 +152,7 @@ @Override public void init() throws ServletException { - moduleInfo = Optional.ofNullable(this.getClass().getAnnotation(LightPITModule.class)) - .map(LightPITModule.ELProxy::new).orElse(null); - - if (moduleInfo != null) { - scanForRequestMappings(); - } + scanForRequestMappings(); LOG.trace("{} initialized", getServletName()); } @@ -387,7 +384,7 @@ final String fullPath = Functions.fullPath(req); req.setAttribute(Constants.REQ_ATTR_BASE_HREF, Functions.baseHref(req)); req.setAttribute(Constants.REQ_ATTR_PATH, fullPath); - Optional.ofNullable(moduleInfo).ifPresent((proxy) -> req.setAttribute(Constants.REQ_ATTR_MODULE_INFO, proxy)); + req.setAttribute(Constants.REQ_ATTR_RESOURCE_BUNDLE, getResourceBundleName()); // if this is an error path, bypass the normal flow if (fullPath.startsWith("/error/")) { diff -r 192298f8161f -r bb4c52bf3439 src/main/java/de/uapcore/lightpit/Constants.java --- a/src/main/java/de/uapcore/lightpit/Constants.java Sat May 23 13:34:41 2020 +0200 +++ b/src/main/java/de/uapcore/lightpit/Constants.java Sat May 23 13:52:04 2020 +0200 @@ -62,9 +62,9 @@ public static final String CTX_ATTR_DB_DIALECT = "db-dialect"; /** - * Key for the request attribute containing the {@link LightPITModule} information of the currently dispatching module. + * Key for the request attribute containing the resource bundle name. */ - public static final String REQ_ATTR_MODULE_INFO = fqn(AbstractLightPITServlet.class, "moduleInfo"); + public static final String REQ_ATTR_RESOURCE_BUNDLE = fqn(AbstractLightPITServlet.class, "bundleName"); /** * Key for the request attribute containing the menu list. diff -r 192298f8161f -r bb4c52bf3439 src/main/java/de/uapcore/lightpit/Functions.java --- a/src/main/java/de/uapcore/lightpit/Functions.java Sat May 23 13:34:41 2020 +0200 +++ b/src/main/java/de/uapcore/lightpit/Functions.java Sat May 23 13:52:04 2020 +0200 @@ -75,28 +75,6 @@ } /** - * Returns the module path of the given LightPIT Servlet module. - *

- * If you specify a malformed LightPIT servlet, which does not have a module - * annotation, the path to the /error/404.html page is returned. - * - * @param clazz the servlet class - * @return the module path - */ - public static String modulePathOf(Class clazz) { - Optional moduleInfo = Optional.ofNullable(clazz.getAnnotation(LightPITModule.class)); - if (moduleInfo.isPresent()) { - return moduleInfo.get().modulePath(); - } else { - LOG.warn( - "{} is a LightPIT Servlet but is missing the module annotation.", - clazz.getName() - ); - return "/error/404.html"; - } - } - - /** * This class is not instantiatable. */ private Functions() { diff -r 192298f8161f -r bb4c52bf3439 src/main/java/de/uapcore/lightpit/modules/ErrorModule.java --- a/src/main/java/de/uapcore/lightpit/modules/ErrorModule.java Sat May 23 13:34:41 2020 +0200 +++ b/src/main/java/de/uapcore/lightpit/modules/ErrorModule.java Sat May 23 13:52:04 2020 +0200 @@ -51,6 +51,11 @@ public static final String REQ_ATTR_RETURN_LINK = "returnLink"; + @Override + protected String getResourceBundleName() { + return "localization.error"; + } + @RequestMapping(requestPath = "generic", method = HttpMethod.GET) public ResponseType onError(HttpServletRequest req, HttpServletResponse resp) { Optional.ofNullable(req.getHeader("Referer")).ifPresent( diff -r 192298f8161f -r bb4c52bf3439 src/main/java/de/uapcore/lightpit/modules/LanguageModule.java --- a/src/main/java/de/uapcore/lightpit/modules/LanguageModule.java Sat May 23 13:34:41 2020 +0200 +++ b/src/main/java/de/uapcore/lightpit/modules/LanguageModule.java Sat May 23 13:52:04 2020 +0200 @@ -55,6 +55,11 @@ private final List languages = new ArrayList<>(); @Override + protected String getResourceBundleName() { + return "localization.language"; + } + + @Override public void init() throws ServletException { super.init(); diff -r 192298f8161f -r bb4c52bf3439 src/main/java/de/uapcore/lightpit/modules/ProjectsModule.java --- a/src/main/java/de/uapcore/lightpit/modules/ProjectsModule.java Sat May 23 13:34:41 2020 +0200 +++ b/src/main/java/de/uapcore/lightpit/modules/ProjectsModule.java Sat May 23 13:52:04 2020 +0200 @@ -133,6 +133,10 @@ } } + @Override + protected String getResourceBundleName() { + return "localization.projects"; + } /** * Creates the breadcrumb menu. diff -r 192298f8161f -r bb4c52bf3439 src/main/java/de/uapcore/lightpit/modules/UsersModule.java --- a/src/main/java/de/uapcore/lightpit/modules/UsersModule.java Sat May 23 13:34:41 2020 +0200 +++ b/src/main/java/de/uapcore/lightpit/modules/UsersModule.java Sat May 23 13:52:04 2020 +0200 @@ -53,6 +53,11 @@ private static final Logger LOG = LoggerFactory.getLogger(UsersModule.class); + @Override + protected String getResourceBundleName() { + return "localization.users"; + } + @RequestMapping(method = HttpMethod.GET) public ResponseType index(HttpServletRequest req, DataAccessObjects dao) throws SQLException { final var userDao = dao.getUserDao(); diff -r 192298f8161f -r bb4c52bf3439 src/main/webapp/WEB-INF/jsp/issue-form.jsp --- a/src/main/webapp/WEB-INF/jsp/issue-form.jsp Sat May 23 13:34:41 2020 +0200 +++ b/src/main/webapp/WEB-INF/jsp/issue-form.jsp Sat May 23 13:52:04 2020 +0200 @@ -25,19 +25,16 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --%> <%@page pageEncoding="UTF-8" %> -<%@page import="de.uapcore.lightpit.Constants" %> <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> - - -

+ @@ -165,10 +162,10 @@ - ./${moduleInfo.modulePath}/view?pid=${issue.project.id} + ./projects/view?pid=${issue.project.id} - ./${moduleInfo.modulePath}/ + ./projects/ diff -r 192298f8161f -r bb4c52bf3439 src/main/webapp/WEB-INF/jsp/project-details.jsp --- a/src/main/webapp/WEB-INF/jsp/project-details.jsp Sat May 23 13:34:41 2020 +0200 +++ b/src/main/webapp/WEB-INF/jsp/project-details.jsp Sat May 23 13:52:04 2020 +0200 @@ -25,20 +25,18 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --%> <%@page pageEncoding="UTF-8" %> -<%@page import="de.uapcore.lightpit.Constants" %> <%@page import="de.uapcore.lightpit.modules.ProjectsModule" %> <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> -
- - + +
@@ -53,7 +51,7 @@ - diff -r 192298f8161f -r bb4c52bf3439 src/main/webapp/WEB-INF/jsp/project-form.jsp --- a/src/main/webapp/WEB-INF/jsp/project-form.jsp Sat May 23 13:34:41 2020 +0200 +++ b/src/main/webapp/WEB-INF/jsp/project-form.jsp Sat May 23 13:52:04 2020 +0200 @@ -25,16 +25,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --%> <%@page pageEncoding="UTF-8" %> -<%@page import="de.uapcore.lightpit.Constants" %> <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> - - - +
+
@@ -71,8 +68,9 @@ diff -r 192298f8161f -r bb4c52bf3439 src/main/webapp/WEB-INF/jsp/projects.jsp --- a/src/main/webapp/WEB-INF/jsp/projects.jsp Sat May 23 13:34:41 2020 +0200 +++ b/src/main/webapp/WEB-INF/jsp/projects.jsp Sat May 23 13:52:04 2020 +0200 @@ -25,12 +25,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --%> <%@page pageEncoding="UTF-8" %> -<%@page import="de.uapcore.lightpit.Constants" %> <%@page import="de.uapcore.lightpit.modules.ProjectsModule" %> <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> - @@ -42,7 +40,7 @@
- +
@@ -66,8 +64,8 @@
- - +
- + + +
+ diff -r 192298f8161f -r bb4c52bf3439 src/main/webapp/WEB-INF/jsp/site.jsp --- a/src/main/webapp/WEB-INF/jsp/site.jsp Sat May 23 13:34:41 2020 +0200 +++ b/src/main/webapp/WEB-INF/jsp/site.jsp Sat May 23 13:52:04 2020 +0200 @@ -52,8 +52,8 @@ <%-- Define an alias for the additional stylesheet --%> -<%-- Define an alias for the module info --%> - +<%-- Define an alias for the bundle name --%> + <%-- Apply the session locale (should always be present, but check nevertheless) --%> @@ -63,15 +63,15 @@ <%-- Selected project, if any --%> +<%-- Load resource bundles --%> + + + - LightPIT - - <fmt:bundle basename="${moduleInfo.bundleBaseName}"> - <fmt:message key="pageTitle"/> - </fmt:bundle> - + LightPIT - <fmt:message key="pageTitle"/> @@ -96,8 +96,6 @@
- -
diff -r 192298f8161f -r bb4c52bf3439 src/main/webapp/WEB-INF/jsp/user-form.jsp --- a/src/main/webapp/WEB-INF/jsp/user-form.jsp Sat May 23 13:34:41 2020 +0200 +++ b/src/main/webapp/WEB-INF/jsp/user-form.jsp Sat May 23 13:52:04 2020 +0200 @@ -25,15 +25,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --%> <%@page pageEncoding="UTF-8" %> -<%@page import="de.uapcore.lightpit.Constants" %> <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> - - - + @@ -62,8 +59,9 @@ diff -r 192298f8161f -r bb4c52bf3439 src/main/webapp/WEB-INF/jsp/users.jsp --- a/src/main/webapp/WEB-INF/jsp/users.jsp Sat May 23 13:34:41 2020 +0200 +++ b/src/main/webapp/WEB-INF/jsp/users.jsp Sat May 23 13:52:04 2020 +0200 @@ -25,12 +25,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --%> <%@page pageEncoding="UTF-8" %> -<%@page import="de.uapcore.lightpit.Constants" %> <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> - - @@ -40,7 +37,7 @@
- +
@@ -54,7 +51,7 @@
- + diff -r 192298f8161f -r bb4c52bf3439 src/main/webapp/WEB-INF/jsp/version-form.jsp --- a/src/main/webapp/WEB-INF/jsp/version-form.jsp Sat May 23 13:34:41 2020 +0200 +++ b/src/main/webapp/WEB-INF/jsp/version-form.jsp Sat May 23 13:52:04 2020 +0200 @@ -25,17 +25,14 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --%> <%@page pageEncoding="UTF-8" %> -<%@page import="de.uapcore.lightpit.Constants" %> <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> - - - +
- + + +
@@ -83,10 +80,10 @@ - ./${moduleInfo.modulePath}/view?pid=${version.project.id} + ./projects/view?pid=${version.project.id} - ./${moduleInfo.modulePath}/ + ./projects/ diff -r 192298f8161f -r bb4c52bf3439 src/main/webapp/index.jsp --- a/src/main/webapp/index.jsp Sat May 23 13:34:41 2020 +0200 +++ b/src/main/webapp/index.jsp Sat May 23 13:52:04 2020 +0200 @@ -24,9 +24,7 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --%> -<%@page import="de.uapcore.lightpit.Functions" %> -<%@ page import="de.uapcore.lightpit.modules.ProjectsModule" %> <% response.setStatus(response.SC_MOVED_TEMPORARILY); - response.setHeader("Location", Functions.modulePathOf(ProjectsModule.class)); + response.setHeader("Location", "/projects/"); %>