Skip to content

Commit

Permalink
[maven-release-plugin] copy for tag jetty-7.0.0.RC6
Browse files Browse the repository at this point in the history
git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/tags/jetty-7.0.0.RC6@944 7e9141cc-0065-0410-87d8-b60c137991c4
  • Loading branch information
jmcc0nn3ll committed Sep 21, 2009
2 parents d6c76a4 + 16dc3c6 commit 9a40cc7
Show file tree
Hide file tree
Showing 5 changed files with 117 additions and 19 deletions.
4 changes: 3 additions & 1 deletion VERSION.txt
@@ -1,4 +1,6 @@
jetty-7.0.0.RC6 September 18th 2009
jetty-7.0.0.RC6 September 21 2009
+ 289958 StatisticsServlet incorrectly adds StatisticsHandler
+ Remove printlns from jetty-plus
+ JETTY-719 Document state machine of jetty http client
+ JETTY-780 CNFE during startup of webapp with spring-context >= 2.5.1
+ JETTY-936 274251 Improved servlet matching and optimized'
Expand Down
Expand Up @@ -237,12 +237,10 @@ protected void injectField (Field field, Object injectable)
{
try
{
System.err.println("Value to inject="+lookupInjectedValue());
boolean accessibility = field.isAccessible();
field.setAccessible(true);
field.set(injectable, lookupInjectedValue());
field.setAccessible(accessibility);
System.err.println("Injected field "+_fieldName+" of class "+_className);
}
catch (Exception e)
{
Expand All @@ -265,12 +263,10 @@ protected void injectMethod (Method method, Object injectable)
{
try
{
System.err.println("Value to inject="+lookupInjectedValue());
boolean accessibility = method.isAccessible();
method.setAccessible(true);
method.invoke(injectable, new Object[] {lookupInjectedValue()});
method.setAccessible(accessibility);
System.err.println("Injected method "+_methodName+" of class "+_className);
}
catch (Exception e)
{
Expand Down Expand Up @@ -311,14 +307,12 @@ protected void loadMethod ()

if (_targetClass == null)
_targetClass = Loader.loadClass(null, _className);
System.err.println("Loaded target class "+_targetClass.getName());

System.err.println("Looking for method "+_methodName +" with argument of type "+_paramCanonicalName+" on class "+_className);

Class arg = TypeUtil.fromName(_paramCanonicalName);

if (arg == null)
arg = Loader.loadClass(null, _paramCanonicalName);
System.err.println("Loaded type: "+arg.getName());

_target = _targetClass.getDeclaredMethod(_methodName, new Class[] {arg});
}

Expand All @@ -331,7 +325,6 @@ private boolean validateInjection ()
//JavaEE spec sec 5.2.4
if (_annotationResourceType != null)
{
System.err.println("Validating against annotationResourceType="+_annotationResourceType);
if (_target == null)
return false;

Expand Down
Expand Up @@ -109,7 +109,6 @@ public void callback (Object instance)
getTarget().setAccessible(true);
getTarget().invoke(instance, __EMPTY_ARGS);
getTarget().setAccessible(accessibility);
System.err.println("Calling callback on "+_className+"."+_methodName);
}
}

Expand Down
Expand Up @@ -39,8 +39,6 @@ public class StatisticsServlet extends HttpServlet

public void init() throws ServletException
{
_memoryBean = ManagementFactory.getMemoryMXBean();

ServletContext context = getServletContext();
ContextHandler.Context scontext = (ContextHandler.Context) context;
Server _server = scontext.getContextHandler().getServer();
Expand All @@ -53,12 +51,11 @@ public void init() throws ServletException
}
else
{
Log.info("Installing Statistics Handler");
_statsHandler = new StatisticsHandler();
_server.setHandler(_statsHandler);
Log.warn("Statistics Handler not installed!");
return;
}


_memoryBean = ManagementFactory.getMemoryMXBean();
_connectors = _server.getConnectors();

if (getInitParameter("restrictToLocalhost") != null)
Expand All @@ -75,7 +72,12 @@ public void doPost(HttpServletRequest sreq, HttpServletResponse sres) throws Ser

protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
{

if (_statsHandler == null)
{
Log.warn("Statistics Handler not installed!");
resp.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE);
return;
}
if (_restrictToLocalhost)
{
if (!"127.0.0.1".equals(req.getRemoteAddr()))
Expand Down
@@ -0,0 +1,102 @@
// ========================================================================
// Copyright (c) 2009 Mort Bay Consulting Pty. Ltd.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
// The Eclipse Public License is available at
// http://www.eclipse.org/legal/epl-v10.html
// The Apache License v2.0 is available at
// http://www.opensource.org/licenses/apache2.0.php
// You may elect to redistribute this code under either of these licenses.
// ========================================================================
package org.eclipse.jetty.servlet;

import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.LocalConnector;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.StatisticsHandler;

import junit.framework.AssertionFailedError;
import junit.framework.TestCase;

public class StatisticsServletTest extends TestCase
{
Server server;
LocalConnector connector;
ServletContextHandler context;

protected void setUp() throws Exception
{
super.setUp();

server = new Server();
server.setSendServerVersion(false);
context = new ServletContextHandler();
context.setContextPath("/");
ServletHolder holder = new ServletHolder();
holder.setServlet(new org.eclipse.jetty.servlet.StatisticsServlet());
holder.setInitParameter("restrictToLocalhost", "false");
context.addServlet(holder, "/stats");

server.setHandler(context);
connector = new LocalConnector();
server.addConnector(connector);
}

protected void tearDown() throws Exception
{
super.tearDown();

if (server != null)
{
server.stop();
}
}


public void testNoHandler () throws Exception
{
server.start();

StringBuffer req1 = new StringBuffer();
req1.append("GET /stats HTTP/1.1\n");
req1.append("Host: localhost\n");
req1.append("\n");

String response = connector.getResponses(req1.toString());
assertResponseContains("503", response);
}

public void testWithHandler () throws Exception
{
StatisticsHandler statsHandler = new StatisticsHandler();
statsHandler.setHandler(context);
server.setHandler(statsHandler);
server.start();

StringBuffer req1 = new StringBuffer();
req1.append("GET /stats HTTP/1.1\n");
req1.append("Host: localhost\n");
req1.append("\n");

String response = connector.getResponses(req1.toString());
assertResponseContains("Statistics gathering started ", response);
}


private void assertResponseContains(String expected, String response)
{
int idx = response.indexOf(expected);
if (idx == (-1))
{
// Not found
StringBuffer err = new StringBuffer();
err.append("Response does not contain expected string \"").append(expected).append("\"");
err.append("\n").append(response);

System.err.println(err);
throw new AssertionFailedError(err.toString());
}
}
}

0 comments on commit 9a40cc7

Please sign in to comment.