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

changeset 151
b3f14cd4f3ab
parent 145
6d2d69fd1c12
child 157
1e6f16fad3a5
equal deleted inserted replaced
150:822b7e3d064d 151:b3f14cd4f3ab
99 * 99 *
100 * @param connection the SQL connection 100 * @param connection the SQL connection
101 * @return a set of data access objects 101 * @return a set of data access objects
102 */ 102 */
103 private DataAccessObjects createDataAccessObjects(Connection connection) throws SQLException { 103 private DataAccessObjects createDataAccessObjects(Connection connection) throws SQLException {
104 final var df = (DatabaseFacade) getServletContext().getAttribute(DatabaseFacade.SC_ATTR_NAME); 104 final var df = (DataSourceProvider) getServletContext().getAttribute(DataSourceProvider.Companion.getSC_ATTR_NAME());
105 if (df.getSQLDialect() == DatabaseFacade.Dialect.Postgres) { 105 if (df.getDialect() == DatabaseDialect.Postgres) {
106 return new PGDataAccessObjects(connection); 106 return new PGDataAccessObjects(connection);
107 } 107 }
108 throw new AssertionError("Non-exhaustive if-else - this is a bug."); 108 throw new UnsupportedOperationException("Non-exhaustive if-else - this is a bug.");
109 } 109 }
110 110
111 private ResponseType invokeMapping(Map.Entry<PathPattern, Method> mapping, HttpServletRequest req, HttpServletResponse resp, DataAccessObjects dao) throws IOException { 111 private ResponseType invokeMapping(Map.Entry<PathPattern, Method> mapping, HttpServletRequest req, HttpServletResponse resp, DataAccessObjects dao) throws IOException {
112 final var pathPattern = mapping.getKey(); 112 final var pathPattern = mapping.getKey();
113 final var method = mapping.getValue(); 113 final var method = mapping.getValue();
432 } 432 }
433 return; 433 return;
434 } 434 }
435 435
436 // obtain a connection and create the data access objects 436 // obtain a connection and create the data access objects
437 final var db = (DatabaseFacade) req.getServletContext().getAttribute(DatabaseFacade.SC_ATTR_NAME); 437 final var db = (DataSourceProvider) req.getServletContext().getAttribute(DataSourceProvider.Companion.getSC_ATTR_NAME());
438 final var ds = db.getDataSource(); 438 final var ds = db.getDataSource();
439 if (ds == null) { 439 if (ds == null) {
440 resp.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE, "JNDI DataSource lookup failed. See log for details."); 440 resp.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE, "JNDI DataSource lookup failed. See log for details.");
441 return; 441 return;
442 } 442 }

mercurial