makes LightPITServlet abstract

Fri, 15 Dec 2017 17:39:54 +0100

author
Mike Becker <universe@uap-core.de>
date
Fri, 15 Dec 2017 17:39:54 +0100
changeset 9
20a9b2bc9063
parent 8
2dfdb79b5344
child 10
89e3e6e28b69

makes LightPITServlet abstract

src/java/de/uapcore/lightpit/AbstractLightPITServlet.java file | annotate | diff | comparison | revisions
src/java/de/uapcore/lightpit/LightPITServlet.java file | annotate | diff | comparison | revisions
src/java/de/uapcore/lightpit/ModuleManager.java file | annotate | diff | comparison | revisions
src/java/de/uapcore/lightpit/modules/HomeModule.java file | annotate | diff | comparison | revisions
src/java/de/uapcore/lightpit/modules/VersionsModule.java file | annotate | diff | comparison | revisions
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/java/de/uapcore/lightpit/AbstractLightPITServlet.java	Fri Dec 15 17:39:54 2017 +0100
     1.3 @@ -0,0 +1,55 @@
     1.4 +/*
     1.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
     1.6 + * 
     1.7 + * Copyright 2017 Mike Becker. All rights reserved.
     1.8 + * 
     1.9 + * Redistribution and use in source and binary forms, with or without
    1.10 + * modification, are permitted provided that the following conditions are met:
    1.11 + *
    1.12 + *   1. Redistributions of source code must retain the above copyright
    1.13 + *      notice, this list of conditions and the following disclaimer.
    1.14 + *
    1.15 + *   2. Redistributions in binary form must reproduce the above copyright
    1.16 + *      notice, this list of conditions and the following disclaimer in the
    1.17 + *      documentation and/or other materials provided with the distribution.
    1.18 + *
    1.19 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
    1.20 + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    1.21 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
    1.22 + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
    1.23 + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    1.24 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
    1.25 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
    1.26 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
    1.27 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
    1.28 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    1.29 + * POSSIBILITY OF SUCH DAMAGE.
    1.30 + * 
    1.31 + */
    1.32 +package de.uapcore.lightpit;
    1.33 +
    1.34 +import java.io.IOException;
    1.35 +import javax.servlet.ServletException;
    1.36 +import javax.servlet.http.HttpServlet;
    1.37 +import javax.servlet.http.HttpServletRequest;
    1.38 +import javax.servlet.http.HttpServletResponse;
    1.39 +
    1.40 +/**
    1.41 + * A special implementation of a HTTPServlet which is focused on implementing
    1.42 + * the necessary functionality for {@link LightPITModule}s.
    1.43 + */
    1.44 +public abstract class AbstractLightPITServlet extends HttpServlet {
    1.45 +    
    1.46 +    @Override
    1.47 +    protected final void doGet(HttpServletRequest req, HttpServletResponse resp)
    1.48 +            throws ServletException, IOException {
    1.49 +        
    1.50 +        resp.getWriter().println("It works!");
    1.51 +    }
    1.52 +
    1.53 +    @Override
    1.54 +    protected final void doPost(HttpServletRequest req, HttpServletResponse resp)
    1.55 +            throws ServletException, IOException {
    1.56 +    }
    1.57 +    
    1.58 +}
     2.1 --- a/src/java/de/uapcore/lightpit/LightPITServlet.java	Sun Dec 10 16:10:14 2017 +0100
     2.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.3 @@ -1,55 +0,0 @@
     2.4 -/*
     2.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
     2.6 - * 
     2.7 - * Copyright 2017 Mike Becker. All rights reserved.
     2.8 - * 
     2.9 - * Redistribution and use in source and binary forms, with or without
    2.10 - * modification, are permitted provided that the following conditions are met:
    2.11 - *
    2.12 - *   1. Redistributions of source code must retain the above copyright
    2.13 - *      notice, this list of conditions and the following disclaimer.
    2.14 - *
    2.15 - *   2. Redistributions in binary form must reproduce the above copyright
    2.16 - *      notice, this list of conditions and the following disclaimer in the
    2.17 - *      documentation and/or other materials provided with the distribution.
    2.18 - *
    2.19 - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
    2.20 - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    2.21 - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
    2.22 - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
    2.23 - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    2.24 - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
    2.25 - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
    2.26 - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
    2.27 - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
    2.28 - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    2.29 - * POSSIBILITY OF SUCH DAMAGE.
    2.30 - * 
    2.31 - */
    2.32 -package de.uapcore.lightpit;
    2.33 -
    2.34 -import java.io.IOException;
    2.35 -import javax.servlet.ServletException;
    2.36 -import javax.servlet.http.HttpServlet;
    2.37 -import javax.servlet.http.HttpServletRequest;
    2.38 -import javax.servlet.http.HttpServletResponse;
    2.39 -
    2.40 -/**
    2.41 - * A special implementation of a HTTPServlet which is focused on implementing
    2.42 - * the necessary functionality for {@link LightPITModule}s.
    2.43 - */
    2.44 -public class LightPITServlet extends HttpServlet {
    2.45 -    
    2.46 -    @Override
    2.47 -    protected final void doGet(HttpServletRequest req, HttpServletResponse resp)
    2.48 -            throws ServletException, IOException {
    2.49 -        
    2.50 -        resp.getWriter().println("It works!");
    2.51 -    }
    2.52 -
    2.53 -    @Override
    2.54 -    protected final void doPost(HttpServletRequest req, HttpServletResponse resp)
    2.55 -            throws ServletException, IOException {
    2.56 -    }
    2.57 -    
    2.58 -}
     3.1 --- a/src/java/de/uapcore/lightpit/ModuleManager.java	Sun Dec 10 16:10:14 2017 +0100
     3.2 +++ b/src/java/de/uapcore/lightpit/ModuleManager.java	Fri Dec 15 17:39:54 2017 +0100
     3.3 @@ -70,26 +70,28 @@
     3.4          try {
     3.5              final Class scclass = Class.forName(reg.getClassName());
     3.6              
     3.7 -            final boolean lpservlet = LightPITServlet.class.isAssignableFrom(scclass);
     3.8 +            final boolean lpservlet = AbstractLightPITServlet.class.isAssignableFrom(scclass);
     3.9              final boolean lpmodule = scclass.isAnnotationPresent(LightPITModule.class);
    3.10              
    3.11              if (lpservlet && !lpmodule) {
    3.12                  LOG.warn(
    3.13 -                    "Servlet is a LightPITServlet but is missing the module annotation: {}",
    3.14 +                    "{} is a LightPIT Servlet but is missing the module annotation.",
    3.15                      reg.getClassName()
    3.16                  );
    3.17              } else if (!lpservlet && lpmodule) {
    3.18                  LOG.warn(
    3.19 -                    "Servlet is annotated as a LightPITModule but does not extend LightPITServlet: {}",
    3.20 -                    reg.getClassName()
    3.21 +                    "{} is annotated as a LightPIT Module but does not extend {}.",
    3.22 +                    reg.getClassName(),
    3.23 +                    AbstractLightPITServlet.class.getSimpleName()
    3.24                  );
    3.25              }
    3.26              
    3.27              return lpservlet && lpmodule;
    3.28          } catch (ClassNotFoundException ex) {
    3.29              LOG.error(
    3.30 -                    "Servlet registration refers to a class which cannot be found by the class loader: {}",
    3.31 -                    reg.getClassName()
    3.32 +                    "Servlet registration refers to class {} which cannot be found by the class loader (Reason: {})",
    3.33 +                    reg.getClassName(),
    3.34 +                    ex.getMessage()
    3.35              );
    3.36              return false;
    3.37          }        
     4.1 --- a/src/java/de/uapcore/lightpit/modules/HomeModule.java	Sun Dec 10 16:10:14 2017 +0100
     4.2 +++ b/src/java/de/uapcore/lightpit/modules/HomeModule.java	Fri Dec 15 17:39:54 2017 +0100
     4.3 @@ -30,7 +30,7 @@
     4.4  
     4.5  import de.uapcore.lightpit.Constants;
     4.6  import de.uapcore.lightpit.LightPITModule;
     4.7 -import de.uapcore.lightpit.LightPITServlet;
     4.8 +import de.uapcore.lightpit.AbstractLightPITServlet;
     4.9  import javax.servlet.annotation.WebServlet;
    4.10  
    4.11  /**
    4.12 @@ -43,6 +43,6 @@
    4.13          name = "HomeModule",
    4.14          urlPatterns = Constants.HOME_NODE+"*"
    4.15  )
    4.16 -public class HomeModule extends LightPITServlet {
    4.17 +public class HomeModule extends AbstractLightPITServlet {
    4.18      
    4.19  }
     5.1 --- a/src/java/de/uapcore/lightpit/modules/VersionsModule.java	Sun Dec 10 16:10:14 2017 +0100
     5.2 +++ b/src/java/de/uapcore/lightpit/modules/VersionsModule.java	Fri Dec 15 17:39:54 2017 +0100
     5.3 @@ -29,7 +29,7 @@
     5.4  package de.uapcore.lightpit.modules;
     5.5  
     5.6  import de.uapcore.lightpit.LightPITModule;
     5.7 -import de.uapcore.lightpit.LightPITServlet;
     5.8 +import de.uapcore.lightpit.AbstractLightPITServlet;
     5.9  import javax.servlet.annotation.WebServlet;
    5.10  
    5.11  
    5.12 @@ -40,6 +40,6 @@
    5.13          name = "VersionsModule",
    5.14          urlPatterns = "/versions/*"
    5.15  )
    5.16 -public class VersionsModule extends LightPITServlet {
    5.17 +public class VersionsModule extends AbstractLightPITServlet {
    5.18      
    5.19  }

mercurial