Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Wilkins2010-06-07 10:15:05 +0000
committerGreg Wilkins2010-06-07 10:15:05 +0000
commit595f0e6f72ce1b7fffc5b62d6728602b3f7d706f (patch)
tree2e56c5308ea53193a5b7bc0fadb2ee22dc34bf31
parenta2bd4024c7f1cef9ae7f4a7dd45cbf699f007231 (diff)
downloadorg.eclipse.jetty.project-595f0e6f72ce1b7fffc5b62d6728602b3f7d706f.tar.gz
org.eclipse.jetty.project-595f0e6f72ce1b7fffc5b62d6728602b3f7d706f.tar.xz
org.eclipse.jetty.project-595f0e6f72ce1b7fffc5b62d6728602b3f7d706f.zip
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
-rw-r--r--VERSION.txt1
-rw-r--r--jetty-server/src/main/java/org/eclipse/jetty/server/handler/ContextHandler.java13
-rw-r--r--jetty-server/src/main/java/org/eclipse/jetty/server/handler/RequestLogHandler.java1
-rw-r--r--jetty-server/src/main/java/org/eclipse/jetty/server/handler/ScopedHandler.java10
-rw-r--r--jetty-server/src/main/java/org/eclipse/jetty/server/session/SessionHandler.java3
-rw-r--r--jetty-server/src/test/java/org/eclipse/jetty/server/handler/ContextHandlerTest.java10
-rw-r--r--jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletContextHandler.java16
-rw-r--r--jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletHandler.java2
-rw-r--r--jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebAppClassLoader.java4
-rw-r--r--jetty-webapp/src/test/java/org/eclipse/jetty/webapp/WebAppClassLoaderTest.java21
-rw-r--r--test-jetty-webapp/src/main/config/contexts/test.xml15
11 files changed, 63 insertions, 33 deletions
diff --git a/VERSION.txt b/VERSION.txt
index e786f689bf..d49e178820 100644
--- a/VERSION.txt
+++ b/VERSION.txt
@@ -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
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ContextHandler.java b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ContextHandler.java
index c76db7e8ae..34a8a3286b 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ContextHandler.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ContextHandler.java
@@ -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);
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/RequestLogHandler.java b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/RequestLogHandler.java
index 1a0c26e365..24b1d2ed92 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/RequestLogHandler.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/RequestLogHandler.java
@@ -147,6 +147,5 @@ public class RequestLogHandler extends HandlerWrapper
if (_requestLog!=null)
_requestLog.stop();
}
-
}
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ScopedHandler.java b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ScopedHandler.java
index ae3154c3b7..d4ff318c7a 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ScopedHandler.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ScopedHandler.java
@@ -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;
+ }
+
}
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/session/SessionHandler.java b/jetty-server/src/main/java/org/eclipse/jetty/server/session/SessionHandler.java
index 752a327b93..7f42428c4e 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/session/SessionHandler.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/session/SessionHandler.java
@@ -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);
diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ContextHandlerTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ContextHandlerTest.java
index c8d01d3418..059986f2de 100644
--- a/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ContextHandlerTest.java
+++ b/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ContextHandlerTest.java
@@ -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"));
}
diff --git a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletContextHandler.java b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletContextHandler.java
index 401523c3ab..36cbc575a4 100644
--- a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletContextHandler.java
+++ b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletContextHandler.java
@@ -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();
}
/* ------------------------------------------------------------ */
diff --git a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletHandler.java b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletHandler.java
index ba2494f42b..3df7379907 100644
--- a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletHandler.java
+++ b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletHandler.java
@@ -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);
diff --git a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebAppClassLoader.java b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebAppClassLoader.java
index 2a4b111c56..e071e88f86 100644
--- a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebAppClassLoader.java
+++ b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebAppClassLoader.java
@@ -140,7 +140,9 @@ public class WebAppClassLoader extends URLClassLoader
addClassPath(r);
}
else
- addURL(resource.getURL());
+ {
+ addClassPath(resource.toString());
+ }
}
/* ------------------------------------------------------------ */
diff --git a/jetty-webapp/src/test/java/org/eclipse/jetty/webapp/WebAppClassLoaderTest.java b/jetty-webapp/src/test/java/org/eclipse/jetty/webapp/WebAppClassLoaderTest.java
index 1ca4ff9a82..469a28b091 100644
--- a/jetty-webapp/src/test/java/org/eclipse/jetty/webapp/WebAppClassLoaderTest.java
+++ b/jetty-webapp/src/test/java/org/eclipse/jetty/webapp/WebAppClassLoaderTest.java
@@ -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;
}
}
}
diff --git a/test-jetty-webapp/src/main/config/contexts/test.xml b/test-jetty-webapp/src/main/config/contexts/test.xml
index fb5f7d31c5..3c36173b13 100644
--- a/test-jetty-webapp/src/main/config/contexts/test.xml
+++ b/test-jetty-webapp/src/main/config/contexts/test.xml
@@ -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>

Back to the top