bug 336056 Ability to override the computation of the ContextHandler to deploy the DefaultServlet on equinox's HttpServiceServlet.

git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@3104 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
Hugues Malphettes 2011-05-10 03:29:29 +00:00
parent 540ba7174f
commit dedc2b648d
2 changed files with 25 additions and 5 deletions

View File

@ -19,6 +19,7 @@ jetty-7.4.1-SNAPSHOT
+ JETTY-1326 Invoker names not hashCode based
+ JETTY-1343 IllegalArgumentException for bad % encodings
+ JETTY-1347 Updated ServletHander javadoc
+ 336056 Ability to override the computation of the ContextHandler to deploy the DefaultServlet on the HttpService
jetty-7.4.0.v20110414
+ 342504 Scanner Listener

View File

@ -162,11 +162,7 @@ public class DefaultServlet extends HttpServlet implements ResourceFactory
throws UnavailableException
{
_servletContext=getServletContext();
ContextHandler.Context scontext=ContextHandler.getCurrentContext();
if (scontext==null)
_contextHandler=((ContextHandler.Context)_servletContext).getContextHandler();
else
_contextHandler = ContextHandler.getCurrentContext().getContextHandler();
_contextHandler = initContextHandler(_servletContext);
_mimeTypes = _contextHandler.getMimeTypes();
@ -284,6 +280,29 @@ public class DefaultServlet extends HttpServlet implements ResourceFactory
if (Log.isDebugEnabled()) Log.debug("resource base = "+_resourceBase);
}
/**
* Compute the field _contextHandler.<br/>
* In the case where the DefaultServlet is deployed on the HttpService it is likely that
* this method needs to be overwritten to unwrap the ServletContext facade until we reach
* the original jetty's ContextHandler.
* @param servletContext The servletContext of this servlet.
* @return the jetty's ContextHandler for this servletContext.
*/
protected ContextHandler initContextHandler(ServletContext servletContext)
{
ContextHandler.Context scontext=ContextHandler.getCurrentContext();
if (scontext==null)
{
if (servletContext instanceof ContextHandler.Context)
return ((ContextHandler.Context)servletContext).getContextHandler();
else
throw new IllegalArgumentException("The servletContext " + servletContext + " " +
servletContext.getClass().getName() + " is not " + ContextHandler.Context.class.getName());
}
else
return ContextHandler.getCurrentContext().getContextHandler();
}
/* ------------------------------------------------------------ */
@Override
public String getInitParameter(String name)