JETTY-1231 support context request log
git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@1933 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
parent
a2bd4024c7
commit
595f0e6f72
|
@ -12,6 +12,7 @@ jetty-7.1.4-SNAPSHOT
|
|||
+ 315744 Fixed STOP.PORT and STOP.KEY in start.jar
|
||||
+ 315748 Removed --fromDaemon from start.jar
|
||||
+ 315925 Improved context xml configuration handling
|
||||
+ JETTY-1231 Support context request log handler
|
||||
|
||||
jetty-7.1.3.v20100526
|
||||
+ 296567 HttpClient RedirectListener handles new HttpDestination
|
||||
|
|
|
@ -860,8 +860,7 @@ public class ContextHandler extends ScopedHandler implements Attributes, Server.
|
|||
}
|
||||
|
||||
// start manual inline of nextScope(target,baseRequest,request,response);
|
||||
//noinspection ConstantIfStatement
|
||||
if (false)
|
||||
if (never())
|
||||
nextScope(target,baseRequest,request,response);
|
||||
else if (_nextScope!=null)
|
||||
_nextScope.doScope(target,baseRequest,request, response);
|
||||
|
@ -925,7 +924,7 @@ public class ContextHandler extends ScopedHandler implements Attributes, Server.
|
|||
|
||||
// start manual inline of nextHandle(target,baseRequest,request,response);
|
||||
//noinspection ConstantIfStatement
|
||||
if (false)
|
||||
if (never())
|
||||
nextHandle(target,baseRequest,request,response);
|
||||
else if (_nextScope!=null && _nextScope==_handler)
|
||||
_nextScope.doHandle(target,baseRequest,request, response);
|
||||
|
@ -1727,14 +1726,6 @@ public class ContextHandler extends ScopedHandler implements Attributes, Server.
|
|||
*/
|
||||
public synchronized void setAttribute(String name, Object value)
|
||||
{
|
||||
|
||||
if (_contextAttributes==null)
|
||||
{
|
||||
// Set it on the handler
|
||||
ContextHandler.this.setAttribute(name, value);
|
||||
return;
|
||||
}
|
||||
|
||||
checkManagedAttribute(name,value);
|
||||
Object old_value=_contextAttributes.getAttribute(name);
|
||||
|
||||
|
|
|
@ -147,6 +147,5 @@ public class RequestLogHandler extends HandlerWrapper
|
|||
if (_requestLog!=null)
|
||||
_requestLog.stop();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -134,7 +134,7 @@ public abstract class ScopedHandler extends HandlerWrapper
|
|||
throws IOException, ServletException
|
||||
{
|
||||
// this method has been manually inlined in several locations, but
|
||||
// is called protected by an in(false), so your IDE can find those
|
||||
// is called protected by an if(never()), so your IDE can find those
|
||||
// locations if this code is changed.
|
||||
if (_nextScope!=null)
|
||||
_nextScope.doScope(target,baseRequest,request, response);
|
||||
|
@ -158,7 +158,7 @@ public abstract class ScopedHandler extends HandlerWrapper
|
|||
public final void nextHandle(String target, final Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
|
||||
{
|
||||
// this method has been manually inlined in several locations, but
|
||||
// is called protected by an in(false), so your IDE can find those
|
||||
// is called protected by an if(never()), so your IDE can find those
|
||||
// locations if this code is changed.
|
||||
if (_nextScope!=null && _nextScope==_handler)
|
||||
_nextScope.doHandle(target,baseRequest,request, response);
|
||||
|
@ -166,4 +166,10 @@ public abstract class ScopedHandler extends HandlerWrapper
|
|||
_handler.handle(target,baseRequest, request, response);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
protected boolean never()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -217,8 +217,7 @@ public class SessionHandler extends ScopedHandler
|
|||
throws IOException, ServletException
|
||||
{
|
||||
// start manual inline of nextHandle(target,baseRequest,request,response);
|
||||
//noinspection ConstantIfStatement
|
||||
if (false)
|
||||
if (never())
|
||||
nextHandle(target,baseRequest,request,response);
|
||||
else if (_nextScope!=null && _nextScope==_handler)
|
||||
_nextScope.doHandle(target,baseRequest,request, response);
|
||||
|
|
|
@ -156,7 +156,7 @@ public class ContextHandlerTest
|
|||
handler.setAttribute("aaa","111");
|
||||
handler.getServletContext().setAttribute("bbb","222");
|
||||
assertEquals("111",handler.getServletContext().getAttribute("aaa"));
|
||||
assertEquals("222",handler.getAttribute("bbb"));
|
||||
assertEquals(null,handler.getAttribute("bbb"));
|
||||
|
||||
handler.start();
|
||||
|
||||
|
@ -164,20 +164,20 @@ public class ContextHandlerTest
|
|||
handler.setAttribute("ccc","333");
|
||||
handler.getServletContext().setAttribute("ddd","444");
|
||||
assertEquals("111",handler.getServletContext().getAttribute("aaa"));
|
||||
assertEquals("222",handler.getServletContext().getAttribute("bbb"));
|
||||
assertEquals(null,handler.getServletContext().getAttribute("bbb"));
|
||||
handler.getServletContext().setAttribute("bbb","222");
|
||||
assertEquals("333",handler.getServletContext().getAttribute("ccc"));
|
||||
assertEquals("444",handler.getServletContext().getAttribute("ddd"));
|
||||
|
||||
assertEquals("111",handler.getAttribute("aaa"));
|
||||
assertEquals("222",handler.getAttribute("bbb"));
|
||||
assertEquals(null,handler.getAttribute("bbb"));
|
||||
assertEquals("333",handler.getAttribute("ccc"));
|
||||
assertEquals(null,handler.getAttribute("ddd"));
|
||||
|
||||
|
||||
handler.stop();
|
||||
|
||||
assertEquals("111",handler.getServletContext().getAttribute("aaa"));
|
||||
assertEquals("222",handler.getServletContext().getAttribute("bbb"));
|
||||
assertEquals(null,handler.getServletContext().getAttribute("bbb"));
|
||||
assertEquals("333",handler.getServletContext().getAttribute("ccc"));
|
||||
assertEquals(null,handler.getServletContext().getAttribute("ddd"));
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ import org.eclipse.jetty.server.handler.ContextHandler;
|
|||
import org.eclipse.jetty.server.handler.ErrorHandler;
|
||||
import org.eclipse.jetty.server.handler.HandlerCollection;
|
||||
import org.eclipse.jetty.server.handler.HandlerWrapper;
|
||||
import org.eclipse.jetty.server.handler.ScopedHandler;
|
||||
import org.eclipse.jetty.server.session.SessionHandler;
|
||||
|
||||
|
||||
|
@ -183,13 +184,24 @@ public class ServletContextHandler extends ContextHandler
|
|||
handler=_sessionHandler;
|
||||
}
|
||||
|
||||
setHandler(handler);
|
||||
// skip any wrapped handlers
|
||||
HandlerWrapper wrapper=this;
|
||||
while (wrapper!=handler && wrapper.getHandler() instanceof HandlerWrapper)
|
||||
wrapper=(HandlerWrapper)wrapper.getHandler();
|
||||
|
||||
// if we are not already linked
|
||||
if (wrapper!=handler)
|
||||
{
|
||||
if (wrapper.getHandler()!=null )
|
||||
throw new IllegalStateException("!ScopedHandler");
|
||||
wrapper.setHandler(handler);
|
||||
}
|
||||
|
||||
super.startContext();
|
||||
|
||||
// OK to Initialize servlet handler now
|
||||
if (_servletHandler != null && _servletHandler.isStarted())
|
||||
_servletHandler.initialize();
|
||||
_servletHandler.initialize();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
|
|
@ -350,7 +350,7 @@ public class ServletHandler extends ScopedHandler
|
|||
baseRequest.setUserIdentityScope(servlet_holder);
|
||||
|
||||
// start manual inline of nextScope(target,baseRequest,request,response);
|
||||
if (false)
|
||||
if (never())
|
||||
nextScope(target,baseRequest,request,response);
|
||||
else if (_nextScope!=null)
|
||||
_nextScope.doScope(target,baseRequest,request, response);
|
||||
|
|
|
@ -140,7 +140,9 @@ public class WebAppClassLoader extends URLClassLoader
|
|||
addClassPath(r);
|
||||
}
|
||||
else
|
||||
addURL(resource.getURL());
|
||||
{
|
||||
addClassPath(resource.toString());
|
||||
}
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
|
|
@ -41,7 +41,7 @@ public class WebAppClassLoaderTest
|
|||
assertTrue(canLoadClass("org.acme.webapp.ClassInJarB"));
|
||||
assertTrue(canLoadClass("org.acme.other.ClassInClassesC"));
|
||||
|
||||
assertFalse(canLoadClass("org.eclipse.jetty.webapp.Configuration"));
|
||||
assertTrue(cantLoadClass("org.eclipse.jetty.webapp.Configuration"));
|
||||
|
||||
Class clazzA = _loader.loadClass("org.acme.webapp.ClassInJarA");
|
||||
assertTrue(clazzA.getField("FROM_PARENT")!=null);
|
||||
|
@ -55,7 +55,7 @@ public class WebAppClassLoaderTest
|
|||
assertTrue(canLoadClass("org.acme.webapp.ClassInJarB"));
|
||||
assertTrue(canLoadClass("org.acme.other.ClassInClassesC"));
|
||||
|
||||
assertFalse(canLoadClass("org.eclipse.jetty.webapp.Configuration"));
|
||||
assertTrue(cantLoadClass("org.eclipse.jetty.webapp.Configuration"));
|
||||
|
||||
Class<?> clazzA = _loader.loadClass("org.acme.webapp.ClassInJarA");
|
||||
try
|
||||
|
@ -83,7 +83,7 @@ public class WebAppClassLoaderTest
|
|||
assertTrue(canLoadClass("org.acme.other.ClassInClassesC"));
|
||||
|
||||
assertTrue(canLoadClass("org.eclipse.jetty.webapp.Configuration"));
|
||||
assertFalse(canLoadClass("org.eclipse.jetty.webapp.JarScanner"));
|
||||
assertTrue(cantLoadClass("org.eclipse.jetty.webapp.JarScanner"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -105,8 +105,8 @@ public class WebAppClassLoaderTest
|
|||
assertTrue(canLoadClass("org.acme.webapp.ClassInJarB"));
|
||||
assertTrue(canLoadClass("org.acme.other.ClassInClassesC"));
|
||||
|
||||
assertFalse(canLoadClass("org.eclipse.jetty.webapp.Configuration"));
|
||||
assertFalse(canLoadClass("org.eclipse.jetty.webapp.JarScanner"));
|
||||
assertTrue(cantLoadClass("org.eclipse.jetty.webapp.Configuration"));
|
||||
assertTrue(cantLoadClass("org.eclipse.jetty.webapp.JarScanner"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -161,15 +161,20 @@ public class WebAppClassLoaderTest
|
|||
return list;
|
||||
}
|
||||
|
||||
private boolean canLoadClass(String clazz)
|
||||
private boolean canLoadClass(String clazz) throws ClassNotFoundException
|
||||
{
|
||||
return _loader.loadClass(clazz)!=null;
|
||||
}
|
||||
|
||||
private boolean cantLoadClass(String clazz)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _loader.loadClass(clazz)!=null;
|
||||
return _loader.loadClass(clazz)==null;
|
||||
}
|
||||
catch(ClassNotFoundException e)
|
||||
{
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -75,4 +75,19 @@ detected.
|
|||
</Get>
|
||||
-->
|
||||
|
||||
<!-- Add context specific logger
|
||||
<Set name="handler">
|
||||
<New id="RequestLog" class="org.eclipse.jetty.server.handler.RequestLogHandler">
|
||||
<Set name="requestLog">
|
||||
<New id="RequestLogImpl" class="org.eclipse.jetty.server.NCSARequestLog">
|
||||
<Set name="filename"><Property name="jetty.logs" default="./logs"/>/test-yyyy_mm_dd.request.log</Set>
|
||||
<Set name="filenameDateFormat">yyyy_MM_dd</Set>
|
||||
<Set name="append">true</Set>
|
||||
<Set name="LogTimeZone">GMT</Set>
|
||||
</New>
|
||||
</Set>
|
||||
</New>
|
||||
</Set>
|
||||
-->
|
||||
|
||||
</Configure>
|
||||
|
|
Loading…
Reference in New Issue