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

changeset 180
009700915269
parent 179
623c340058f3
child 182
53f0e2685ad5
equal deleted inserted replaced
179:623c340058f3 180:009700915269
1 /* 1 /*
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3 * 3 *
4 * Copyright 2018 Mike Becker. All rights reserved. 4 * Copyright 2021 Mike Becker. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met: 7 * modification, are permitted provided that the following conditions are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
64 * <p> 64 * <p>
65 * The reason for this is the different handling of empty paths in 65 * The reason for this is the different handling of empty paths in
66 * {@link HttpServletRequest#getPathInfo()}. 66 * {@link HttpServletRequest#getPathInfo()}.
67 */ 67 */
68 private final Map<HttpMethod, Map<PathPattern, Method>> mappings = new HashMap<>(); 68 private final Map<HttpMethod, Map<PathPattern, Method>> mappings = new HashMap<>();
69
70 /**
71 * Returns the name of the resource bundle associated with this servlet.
72 *
73 * @return the resource bundle base name
74 */
75 protected abstract String getResourceBundleName();
76
77 69
78 /** 70 /**
79 * Creates a set of data access objects for the specified connection. 71 * Creates a set of data access objects for the specified connection.
80 * 72 *
81 * @param connection the SQL connection 73 * @param connection the SQL connection
412 404
413 // set some internal request attributes 405 // set some internal request attributes
414 final String fullPath = req.getServletPath() + Optional.ofNullable(req.getPathInfo()).orElse(""); 406 final String fullPath = req.getServletPath() + Optional.ofNullable(req.getPathInfo()).orElse("");
415 req.setAttribute(Constants.REQ_ATTR_BASE_HREF, baseHref(req)); 407 req.setAttribute(Constants.REQ_ATTR_BASE_HREF, baseHref(req));
416 req.setAttribute(Constants.REQ_ATTR_PATH, fullPath); 408 req.setAttribute(Constants.REQ_ATTR_PATH, fullPath);
417 req.setAttribute(Constants.REQ_ATTR_RESOURCE_BUNDLE, getResourceBundleName());
418 409
419 // if this is an error path, bypass the normal flow 410 // if this is an error path, bypass the normal flow
420 if (fullPath.startsWith("/error/")) { 411 if (fullPath.startsWith("/error/")) {
421 final var mapping = findMapping(method, req); 412 final var mapping = findMapping(method, req);
422 if (mapping.isPresent()) { 413 if (mapping.isPresent()) {

mercurial