iterator = Kiss4web.instance().modules().iterator();
+ result = null;
+ while (!ended)
+ {
+ if (iterator.hasNext())
+ {
+ KissModule module = iterator.next();
+
+ String currentClassName = KissDispatcherUtils.concatenatePackage(module.websiteRootPackage(), className);
+ HttpServlet servlet = KissDispatcherUtils.instanciateServlet(currentClassName);
+ if (servlet != null)
+ {
+ ended = true;
+ result = servlet;
+ }
+ }
+ else
+ {
+ ended = true;
+ result = null;
+ }
+ }
+ }
+
+ //
+ return result;
+ }
+
+ /**
+ * Instance.
+ *
+ * @return the kiss dispatcher factory
+ */
+ public static KissDispatcherFactory instance()
+ {
+ return SingletonHolder.instance;
+ }
+
+ /**
+ * Translate to class name.
+ *
+ *
+ * "/" => "Index_xhtml"
+ * "/good/" => "good.Index_xhtml"
+ * "/good/morning.xhtml" => "good.Morning_xhtml"
+ * "/good/morning_girl.xhtml" => "good.Morning_girl_xhtml"
+ *
+ *
+ * @param urlPath
+ * the url path
+ * @return the string
+ */
+ public static String translateToClassName(final String urlPath)
+ {
+ String result;
+
+ if (urlPath == null)
+ {
+ result = null;
+ }
+ else
+ {
+ String[] tokens = urlPath.split("/");
+ if (tokens.length == 1)
+ {
+ result = "Index_xhtml";
+ }
+ else if (urlPath.endsWith("/"))
+ {
+ StringList buffer = new StringList();
+
+ // Note: as pathInfo starts always with a '/', the first
+ // good token index is 1.
+ for (int tokenCounter = 1; tokenCounter <= tokens.length - 1; tokenCounter++)
+ {
+ buffer.append(tokens[tokenCounter]);
+ buffer.append('.');
+ }
+
+ // String lastToken = tokens[tokens.length - 1];
+ // buffer.append(StringUtils.capitalize(lastToken)).append("_xhtml");
+ buffer.append("Index_xhtml");
+
+ result = buffer.toString();
+ }
+ else
+ {
+ StringList buffer = new StringList();
+
+ // Note: as pathInfo starts always with a '/', the first
+ // good token index is 1.
+ for (int tokenCounter = 1; tokenCounter < tokens.length - 1; tokenCounter++)
+ {
+ buffer.append(tokens[tokenCounter]);
+ buffer.append('.');
+ }
+
+ String lastToken = tokens[tokens.length - 1];
+ buffer.append(StringUtils.capitalize(lastToken).replace('.', '_'));
+
+ result = buffer.toString();
+ }
+ }
+
+ //
+ return result;
+ }
+}
diff --git a/src/fr/devinsy/kiss4web/KissDispatcherUtils.java b/src/fr/devinsy/kiss4web/dispatcher/KissDispatcherUtils.java
similarity index 96%
rename from src/fr/devinsy/kiss4web/KissDispatcherUtils.java
rename to src/fr/devinsy/kiss4web/dispatcher/KissDispatcherUtils.java
index 85df296..d8dd3ca 100644
--- a/src/fr/devinsy/kiss4web/KissDispatcherUtils.java
+++ b/src/fr/devinsy/kiss4web/dispatcher/KissDispatcherUtils.java
@@ -16,7 +16,7 @@
* You should have received a copy of the GNU Lesser General Public License
* along with Kiss4web. If not, see
*/
-package fr.devinsy.kiss4web;
+package fr.devinsy.kiss4web.dispatcher;
import java.io.File;
import java.io.FileInputStream;
diff --git a/src/fr/devinsy/kiss4web/hooks/BlankHook.java b/src/fr/devinsy/kiss4web/dispatcher/hooks/BlankHook.java
similarity index 77%
rename from src/fr/devinsy/kiss4web/hooks/BlankHook.java
rename to src/fr/devinsy/kiss4web/dispatcher/hooks/BlankHook.java
index 9ddd20a..b016bfc 100644
--- a/src/fr/devinsy/kiss4web/hooks/BlankHook.java
+++ b/src/fr/devinsy/kiss4web/dispatcher/hooks/BlankHook.java
@@ -1,5 +1,5 @@
/**
- * Copyright (C) 2006-2010, 2013-2016 Christian Pierre MOMON
+ * Copyright (C) 2006-2021 Christian Pierre MOMON
*
* This file is part of Kiss4web.
*
@@ -16,7 +16,7 @@
* You should have received a copy of the GNU Lesser General Public License
* along with Kiss4web. If not, see
*/
-package fr.devinsy.kiss4web.hooks;
+package fr.devinsy.kiss4web.dispatcher.hooks;
import java.io.IOException;
import java.io.PrintWriter;
@@ -30,44 +30,22 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- *
+ * The Class BlankHook.
*/
public class BlankHook extends HookCore
{
private static Logger logger = LoggerFactory.getLogger(BlankHook.class);
/**
- *
+ * Instantiates a new blank hook.
*/
public BlankHook()
{
super();
}
- /**
- * @throws IOException
- *
- */
- @Override
- public void process(final ServletConfig servletConfig, final ServletContext servletContext, final HttpServletRequest request,
- final HttpServletResponse response) throws IOException
- {
- logger.debug("Doing catch.");
-
- response.setContentType("text/html");
- PrintWriter out = response.getWriter();
-
- out.println("");
- out.println("Null path.");
- out.println("");
-
- out.close();
- }
-
- /**
- *
- * @param urlPath
- * @return
+ /* (non-Javadoc)
+ * @see fr.devinsy.kiss4web.hooks.Hook#matches(javax.servlet.ServletContext, javax.servlet.http.HttpServletRequest)
*/
@Override
public boolean matches(final ServletContext servletContext, final HttpServletRequest request)
@@ -88,4 +66,23 @@ public class BlankHook extends HookCore
//
return result;
}
+
+ /* (non-Javadoc)
+ * @see fr.devinsy.kiss4web.hooks.Hook#process(javax.servlet.ServletConfig, javax.servlet.ServletContext, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
+ */
+ @Override
+ public void process(final ServletConfig servletConfig, final ServletContext servletContext, final HttpServletRequest request,
+ final HttpServletResponse response) throws IOException
+ {
+ logger.debug("Doing catch.");
+
+ response.setContentType("text/html");
+ PrintWriter out = response.getWriter();
+
+ out.println("");
+ out.println("Null path.");
+ out.println("");
+
+ out.close();
+ }
}
diff --git a/src/fr/devinsy/kiss4web/hooks/FolderHook.java b/src/fr/devinsy/kiss4web/dispatcher/hooks/FolderHook.java
similarity index 75%
rename from src/fr/devinsy/kiss4web/hooks/FolderHook.java
rename to src/fr/devinsy/kiss4web/dispatcher/hooks/FolderHook.java
index 9d9fb53..e4872da 100644
--- a/src/fr/devinsy/kiss4web/hooks/FolderHook.java
+++ b/src/fr/devinsy/kiss4web/dispatcher/hooks/FolderHook.java
@@ -1,5 +1,5 @@
/**
- * Copyright (C) 2006-2010, 2013-2016 Christian Pierre MOMON
+ * Copyright (C) 2006-2021 Christian Pierre MOMON
*
* This file is part of Kiss4web.
*
@@ -16,7 +16,7 @@
* You should have received a copy of the GNU Lesser General Public License
* along with Kiss4web. If not, see
*/
-package fr.devinsy.kiss4web.hooks;
+package fr.devinsy.kiss4web.dispatcher.hooks;
import java.io.IOException;
@@ -29,42 +29,25 @@ import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import fr.devinsy.kiss4web.KissDispatcherUtils;
+import fr.devinsy.kiss4web.dispatcher.KissDispatcherUtils;
/**
- *
+ * The Class FolderHook.
*/
public class FolderHook extends HookCore
{
private static Logger logger = LoggerFactory.getLogger(FolderHook.class);
/**
- *
+ * Instantiates a new folder hook.
*/
public FolderHook()
{
super();
}
- /**
- * @throws IOException
- * @throws ServletException
- *
- */
- @Override
- public void process(final ServletConfig servletConfig, final ServletContext servletContext, final HttpServletRequest request,
- final HttpServletResponse response) throws IOException, ServletException
- {
- logger.debug("Doing catch.");
-
- String urlPath = request.getPathInfo();
- KissDispatcherUtils.dispatchToServlet(servletConfig, request, response, urlPath);
- }
-
- /**
- *
- * @param urlPath
- * @return
+ /* (non-Javadoc)
+ * @see fr.devinsy.kiss4web.hooks.Hook#matches(javax.servlet.ServletContext, javax.servlet.http.HttpServletRequest)
*/
@Override
public boolean matches(final ServletContext servletContext, final HttpServletRequest request)
@@ -86,4 +69,16 @@ public class FolderHook extends HookCore
return result;
}
+ /* (non-Javadoc)
+ * @see fr.devinsy.kiss4web.hooks.Hook#process(javax.servlet.ServletConfig, javax.servlet.ServletContext, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
+ */
+ @Override
+ public void process(final ServletConfig servletConfig, final ServletContext servletContext, final HttpServletRequest request,
+ final HttpServletResponse response) throws IOException, ServletException
+ {
+ logger.debug("Doing catch.");
+
+ String urlPath = request.getPathInfo();
+ KissDispatcherUtils.dispatchToServlet(servletConfig, request, response, urlPath);
+ }
}
diff --git a/src/fr/devinsy/kiss4web/hooks/Hook.java b/src/fr/devinsy/kiss4web/dispatcher/hooks/Hook.java
similarity index 64%
rename from src/fr/devinsy/kiss4web/hooks/Hook.java
rename to src/fr/devinsy/kiss4web/dispatcher/hooks/Hook.java
index 6cce1a4..c76117b 100644
--- a/src/fr/devinsy/kiss4web/hooks/Hook.java
+++ b/src/fr/devinsy/kiss4web/dispatcher/hooks/Hook.java
@@ -1,6 +1,6 @@
/**
- * Copyright (C) 2006-2010, 2013-2016 Christian Pierre MOMON
- *
+ * Copyright (C) 2006-2021 Christian Pierre MOMON
+ *
* This file is part of Kiss4web.
*
* Kiss4web is free software: you can redistribute it and/or modify
@@ -16,7 +16,7 @@
* You should have received a copy of the GNU Lesser General Public License
* along with Kiss4web. If not, see
*/
-package fr.devinsy.kiss4web.hooks;
+package fr.devinsy.kiss4web.dispatcher.hooks;
import java.io.IOException;
@@ -27,30 +27,45 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
- *
+ * The Interface Hook.
*/
public interface Hook
{
- /**
- *
- * @param request
- * @param response
- * @throws Exception
- */
- void process(final ServletConfig servletConfig, final ServletContext servletContext, final HttpServletRequest request,
- final HttpServletResponse response) throws IOException, ServletException;
/**
- *
- * @param source
- * @return
+ * Checks if is terminal.
+ *
+ * @return true if it is a final hook, false otherwise.
+ */
+ boolean isTerminal();
+
+ /**
+ * Matches.
+ *
+ * @param servletContext
+ * the servlet context
+ * @param request
+ * the request
+ * @return true, if successful
*/
boolean matches(final ServletContext servletContext, final HttpServletRequest request);
/**
- *
- *
- * @return true if it is a final hook, false otherwise.
+ * Process.
+ *
+ * @param servletConfig
+ * the servlet config
+ * @param servletContext
+ * the servlet context
+ * @param request
+ * the request
+ * @param response
+ * the response
+ * @throws IOException
+ * Signals that an I/O exception has occurred.
+ * @throws ServletException
+ * the servlet exception
*/
- boolean isTerminal();
+ void process(final ServletConfig servletConfig, final ServletContext servletContext, final HttpServletRequest request,
+ final HttpServletResponse response) throws IOException, ServletException;
}
diff --git a/src/fr/devinsy/kiss4web/hooks/HookCore.java b/src/fr/devinsy/kiss4web/dispatcher/hooks/HookCore.java
similarity index 69%
rename from src/fr/devinsy/kiss4web/hooks/HookCore.java
rename to src/fr/devinsy/kiss4web/dispatcher/hooks/HookCore.java
index f8e5885..05febe3 100644
--- a/src/fr/devinsy/kiss4web/hooks/HookCore.java
+++ b/src/fr/devinsy/kiss4web/dispatcher/hooks/HookCore.java
@@ -1,5 +1,5 @@
/**
- * Copyright (C) 2006-2010, 2013-2016 Christian Pierre MOMON
+ * Copyright (C) 2006-2021 Christian Pierre MOMON
*
* This file is part of Kiss4web.
*
@@ -16,22 +16,17 @@
* You should have received a copy of the GNU Lesser General Public License
* along with Kiss4web. If not, see
*/
-package fr.devinsy.kiss4web.hooks;
+package fr.devinsy.kiss4web.dispatcher.hooks;
/**
- *
+ * The Class HookCore.
*/
public abstract class HookCore implements Hook
{
private boolean terminal;
- public void setTerminal(boolean terminal)
- {
- this.terminal = terminal;
- }
-
/**
- *
+ * Instantiates a new hook core.
*/
public HookCore()
{
@@ -40,11 +35,23 @@ public abstract class HookCore implements Hook
this.terminal = true;
}
- /**
- *
+ /* (non-Javadoc)
+ * @see fr.devinsy.kiss4web.hooks.Hook#isTerminal()
*/
+ @Override
public boolean isTerminal()
{
return this.terminal;
}
+
+ /**
+ * Sets the terminal.
+ *
+ * @param terminal
+ * the new terminal
+ */
+ public void setTerminal(final boolean terminal)
+ {
+ this.terminal = terminal;
+ }
}
diff --git a/src/fr/devinsy/kiss4web/hooks/HookRegister.java b/src/fr/devinsy/kiss4web/dispatcher/hooks/HookRegister.java
similarity index 76%
rename from src/fr/devinsy/kiss4web/hooks/HookRegister.java
rename to src/fr/devinsy/kiss4web/dispatcher/hooks/HookRegister.java
index fa444c6..d319a8a 100644
--- a/src/fr/devinsy/kiss4web/hooks/HookRegister.java
+++ b/src/fr/devinsy/kiss4web/dispatcher/hooks/HookRegister.java
@@ -1,5 +1,5 @@
/**
- * Copyright (C) 2006-2010, 2013-2016 Christian Pierre MOMON
+ * Copyright (C) 2006-2021 Christian Pierre MOMON
*
* This file is part of Kiss4web.
*
@@ -16,7 +16,7 @@
* You should have received a copy of the GNU Lesser General Public License
* along with Kiss4web. If not, see
*/
-package fr.devinsy.kiss4web.hooks;
+package fr.devinsy.kiss4web.dispatcher.hooks;
import java.util.ArrayList;
import java.util.Iterator;
@@ -26,14 +26,14 @@ import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
/**
- *
+ * The Class HookRegister.
*/
public class HookRegister
{
List hooks;
/**
- *
+ * Instantiates a new hook register.
*/
public HookRegister()
{
@@ -43,28 +43,13 @@ public class HookRegister
}
/**
- *
- * @return
- */
- public List hooks()
- {
- return hooks;
- }
-
- /**
- *
- * @param hook
- */
- public void register(Hook hook)
- {
- hooks.add(hook);
- }
-
- /**
- *
+ * Gets the matching.
+ *
* @param servletContext
+ * the servlet context
* @param request
- * @return
+ * the request
+ * @return the matching
*/
public Hook getMatching(final ServletContext servletContext, final HttpServletRequest request)
{
@@ -95,4 +80,25 @@ public class HookRegister
//
return result;
}
+
+ /**
+ * Hooks.
+ *
+ * @return the list
+ */
+ public List hooks()
+ {
+ return this.hooks;
+ }
+
+ /**
+ * Register.
+ *
+ * @param hook
+ * the hook
+ */
+ public void register(final Hook hook)
+ {
+ this.hooks.add(hook);
+ }
}
diff --git a/src/fr/devinsy/kiss4web/hooks/LongURLHook.java b/src/fr/devinsy/kiss4web/dispatcher/hooks/LongURLHook.java
similarity index 75%
rename from src/fr/devinsy/kiss4web/hooks/LongURLHook.java
rename to src/fr/devinsy/kiss4web/dispatcher/hooks/LongURLHook.java
index 98766d1..bdab709 100644
--- a/src/fr/devinsy/kiss4web/hooks/LongURLHook.java
+++ b/src/fr/devinsy/kiss4web/dispatcher/hooks/LongURLHook.java
@@ -1,5 +1,5 @@
/**
- * Copyright (C) 2006-2010, 2013-2016 Christian Pierre MOMON
+ * Copyright (C) 2006-2021 Christian Pierre MOMON
*
* This file is part of Kiss4web.
*
@@ -16,7 +16,7 @@
* You should have received a copy of the GNU Lesser General Public License
* along with Kiss4web. If not, see
*/
-package fr.devinsy.kiss4web.hooks;
+package fr.devinsy.kiss4web.dispatcher.hooks;
import java.io.IOException;
@@ -29,45 +29,25 @@ import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import fr.devinsy.kiss4web.KissDispatcherUtils;
+import fr.devinsy.kiss4web.dispatcher.KissDispatcherUtils;
/**
- *
+ * The Class LongURLHook.
*/
public class LongURLHook extends HookCore
{
private static Logger logger = LoggerFactory.getLogger(LongURLHook.class);
/**
- *
+ * Instantiates a new long URL hook.
*/
public LongURLHook()
{
super();
}
- /**
- * @throws IOException
- * @throws ServletException
- *
- */
- @Override
- public void process(final ServletConfig servletConfig, final ServletContext servletContext, final HttpServletRequest request,
- final HttpServletResponse response) throws IOException, ServletException
- {
- logger.debug("Doing catch.");
-
- String urlPath = request.getPathInfo();
-
- String rewritedURLPath = LongURLRewriter.unrewrite(urlPath);
-
- KissDispatcherUtils.dispatchToServlet(servletConfig, request, response, rewritedURLPath);
- }
-
- /**
- *
- * @param urlPath
- * @return
+ /* (non-Javadoc)
+ * @see fr.devinsy.kiss4web.hooks.Hook#matches(javax.servlet.ServletContext, javax.servlet.http.HttpServletRequest)
*/
@Override
public boolean matches(final ServletContext servletContext, final HttpServletRequest request)
@@ -81,4 +61,20 @@ public class LongURLHook extends HookCore
//
return result;
}
+
+ /* (non-Javadoc)
+ * @see fr.devinsy.kiss4web.hooks.Hook#process(javax.servlet.ServletConfig, javax.servlet.ServletContext, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
+ */
+ @Override
+ public void process(final ServletConfig servletConfig, final ServletContext servletContext, final HttpServletRequest request,
+ final HttpServletResponse response) throws IOException, ServletException
+ {
+ logger.debug("Doing catch.");
+
+ String urlPath = request.getPathInfo();
+
+ String rewritedURLPath = LongURLRewriter.unrewrite(urlPath);
+
+ KissDispatcherUtils.dispatchToServlet(servletConfig, request, response, rewritedURLPath);
+ }
}
diff --git a/src/fr/devinsy/kiss4web/hooks/LongURLRewriter.java b/src/fr/devinsy/kiss4web/dispatcher/hooks/LongURLRewriter.java
similarity index 87%
rename from src/fr/devinsy/kiss4web/hooks/LongURLRewriter.java
rename to src/fr/devinsy/kiss4web/dispatcher/hooks/LongURLRewriter.java
index d7780af..200f3ee 100644
--- a/src/fr/devinsy/kiss4web/hooks/LongURLRewriter.java
+++ b/src/fr/devinsy/kiss4web/dispatcher/hooks/LongURLRewriter.java
@@ -1,5 +1,5 @@
/**
- * Copyright (C) 2006-2010, 2013-2016 Christian Pierre MOMON
+ * Copyright (C) 2006-2021 Christian Pierre MOMON
*
* This file is part of Kiss4web.
*
@@ -16,7 +16,7 @@
* You should have received a copy of the GNU Lesser General Public License
* along with Kiss4web. If not, see
*/
-package fr.devinsy.kiss4web.hooks;
+package fr.devinsy.kiss4web.dispatcher.hooks;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -29,7 +29,7 @@ import org.slf4j.LoggerFactory;
import fr.devinsy.util.strings.StringList;
/**
- *
+ * The Class LongURLRewriter.
*/
public class LongURLRewriter
{
@@ -41,9 +41,11 @@ public class LongURLRewriter
private static final Pattern REWRITE_PARAMETER = Pattern.compile("[^%\\w\\d]");
/**
- *
+ * Matches.
+ *
* @param urlPath
- * @return
+ * the url path
+ * @return true, if successful
*/
public static boolean matches(final String urlPath)
{
@@ -57,19 +59,6 @@ public class LongURLRewriter
return result;
}
- /**
- *
- */
- public static String[] unrewriteParameters(final HttpServletRequest request)
- {
- String[] result;
-
- result = unrewriteParameters(request.getRequestURI());
-
- //
- return result;
- }
-
/**
* This method gives a way for a long rewriting URL format. Long as in REST.
*
@@ -113,12 +102,11 @@ public class LongURLRewriter
}
/**
- *
* /catalog/article-/123/2016/12/14/resume.xhtml -> /catalog/article.xhtml
- *
+ *
* @param source
* an URL path.
- * @return
+ * @return the string
*/
public static String unrewrite(final String source)
{
@@ -141,6 +129,23 @@ public class LongURLRewriter
return result;
}
+ /**
+ * Unrewrite parameters.
+ *
+ * @param request
+ * the request
+ * @return the string[]
+ */
+ public static String[] unrewriteParameters(final HttpServletRequest request)
+ {
+ String[] result;
+
+ result = unrewriteParameters(request.getRequestURI());
+
+ //
+ return result;
+ }
+
/**
* Extract values from a path.
*
@@ -150,10 +155,10 @@ public class LongURLRewriter
* "/article-/123/doors/open.xhtml";
* => "123", "doors" and "open".
*
- *
+ *
* @param source
* an URL path.
- * @return
+ * @return the string[]
*/
public static String[] unrewriteParameters(final String source)
{
diff --git a/src/fr/devinsy/kiss4web/hooks/RootHook.java b/src/fr/devinsy/kiss4web/dispatcher/hooks/RootHook.java
similarity index 75%
rename from src/fr/devinsy/kiss4web/hooks/RootHook.java
rename to src/fr/devinsy/kiss4web/dispatcher/hooks/RootHook.java
index 23d9870..c5e0bd6 100644
--- a/src/fr/devinsy/kiss4web/hooks/RootHook.java
+++ b/src/fr/devinsy/kiss4web/dispatcher/hooks/RootHook.java
@@ -1,5 +1,5 @@
/**
- * Copyright (C) 2006-2010, 2013-2016 Christian Pierre MOMON
+ * Copyright (C) 2006-2021 Christian Pierre MOMON
*
* This file is part of Kiss4web.
*
@@ -16,7 +16,7 @@
* You should have received a copy of the GNU Lesser General Public License
* along with Kiss4web. If not, see
*/
-package fr.devinsy.kiss4web.hooks;
+package fr.devinsy.kiss4web.dispatcher.hooks;
import java.io.IOException;
@@ -29,43 +29,25 @@ import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import fr.devinsy.kiss4web.KissDispatcherUtils;
+import fr.devinsy.kiss4web.dispatcher.KissDispatcherUtils;
/**
- *
+ * The Class RootHook.
*/
public class RootHook extends HookCore
{
private static Logger logger = LoggerFactory.getLogger(RootHook.class);
/**
- *
+ * Instantiates a new root hook.
*/
public RootHook()
{
super();
}
- /**
- * @throws IOException
- * @throws ServletException
- *
- */
- @Override
- public void process(final ServletConfig servletConfig, final ServletContext servletContext, final HttpServletRequest request,
- final HttpServletResponse response) throws IOException, ServletException
- {
- logger.debug("Doing catch.");
-
- String className = "index.xhtml";
-
- KissDispatcherUtils.dispatchToServlet(servletConfig, request, response, className);
- }
-
- /**
- *
- * @param urlPath
- * @return
+ /* (non-Javadoc)
+ * @see fr.devinsy.kiss4web.hooks.Hook#matches(javax.servlet.ServletContext, javax.servlet.http.HttpServletRequest)
*/
@Override
public boolean matches(final ServletContext servletContext, final HttpServletRequest request)
@@ -86,4 +68,18 @@ public class RootHook extends HookCore
//
return result;
}
+
+ /* (non-Javadoc)
+ * @see fr.devinsy.kiss4web.hooks.Hook#process(javax.servlet.ServletConfig, javax.servlet.ServletContext, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
+ */
+ @Override
+ public void process(final ServletConfig servletConfig, final ServletContext servletContext, final HttpServletRequest request,
+ final HttpServletResponse response) throws IOException, ServletException
+ {
+ logger.debug("Doing catch.");
+
+ String className = "index.xhtml";
+
+ KissDispatcherUtils.dispatchToServlet(servletConfig, request, response, className);
+ }
}
diff --git a/src/fr/devinsy/kiss4web/hooks/ShortURLHook.java b/src/fr/devinsy/kiss4web/dispatcher/hooks/ShortURLHook.java
similarity index 75%
rename from src/fr/devinsy/kiss4web/hooks/ShortURLHook.java
rename to src/fr/devinsy/kiss4web/dispatcher/hooks/ShortURLHook.java
index fb5df13..e948857 100644
--- a/src/fr/devinsy/kiss4web/hooks/ShortURLHook.java
+++ b/src/fr/devinsy/kiss4web/dispatcher/hooks/ShortURLHook.java
@@ -1,5 +1,5 @@
/**
- * Copyright (C) 2006-2010, 2013-2016 Christian Pierre MOMON
+ * Copyright (C) 2006-2021 Christian Pierre MOMON
*
* This file is part of Kiss4web.
*
@@ -16,7 +16,7 @@
* You should have received a copy of the GNU Lesser General Public License
* along with Kiss4web. If not, see
*/
-package fr.devinsy.kiss4web.hooks;
+package fr.devinsy.kiss4web.dispatcher.hooks;
import java.io.IOException;
@@ -29,45 +29,25 @@ import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import fr.devinsy.kiss4web.KissDispatcherUtils;
+import fr.devinsy.kiss4web.dispatcher.KissDispatcherUtils;
/**
- *
+ * The Class ShortURLHook.
*/
public class ShortURLHook extends HookCore
{
private static Logger logger = LoggerFactory.getLogger(ShortURLHook.class);
/**
- *
+ * Instantiates a new short URL hook.
*/
public ShortURLHook()
{
super();
}
- /**
- * @throws IOException
- * @throws ServletException
- *
- */
- @Override
- public void process(final ServletConfig servletConfig, final ServletContext servletContext, final HttpServletRequest request,
- final HttpServletResponse response) throws IOException, ServletException
- {
- logger.debug("Doing catch.");
-
- String urlPath = request.getPathInfo();
-
- String rewritedURLPath = ShortURLRewriter.unrewrite(urlPath);
-
- KissDispatcherUtils.dispatchToServlet(servletConfig, request, response, rewritedURLPath);
- }
-
- /**
- *
- * @param urlPath
- * @return
+ /* (non-Javadoc)
+ * @see fr.devinsy.kiss4web.hooks.Hook#matches(javax.servlet.ServletContext, javax.servlet.http.HttpServletRequest)
*/
@Override
public boolean matches(final ServletContext servletContext, final HttpServletRequest request)
@@ -81,4 +61,20 @@ public class ShortURLHook extends HookCore
//
return result;
}
+
+ /* (non-Javadoc)
+ * @see fr.devinsy.kiss4web.hooks.Hook#process(javax.servlet.ServletConfig, javax.servlet.ServletContext, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
+ */
+ @Override
+ public void process(final ServletConfig servletConfig, final ServletContext servletContext, final HttpServletRequest request,
+ final HttpServletResponse response) throws IOException, ServletException
+ {
+ logger.debug("Doing catch.");
+
+ String urlPath = request.getPathInfo();
+
+ String rewritedURLPath = ShortURLRewriter.unrewrite(urlPath);
+
+ KissDispatcherUtils.dispatchToServlet(servletConfig, request, response, rewritedURLPath);
+ }
}
diff --git a/src/fr/devinsy/kiss4web/hooks/ShortURLRewriter.java b/src/fr/devinsy/kiss4web/dispatcher/hooks/ShortURLRewriter.java
similarity index 66%
rename from src/fr/devinsy/kiss4web/hooks/ShortURLRewriter.java
rename to src/fr/devinsy/kiss4web/dispatcher/hooks/ShortURLRewriter.java
index 79af076..fef1dbc 100644
--- a/src/fr/devinsy/kiss4web/hooks/ShortURLRewriter.java
+++ b/src/fr/devinsy/kiss4web/dispatcher/hooks/ShortURLRewriter.java
@@ -1,5 +1,5 @@
/**
- * Copyright (C) 2006-2010, 2013-2016 Christian Pierre MOMON
+ * Copyright (C) 2006-2021 Christian Pierre MOMON
*
* This file is part of Kiss4web.
*
@@ -16,7 +16,7 @@
* You should have received a copy of the GNU Lesser General Public License
* along with Kiss4web. If not, see
*/
-package fr.devinsy.kiss4web.hooks;
+package fr.devinsy.kiss4web.dispatcher.hooks;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -29,7 +29,7 @@ import org.slf4j.LoggerFactory;
import fr.devinsy.util.strings.StringList;
/**
- *
+ * The Class ShortURLRewriter.
*/
public class ShortURLRewriter
{
@@ -48,28 +48,27 @@ public class ShortURLRewriter
*/
private static char NONE = (char) 0;
- private static int[] rewritingParameterMapping = {
- /* 00 */NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE,
- /* 10 */NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE,
- /* 20 */'-', NONE, NONE, '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-',
- /* 30 */'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '-', '-', '-', '-', '-', '-',
- /* 40 */'\u0040', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
- /* 50 */'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '-', '-', '-', '-', '-',
- /* 60 */'-', '\u0061', '\u0062', '\u0063', '\u0064', '\u0065', '\u0066', '\u0067', '\u0068', '\u0069', '\u006A', '\u006B', '\u006C', '\u006D', '\u006E', '\u006F',
- /* 70 */'\u0070', '\u0071', '\u0072', '\u0073', '\u0074', '\u0075', '\u0076', '\u0077', '\u0078', '\u0079', '\u007A', '\u007B', '\u007C', '\u007D', '-', '-',
- /* 80 */NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE,
- /* 90 */NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE,
- /* A0 */'\u00A0', '\u00A1', '\u00A2', '\u00A3', '\u00A4', '\u00A5', '\u00A6', '\u00A7', '\u00A8', '\u00A9', '\u00AA', '\u00AB', '\u00AC', '\u00AD', '\u00AE', '\u00AF',
- /* B0 */'-', '\u00B1', '\u00B2', '\u00B3', '\u00B4', '\u00B5', '\u00B6', '\u00B7', '\u00B8', '\u00B9', '\u00BA', '\u00BB', '\u00BC', '\u00BD', '\u00BE', '\u00BF',
- /* C0 */'a', 'a', 'a', 'a', 'a', 'a', 'a', 'c', 'e', 'e', 'e', 'e', 'i', 'i', 'i', 'i',
- /* D0 */'\u00D0', '\u00D1', 'o', 'o', 'o', 'o', 'o', 'o', '\u00D8', 'u', 'u', 'u', 'u', 'y', '\u00DE', '\u00DF',
- /* E0 */'a', 'a', 'a', 'a', 'a', 'a', 'a', 'c', 'e', 'e', 'e', 'e', 'i', 'i', 'i', 'i',
- /* F0 */'o', 'n', 'o', 'o', 'o', 'o', 'o', '\u00F7', '-', 'u', 'u', 'u', 'u', 'y', '-', 'y' };
+ private static int[] rewritingParameterMapping = { /* 00 */NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE,
+ NONE, NONE, /* 10 */NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, /* 20 */'-', NONE,
+ NONE, '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', /* 30 */'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '-', '-',
+ '-', '-', '-', '-', /* 40 */'\u0040', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', /* 50 */'p', 'q', 'r',
+ 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '-', '-', '-', '-', '-', /* 60 */'-', '\u0061', '\u0062', '\u0063', '\u0064', '\u0065', '\u0066',
+ '\u0067', '\u0068', '\u0069', '\u006A', '\u006B', '\u006C', '\u006D', '\u006E', '\u006F', /* 70 */'\u0070', '\u0071', '\u0072', '\u0073',
+ '\u0074', '\u0075', '\u0076', '\u0077', '\u0078', '\u0079', '\u007A', '\u007B', '\u007C', '\u007D', '-', '-', /* 80 */NONE, NONE, NONE,
+ NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, /* 90 */NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE,
+ NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, /* A0 */'\u00A0', '\u00A1', '\u00A2', '\u00A3', '\u00A4', '\u00A5', '\u00A6', '\u00A7',
+ '\u00A8', '\u00A9', '\u00AA', '\u00AB', '\u00AC', '\u00AD', '\u00AE', '\u00AF', /* B0 */'-', '\u00B1', '\u00B2', '\u00B3', '\u00B4',
+ '\u00B5', '\u00B6', '\u00B7', '\u00B8', '\u00B9', '\u00BA', '\u00BB', '\u00BC', '\u00BD', '\u00BE', '\u00BF', /* C0 */'a', 'a', 'a', 'a',
+ 'a', 'a', 'a', 'c', 'e', 'e', 'e', 'e', 'i', 'i', 'i', 'i', /* D0 */'\u00D0', '\u00D1', 'o', 'o', 'o', 'o', 'o', 'o', '\u00D8', 'u', 'u',
+ 'u', 'u', 'y', '\u00DE', '\u00DF', /* E0 */'a', 'a', 'a', 'a', 'a', 'a', 'a', 'c', 'e', 'e', 'e', 'e', 'i', 'i', 'i', 'i', /* F0 */'o',
+ 'n', 'o', 'o', 'o', 'o', 'o', '\u00F7', '-', 'u', 'u', 'u', 'u', 'y', '-', 'y' };
/**
- *
+ * Matches.
+ *
* @param url
- * @return
+ * the url
+ * @return true, if successful
*/
public static boolean matches(final String url)
{
@@ -96,6 +95,14 @@ public class ShortURLRewriter
* => rewriteShorturl("/good/article", "xhtml", "123", "Story's aboute me");
* => "/good/article-123-today-story-s-about-me.xhtml"
*
+ *
+ * @param uri
+ * the uri
+ * @param extension
+ * the extension
+ * @param parameters
+ * the parameters
+ * @return the string
*/
public static String rewrite(final String uri, final String extension, final String... parameters)
{
@@ -125,9 +132,11 @@ public class ShortURLRewriter
}
/**
- *
+ * Rewrite parameter.
+ *
* @param parameter
- * @return
+ * the parameter
+ * @return the string
*/
public static String rewriteParameter(final String parameter)
{
@@ -175,11 +184,11 @@ public class ShortURLRewriter
}
/**
- *
* article.xhtm?id=123 -> article.xhtml
- *
+ *
* @param source
- * @return
+ * the source
+ * @return the string
*/
public static String unrewrite(final String source)
{
@@ -203,8 +212,12 @@ public class ShortURLRewriter
}
/**
- *
- */
+ * Unrewrite parameter.
+ *
+ * @param request
+ * the request
+ * @return the string
+ */
public static String unrewriteParameter(final HttpServletRequest request)
{
String result;
@@ -217,6 +230,10 @@ public class ShortURLRewriter
/**
* Return value of the first parameter.
+ *
+ * @param path
+ * the path
+ * @return the string
*/
public static String unrewriteParameter(final String path)
{
@@ -238,8 +255,12 @@ public class ShortURLRewriter
}
/**
- *
- */
+ * Unrewrite parameters.
+ *
+ * @param request
+ * the request
+ * @return the string[]
+ */
public static String[] unrewriteParameters(final HttpServletRequest request)
{
String[] result;
@@ -252,6 +273,10 @@ public class ShortURLRewriter
/**
* Extract value from a path. Example: "/article-123.xhtml" => "123".
+ *
+ * @param path
+ * the path
+ * @return the string[]
*/
public static String[] unrewriteParameters(final String path)
{
diff --git a/src/fr/devinsy/kiss4web/hooks/StatisticsHook.java b/src/fr/devinsy/kiss4web/dispatcher/hooks/StatisticsHook.java
similarity index 74%
rename from src/fr/devinsy/kiss4web/hooks/StatisticsHook.java
rename to src/fr/devinsy/kiss4web/dispatcher/hooks/StatisticsHook.java
index a51b8e4..df4b8e3 100644
--- a/src/fr/devinsy/kiss4web/hooks/StatisticsHook.java
+++ b/src/fr/devinsy/kiss4web/dispatcher/hooks/StatisticsHook.java
@@ -1,5 +1,5 @@
/**
- * Copyright (C) 2006-2010, 2013-2016 Christian Pierre MOMON
+ * Copyright (C) 2006-2021 Christian Pierre MOMON
*
* This file is part of Kiss4web.
*
@@ -16,7 +16,7 @@
* You should have received a copy of the GNU Lesser General Public License
* along with Kiss4web. If not, see
*/
-package fr.devinsy.kiss4web.hooks;
+package fr.devinsy.kiss4web.dispatcher.hooks;
import java.io.IOException;
@@ -29,14 +29,14 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- *
+ * The Class StatisticsHook.
*/
public class StatisticsHook extends HookCore
{
private static Logger logger = LoggerFactory.getLogger(StatisticsHook.class);
/**
- *
+ * Instantiates a new statistics hook.
*/
public StatisticsHook()
{
@@ -45,23 +45,8 @@ public class StatisticsHook extends HookCore
setTerminal(false);
}
- /**
- * @throws IOException
- *
- */
- @Override
- public void process(final ServletConfig servletConfig, final ServletContext servletContext, final HttpServletRequest request,
- final HttpServletResponse response) throws IOException
- {
- logger.debug("Doing catch.");
-
- // TODO store statistics.
- }
-
- /**
- *
- * @param urlPath
- * @return
+ /* (non-Javadoc)
+ * @see fr.devinsy.kiss4web.hooks.Hook#matches(javax.servlet.ServletContext, javax.servlet.http.HttpServletRequest)
*/
@Override
public boolean matches(final ServletContext servletContext, final HttpServletRequest request)
@@ -73,4 +58,16 @@ public class StatisticsHook extends HookCore
//
return result;
}
+
+ /* (non-Javadoc)
+ * @see fr.devinsy.kiss4web.hooks.Hook#process(javax.servlet.ServletConfig, javax.servlet.ServletContext, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
+ */
+ @Override
+ public void process(final ServletConfig servletConfig, final ServletContext servletContext, final HttpServletRequest request,
+ final HttpServletResponse response) throws IOException
+ {
+ logger.debug("Doing catch.");
+
+ // TODO store statistics.
+ }
}
diff --git a/src/fr/devinsy/kiss4web/hooks/WebContentHook.java b/src/fr/devinsy/kiss4web/dispatcher/hooks/WebContentHook.java
similarity index 77%
rename from src/fr/devinsy/kiss4web/hooks/WebContentHook.java
rename to src/fr/devinsy/kiss4web/dispatcher/hooks/WebContentHook.java
index ae31e83..9172797 100644
--- a/src/fr/devinsy/kiss4web/hooks/WebContentHook.java
+++ b/src/fr/devinsy/kiss4web/dispatcher/hooks/WebContentHook.java
@@ -1,5 +1,5 @@
/**
- * Copyright (C) 2006-2010, 2013-2016 Christian Pierre MOMON
+ * Copyright (C) 2006-2021 Christian Pierre MOMON
*
* This file is part of Kiss4web.
*
@@ -16,7 +16,7 @@
* You should have received a copy of the GNU Lesser General Public License
* along with Kiss4web. If not, see
*/
-package fr.devinsy.kiss4web.hooks;
+package fr.devinsy.kiss4web.dispatcher.hooks;
import java.io.File;
import java.io.IOException;
@@ -30,47 +30,25 @@ import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import fr.devinsy.kiss4web.KissDispatcherUtils;
+import fr.devinsy.kiss4web.dispatcher.KissDispatcherUtils;
/**
- *
+ * The Class WebContentHook.
*/
public class WebContentHook extends HookCore
{
private static Logger logger = LoggerFactory.getLogger(WebContentHook.class);
/**
- *
+ * Instantiates a new web content hook.
*/
public WebContentHook()
{
super();
}
- /**
- * @throws IOException
- * @throws ServletException
- *
- */
- @Override
- public void process(final ServletConfig servletConfig, final ServletContext servletContext, final HttpServletRequest request,
- final HttpServletResponse response) throws IOException, ServletException
- {
- logger.debug("Doing catch.");
-
- String path = servletContext.getRealPath("/") + request.getPathInfo();
- logger.info("path=[{}]", path);
-
- String mimeType = servletContext.getMimeType(path);
- KissDispatcherUtils.returnInlineFile(response, new File(path), mimeType);
-
- logger.info("File returned directly [{}] with mimetype [{}].", path, servletContext.getMimeType(path));
- }
-
- /**
- *
- * @param urlPath
- * @return
+ /* (non-Javadoc)
+ * @see fr.devinsy.kiss4web.hooks.Hook#matches(javax.servlet.ServletContext, javax.servlet.http.HttpServletRequest)
*/
@Override
public boolean matches(final ServletContext servletContext, final HttpServletRequest request)
@@ -89,4 +67,22 @@ public class WebContentHook extends HookCore
//
return result;
}
+
+ /* (non-Javadoc)
+ * @see fr.devinsy.kiss4web.hooks.Hook#process(javax.servlet.ServletConfig, javax.servlet.ServletContext, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
+ */
+ @Override
+ public void process(final ServletConfig servletConfig, final ServletContext servletContext, final HttpServletRequest request,
+ final HttpServletResponse response) throws IOException, ServletException
+ {
+ logger.debug("Doing catch.");
+
+ String path = servletContext.getRealPath("/") + request.getPathInfo();
+ logger.info("path=[{}]", path);
+
+ String mimeType = servletContext.getMimeType(path);
+ KissDispatcherUtils.returnInlineFile(response, new File(path), mimeType);
+
+ logger.info("File returned directly [{}] with mimetype [{}].", path, servletContext.getMimeType(path));
+ }
}
diff --git a/src/fr/devinsy/kiss4web/hooks/WebInfHook.java b/src/fr/devinsy/kiss4web/dispatcher/hooks/WebInfHook.java
similarity index 77%
rename from src/fr/devinsy/kiss4web/hooks/WebInfHook.java
rename to src/fr/devinsy/kiss4web/dispatcher/hooks/WebInfHook.java
index 40b0bc7..6265a9d 100644
--- a/src/fr/devinsy/kiss4web/hooks/WebInfHook.java
+++ b/src/fr/devinsy/kiss4web/dispatcher/hooks/WebInfHook.java
@@ -1,5 +1,5 @@
/**
- * Copyright (C) 2006-2010, 2013-2016 Christian Pierre MOMON
+ * Copyright (C) 2006-2021 Christian Pierre MOMON
*
* This file is part of Kiss4web.
*
@@ -16,7 +16,7 @@
* You should have received a copy of the GNU Lesser General Public License
* along with Kiss4web. If not, see
*/
-package fr.devinsy.kiss4web.hooks;
+package fr.devinsy.kiss4web.dispatcher.hooks;
import java.io.File;
import java.io.IOException;
@@ -30,48 +30,25 @@ import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import fr.devinsy.kiss4web.KissDispatcherUtils;
+import fr.devinsy.kiss4web.dispatcher.KissDispatcherUtils;
/**
- *
+ * The Class WebInfHook.
*/
public class WebInfHook extends HookCore
{
private static Logger logger = LoggerFactory.getLogger(WebInfHook.class);
/**
- *
+ * Instantiates a new web inf hook.
*/
public WebInfHook()
{
super();
}
- /**
- * @throws IOException
- * @throws ServletException
- *
- */
- @Override
- public void process(final ServletConfig servletConfig, final ServletContext servletContext, final HttpServletRequest request,
- final HttpServletResponse response) throws IOException, ServletException
- {
- logger.debug("Doing catch.");
-
- String path = servletContext.getRealPath("/") + "WEB-INF/classes/website" + request.getPathInfo();
-
- logger.info("path=[{}]", path);
-
- String mimeType = servletContext.getMimeType(path);
- KissDispatcherUtils.returnInlineFile(response, new File(path), mimeType);
-
- logger.info("File returned directly [{}] with mimetype [{}].", path, servletContext.getMimeType(path));
- }
-
- /**
- *
- * @param urlPath
- * @return
+ /* (non-Javadoc)
+ * @see fr.devinsy.kiss4web.hooks.Hook#matches(javax.servlet.ServletContext, javax.servlet.http.HttpServletRequest)
*/
@Override
public boolean matches(final ServletContext servletContext, final HttpServletRequest request)
@@ -90,4 +67,23 @@ public class WebInfHook extends HookCore
//
return result;
}
+
+ /* (non-Javadoc)
+ * @see fr.devinsy.kiss4web.hooks.Hook#process(javax.servlet.ServletConfig, javax.servlet.ServletContext, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
+ */
+ @Override
+ public void process(final ServletConfig servletConfig, final ServletContext servletContext, final HttpServletRequest request,
+ final HttpServletResponse response) throws IOException, ServletException
+ {
+ logger.debug("Doing catch.");
+
+ String path = servletContext.getRealPath("/") + "WEB-INF/classes/website" + request.getPathInfo();
+
+ logger.info("path=[{}]", path);
+
+ String mimeType = servletContext.getMimeType(path);
+ KissDispatcherUtils.returnInlineFile(response, new File(path), mimeType);
+
+ logger.info("File returned directly [{}] with mimetype [{}].", path, servletContext.getMimeType(path));
+ }
}
diff --git a/src/fr/devinsy/kiss4web/hooks/XHTMLHook.java b/src/fr/devinsy/kiss4web/dispatcher/hooks/XHTMLHook.java
similarity index 75%
rename from src/fr/devinsy/kiss4web/hooks/XHTMLHook.java
rename to src/fr/devinsy/kiss4web/dispatcher/hooks/XHTMLHook.java
index 7a206ec..83b27f6 100644
--- a/src/fr/devinsy/kiss4web/hooks/XHTMLHook.java
+++ b/src/fr/devinsy/kiss4web/dispatcher/hooks/XHTMLHook.java
@@ -1,5 +1,5 @@
/**
- * Copyright (C) 2006-2010, 2013-2016 Christian Pierre MOMON
+ * Copyright (C) 2006-2021 Christian Pierre MOMON
*
* This file is part of Kiss4web.
*
@@ -16,7 +16,7 @@
* You should have received a copy of the GNU Lesser General Public License
* along with Kiss4web. If not, see
*/
-package fr.devinsy.kiss4web.hooks;
+package fr.devinsy.kiss4web.dispatcher.hooks;
import java.io.IOException;
@@ -29,42 +29,25 @@ import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import fr.devinsy.kiss4web.KissDispatcherUtils;
+import fr.devinsy.kiss4web.dispatcher.KissDispatcherUtils;
/**
- *
+ * The Class XHTMLHook.
*/
public class XHTMLHook extends HookCore
{
private static Logger logger = LoggerFactory.getLogger(XHTMLHook.class);
/**
- *
+ * Instantiates a new XHTML hook.
*/
public XHTMLHook()
{
super();
}
- /**
- * @throws IOException
- * @throws ServletException
- */
- @Override
- public void process(final ServletConfig servletConfig, final ServletContext servletContext, final HttpServletRequest request,
- final HttpServletResponse response) throws IOException, ServletException
- {
- logger.debug("Doing catch.");
-
- String urlPath = request.getPathInfo();
-
- KissDispatcherUtils.dispatchToServlet(servletConfig, request, response, urlPath);
- }
-
- /**
- *
- * @param urlPath
- * @return
+ /* (non-Javadoc)
+ * @see fr.devinsy.kiss4web.hooks.Hook#matches(javax.servlet.ServletContext, javax.servlet.http.HttpServletRequest)
*/
@Override
public boolean matches(final ServletContext servletContext, final HttpServletRequest request)
@@ -86,4 +69,17 @@ public class XHTMLHook extends HookCore
return result;
}
+ /* (non-Javadoc)
+ * @see fr.devinsy.kiss4web.hooks.Hook#process(javax.servlet.ServletConfig, javax.servlet.ServletContext, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
+ */
+ @Override
+ public void process(final ServletConfig servletConfig, final ServletContext servletContext, final HttpServletRequest request,
+ final HttpServletResponse response) throws IOException, ServletException
+ {
+ logger.debug("Doing catch.");
+
+ String urlPath = request.getPathInfo();
+
+ KissDispatcherUtils.dispatchToServlet(servletConfig, request, response, urlPath);
+ }
}
diff --git a/test/FooSandbox.java b/test/FooSandbox.java
index 33492d4..d28effb 100644
--- a/test/FooSandbox.java
+++ b/test/FooSandbox.java
@@ -16,7 +16,7 @@
* You should have received a copy of the GNU Lesser General Public License
* along with Kiss4web. If not, see
*/
-import fr.devinsy.kiss4web.KissDispatcherUtils;
+import fr.devinsy.kiss4web.dispatcher.KissDispatcherUtils;
/**
* Kiss4Web tests.
diff --git a/test/fr/devinsy/kiss4web/catchers/BlankCatcherTest.java b/test/fr/devinsy/kiss4web/catchers/BlankCatcherTest.java
index c7ae845..6221578 100644
--- a/test/fr/devinsy/kiss4web/catchers/BlankCatcherTest.java
+++ b/test/fr/devinsy/kiss4web/catchers/BlankCatcherTest.java
@@ -23,8 +23,8 @@ import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import fr.devinsy.kiss4web.hooks.BlankHook;
-import fr.devinsy.kiss4web.hooks.ShortURLHook;
+import fr.devinsy.kiss4web.dispatcher.hooks.BlankHook;
+import fr.devinsy.kiss4web.dispatcher.hooks.ShortURLHook;
import fr.devinsy.kiss4web.mocks.HttpServletRequestMock;
/**
diff --git a/test/fr/devinsy/kiss4web/catchers/RootCatcherTest.java b/test/fr/devinsy/kiss4web/catchers/RootCatcherTest.java
index 051c0fd..768262d 100644
--- a/test/fr/devinsy/kiss4web/catchers/RootCatcherTest.java
+++ b/test/fr/devinsy/kiss4web/catchers/RootCatcherTest.java
@@ -23,8 +23,8 @@ import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import fr.devinsy.kiss4web.hooks.RootHook;
-import fr.devinsy.kiss4web.hooks.ShortURLHook;
+import fr.devinsy.kiss4web.dispatcher.hooks.RootHook;
+import fr.devinsy.kiss4web.dispatcher.hooks.ShortURLHook;
import fr.devinsy.kiss4web.mocks.HttpServletRequestMock;
/**
diff --git a/test/fr/devinsy/kiss4web/mocks/HttpServletRequestMock.java b/test/fr/devinsy/kiss4web/mocks/HttpServletRequestMock.java
index 9446efc..11fbb28 100644
--- a/test/fr/devinsy/kiss4web/mocks/HttpServletRequestMock.java
+++ b/test/fr/devinsy/kiss4web/mocks/HttpServletRequestMock.java
@@ -44,7 +44,7 @@ import javax.servlet.http.Part;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import fr.devinsy.kiss4web.hooks.ShortURLHook;
+import fr.devinsy.kiss4web.dispatcher.hooks.ShortURLHook;
/**
*