OK, not much response. Maybe my initial post was misleading. I don’'t want the PluginServlet to be a GenericServlet but the servlets map of type GenericServlet. See the advantages in the earlier post. This is a patch against version 2700
Markus
Index: PluginServlet.java
===================================================================
— PluginServlet.java (revision 2718)
+++ PluginServlet.java (working copy)
@@ -21,6 +21,7 @@
import org.jivesoftware.util.StringUtils;
import org.xml.sax.SAXException;
+import javax.servlet.GenericServlet;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
@@ -54,12 +55,12 @@
*/
public class PluginServlet extends HttpServlet {
- private static Map<String, HttpServlet> servlets;
- private static Map<String, GenericServlet> servlets;
private static PluginManager pluginManager;
private static ServletConfig servletConfig;
static {
}
public void init(ServletConfig config) throws ServletException {
@@ -156,10 +157,10 @@
// Register the servlet for the URL.
Class servletClass = classMap.get(name);
Object instance = servletClass.newInstance();
// Initialize the servlet then add it to the map…
-
((GenericServlet)instance).init(servletConfig);
-
servlets.put(pluginName + url, (GenericServlet)instance);
}
else {
Log.warn("Could not load " + (pluginName + url) + “: not a servlet.”);
@@ -197,7 +198,7 @@
Element nameElement = (Element)names.get(i);
String url = nameElement.element(“url-pattern”).getTextTrim();
// Destroy the servlet than remove from servlets map.
servlet.destroy();
servlets.remove(pluginName + url);
servlet = null;
@@ -226,8 +227,8 @@
String jspURL = pathInfo.substring(1);
servlet.service(request, response);
return;
}
@@ -250,7 +251,7 @@
private void handleServlet(String pathInfo, HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
// Strip the starting “/” from the path to find the JSP URL.
if (servlet != null) {
servlet.service(request, response);
return;
@@ -267,10 +268,10 @@
-
@param pathInfo the pathinfo to map to the servlet.
-
@return the mapped servlet, or null if no servlet was found.
*/
- private HttpServlet getServlet(String pathInfo) {
- private GenericServlet getServlet(String pathInfo) {
pathInfo = pathInfo.substring(1).toLowerCase();
if (servlet == null) {
for (String key : servlets.keySet()) {
int index = key.indexOf("/*");
@@ -471,4 +472,4 @@
return builder.toString();
}
-}
\ No newline at end of file
+}