Mercurial > hg > digilib
changeset 1690:a0a8dbecb94c
Change web.xml setup to use WebServlet annotations.
Solves problem of having the correct web.xml when combining Servlets
via Maven profiles.
Works only with Servlet 3. For Servlet 2 you still need to patch
your own set of Servlets into web-2.4.xml.
You can still override Servlet mappings in web.xml if you want
(watch out for servlet-name).
author | Robert Casties <casties@mpiwg-berlin.mpg.de> |
---|---|
date | Mon, 26 Mar 2018 20:46:01 +0200 |
parents | 93b59a801711 |
children | 72215ed088ac |
files | iiif-presentation/src/main/java/digilib/servlet/Manifester.java pdf/pom.xml pdf/src/main/java/digilib/servlet/PDFCache.java servlet3/src/main/java/digilib/servlet/Scaler.java text/pom.xml text/src/main/java/digilib/servlet/Texter.java webapp/pom.xml webapp/src/main/webapp/WEB-INF/web-3.0.xml webapp/src/main/webapp/WEB-INF/web-additional.xml webapp/src/main/webapp/WEB-INF/web.xml |
diffstat | 10 files changed, 54 insertions(+), 66 deletions(-) [+] |
line wrap: on
line diff
--- a/iiif-presentation/src/main/java/digilib/servlet/Manifester.java Mon Mar 26 19:49:46 2018 +0200 +++ b/iiif-presentation/src/main/java/digilib/servlet/Manifester.java Mon Mar 26 20:46:01 2018 +0200 @@ -47,6 +47,7 @@ import javax.servlet.ServletContext; import javax.servlet.ServletException; import javax.servlet.ServletOutputStream; +import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -78,6 +79,7 @@ * @author casties * */ +@WebServlet(name = "Manifester", urlPatterns = { "/Manifester/*", "/servlet/Manifester/*" }) public class Manifester extends HttpServlet { private static final long serialVersionUID = 6678666342141409868L; @@ -100,7 +102,7 @@ /** DocuDirCache instance */ protected DocuDirCache dirCache; - /** use authentication */ + /** use authentication and authorization */ protected boolean useAuthorization = false; /** scaler servlet path */
--- a/pdf/pom.xml Mon Mar 26 19:49:46 2018 +0200 +++ b/pdf/pom.xml Mon Mar 26 20:46:01 2018 +0200 @@ -41,7 +41,6 @@ <profile> <id>servlet2</id> <activation> - <activeByDefault>true</activeByDefault> <property> <name>servletapi</name> <value>2</value> @@ -66,6 +65,7 @@ <profile> <id>servlet3</id> <activation> + <activeByDefault>true</activeByDefault> <property> <name>servletapi</name> <value>3</value>
--- a/pdf/src/main/java/digilib/servlet/PDFCache.java Mon Mar 26 19:49:46 2018 +0200 +++ b/pdf/src/main/java/digilib/servlet/PDFCache.java Mon Mar 26 20:46:01 2018 +0200 @@ -4,7 +4,7 @@ * #%L * A Servlet with a disk cache serving pdf documents made from digilib images. * %% - * Copyright (C) 2009 - 2013 MPIWG Berlin + * Copyright (C) 2009 - 2018 MPIWG Berlin * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as @@ -21,7 +21,7 @@ * <http://www.gnu.org/licenses/lgpl-3.0.html>. * #L% * Authors: Christopher Mielack, - * Robert Casties (robcast@berlios.de) + * Robert Casties (robcast@users.sf.net) */ import java.io.File; @@ -33,6 +33,7 @@ import javax.servlet.ServletConfig; import javax.servlet.ServletContext; import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -53,13 +54,15 @@ * If a document does not already exist, it will be enqueued for generation; if * it does exist, it is sent to the user. * - * @author cmielack + * @author cmielack, casties * */ -@SuppressWarnings("serial") +@WebServlet(name = "PDFCache", urlPatterns = { "/PDFCache/*", "/servlet/PDFCache/*" }) public class PDFCache extends HttpServlet { + private static final long serialVersionUID = 351326880003758192L; + public static String version = PDFServletConfiguration.getClassVersion(); /** logger for accounting requests */
--- a/servlet3/src/main/java/digilib/servlet/Scaler.java Mon Mar 26 19:49:46 2018 +0200 +++ b/servlet3/src/main/java/digilib/servlet/Scaler.java Mon Mar 26 20:46:01 2018 +0200 @@ -54,7 +54,7 @@ import digilib.io.ImageInput; import digilib.util.DigilibJobCenter; -@WebServlet(name = "Scaler", urlPatterns = { "/Scaler", "/servlet/Scaler/*" }, asyncSupported = true) +@WebServlet(name = "Scaler", urlPatterns = { "/Scaler/*", "/servlet/Scaler/*" }, asyncSupported = true) public class Scaler extends HttpServlet { private static final long serialVersionUID = 5289386646192471549L;
--- a/text/pom.xml Mon Mar 26 19:49:46 2018 +0200 +++ b/text/pom.xml Mon Mar 26 20:46:01 2018 +0200 @@ -22,7 +22,6 @@ <profile> <id>servlet2</id> <activation> - <activeByDefault>true</activeByDefault> <property> <name>servletapi</name> <value>2</value> @@ -47,6 +46,7 @@ <profile> <id>servlet3</id> <activation> + <activeByDefault>true</activeByDefault> <property> <name>servletapi</name> <value>3</value>
--- a/text/src/main/java/digilib/servlet/Texter.java Mon Mar 26 19:49:46 2018 +0200 +++ b/text/src/main/java/digilib/servlet/Texter.java Mon Mar 26 20:46:01 2018 +0200 @@ -32,6 +32,7 @@ import javax.servlet.ServletConfig; import javax.servlet.ServletContext; import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -54,6 +55,7 @@ * @author casties * */ +@WebServlet(name = "Texter", urlPatterns = { "/Texter/*", "/servlet/Texter/*" }) public class Texter extends HttpServlet { private static final long serialVersionUID = 6678666342141409867L;
--- a/webapp/pom.xml Mon Mar 26 19:49:46 2018 +0200 +++ b/webapp/pom.xml Mon Mar 26 20:46:01 2018 +0200 @@ -258,7 +258,6 @@ <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <configuration> - <webXml>${basedir}/src/main/webapp/WEB-INF/web-3.0.xml</webXml> <classifier>srv3</classifier> </configuration> </plugin> @@ -287,7 +286,6 @@ <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <configuration> - <webXml>${basedir}/src/main/webapp/WEB-INF/web-pdf.xml</webXml> <classifier>srv3pdf</classifier> </configuration> </plugin> @@ -328,7 +326,6 @@ <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <configuration> - <webXml>${basedir}/src/main/webapp/WEB-INF/web-iiif-pres.xml</webXml> <classifier>srv3p</classifier> </configuration> </plugin>
--- a/webapp/src/main/webapp/WEB-INF/web-3.0.xml Mon Mar 26 19:49:46 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,55 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<web-app - xmlns="http://java.sun.com/xml/ns/javaee" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" - version="3.0"> - - <!-- General description of your web application --> - <display-name> - digilib - </display-name> - <description> - This is the web frontend of the Digital Document Library. - </description> - <!-- The Intialisation Listener (also configured by annotation) --> - <listener> - <listener-class> - digilib.conf.DigilibServlet3Configuration - </listener-class> - </listener> - <!-- The Scaler servlet (also configured by annotation) --> - <servlet> - <servlet-name> - Scaler - </servlet-name> - <servlet-class> - digilib.servlet.Scaler - </servlet-class> - <!-- Load this servlet at server startup time --> - <load-on-startup> - 5 - </load-on-startup> - <!-- yes we do use async, Jetty! --> - <async-supported>true</async-supported> - </servlet> - <!-- The mapping for the Scaler servlet --> - <servlet-mapping> - <servlet-name> - Scaler - </servlet-name> - <url-pattern> - /servlet/Scaler/* - </url-pattern> - </servlet-mapping> - <servlet-mapping> - <servlet-name> - Scaler - </servlet-name> - <url-pattern> - /Scaler/* - </url-pattern> - </servlet-mapping> - - -</web-app>
--- a/webapp/src/main/webapp/WEB-INF/web-additional.xml Mon Mar 26 19:49:46 2018 +0200 +++ b/webapp/src/main/webapp/WEB-INF/web-additional.xml Mon Mar 26 20:46:01 2018 +0200 @@ -5,6 +5,27 @@ Use at your own risk! --> + <!-- The Manifest servlet --> + <servlet> + <servlet-name>Manifester</servlet-name> + <servlet-class>digilib.servlet.Manifester</servlet-class> + </servlet> + <!-- The Intialisation Listener --> + <listener> + <listener-class> + digilib.conf.ManifestServletConfiguration + </listener-class> + </listener> + <!-- The mapping for the Manifest servlet --> + <servlet-mapping> + <servlet-name>Manifester</servlet-name> + <url-pattern>/servlet/Manifester/*</url-pattern> + </servlet-mapping> + <servlet-mapping> + <servlet-name>Manifester</servlet-name> + <url-pattern>/Manifester/*</url-pattern> + </servlet-mapping> + <!-- The Texter servlet --> <servlet> <servlet-name>Texter</servlet-name>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/webapp/src/main/webapp/WEB-INF/web.xml Mon Mar 26 20:46:01 2018 +0200 @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="UTF-8"?> +<web-app + xmlns="http://java.sun.com/xml/ns/javaee" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" + version="3.0"> + + <!-- General description of your web application --> + <display-name> + digilib + </display-name> + <description> + This is the web frontend of the Digital Document Library. + </description> + + <!-- everything else should be configured by annotations --> + +</web-app>