improve GitCGIServlet

This commit is contained in:
Sebastian Sdorra
2010-10-12 14:56:29 +02:00
parent 030b2e8db0
commit 9396e9e86a
6 changed files with 144 additions and 72 deletions

View File

@@ -56,8 +56,9 @@ public abstract class AbstractCGIServlet extends HttpServlet
@Override
public void init() throws ServletException
{
cgiRunner = new CGIRunner(getServletContext(), createEnvironment(),
getCmdPrefix(), isExitStateIgnored());
cgiRunner = new CGIRunner(getServletContext(), getCmdPrefix(),
isExitStateIgnored());
baseEnvironment = createBaseEnvironment();
}
/**
@@ -65,8 +66,10 @@ public abstract class AbstractCGIServlet extends HttpServlet
*
*
* @return
*
* @throws ServletException
*/
protected EnvList createEnvironment()
protected EnvList createBaseEnvironment() throws ServletException
{
EnvList env = new EnvList();
Enumeration e = getInitParameterNames();
@@ -94,6 +97,22 @@ public abstract class AbstractCGIServlet extends HttpServlet
return env;
}
/**
* Method description
*
*
* @param baseEnvironment
*
* @return
*
* @throws ServletException
*/
protected EnvList createRequestEnvironment(EnvList baseEnvironment)
throws ServletException
{
return new EnvList(baseEnvironment);
}
/**
* Method description
*
@@ -108,7 +127,8 @@ public abstract class AbstractCGIServlet extends HttpServlet
protected void service(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException
{
cgiRunner.exec(getCommand(req), req.getPathInfo(), req, resp);
cgiRunner.exec(createRequestEnvironment(baseEnvironment), getCommand(req),
req.getPathInfo(), req, resp);
}
//~--- get methods ----------------------------------------------------------
@@ -124,10 +144,6 @@ public abstract class AbstractCGIServlet extends HttpServlet
return null;
}
;
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
@@ -139,10 +155,11 @@ public abstract class AbstractCGIServlet extends HttpServlet
return false;
}
;
//~--- fields ---------------------------------------------------------------
/** Field description */
private EnvList baseEnvironment;
/** Field description */
private CGIRunner cgiRunner;
}