mirror of
https://github.com/jetty/jetty.project.git
synced 2025-02-25 17:18:30 +00:00
Merge remote-tracking branch 'origin/master' into jetty-8
This commit is contained in:
commit
1e079f06c9
5
.gitignore
vendored
5
.gitignore
vendored
@ -3,7 +3,12 @@ target/
|
||||
.project
|
||||
.settings
|
||||
*/src/main/java/META-INF/
|
||||
.pmd
|
||||
*.log
|
||||
*.swp
|
||||
*.diff
|
||||
*.patch
|
||||
*.iml
|
||||
*.ipr
|
||||
*.iws
|
||||
.idea/
|
||||
|
@ -1,6 +1,9 @@
|
||||
BUILDING JETTY
|
||||
--------------
|
||||
|
||||
Jetty is built with maven >= 2.0.8
|
||||
Jetty is built with maven 3.x+
|
||||
|
||||
$ cd /my/work/directory/jetty-7
|
||||
$ mvn clean install
|
||||
|
||||
cd /my/work/directory/jetty-7
|
||||
mvn install
|
||||
|
||||
|
1766
VERSION.txt
1766
VERSION.txt
File diff suppressed because it is too large
Load Diff
8
eclipse-jetty-templates.xml
Normal file
8
eclipse-jetty-templates.xml
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<templates>
|
||||
<template autoinsert="true" context="java" deleted="false" description="Create Jetty Logger constant" enabled="true" name="logjetty">${:import(
|
||||
org.eclipse.jetty.util.log.Log,
|
||||
org.eclipse.jetty.util.log.Logger)
|
||||
}private static final Logger LOG = Log.getLogger(${enclosing_type}.class);
|
||||
</template>
|
||||
</templates>
|
@ -19,6 +19,7 @@ import org.eclipse.jetty.server.handler.DefaultHandler;
|
||||
import org.eclipse.jetty.server.handler.HandlerList;
|
||||
import org.eclipse.jetty.server.handler.ResourceHandler;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/** Simple Jetty FileServer.
|
||||
@ -33,6 +34,8 @@ import org.eclipse.jetty.util.log.Log;
|
||||
*/
|
||||
public class FileServer
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(FileServer.class);
|
||||
|
||||
public static void main(String[] args) throws Exception
|
||||
{
|
||||
Server server = new Server(args.length == 0?8080:Integer.parseInt(args[0]));
|
||||
@ -42,7 +45,7 @@ public class FileServer
|
||||
resource_handler.setWelcomeFiles(new String[]{ "index.html" });
|
||||
|
||||
resource_handler.setResourceBase(args.length == 2?args[1]:".");
|
||||
Log.info("serving " + resource_handler.getBaseResource());
|
||||
LOG.info("serving " + resource_handler.getBaseResource());
|
||||
|
||||
HandlerList handlers = new HandlerList();
|
||||
handlers.setHandlers(new Handler[] { resource_handler, new DefaultHandler() });
|
||||
|
@ -27,9 +27,10 @@ import org.eclipse.jetty.io.Buffer;
|
||||
import org.eclipse.jetty.io.EndPoint;
|
||||
import org.eclipse.jetty.server.BlockingHttpConnection;
|
||||
import org.eclipse.jetty.server.Connector;
|
||||
import org.eclipse.jetty.server.HttpConnection;
|
||||
import org.eclipse.jetty.server.Request;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
|
||||
/**
|
||||
* Connection implementation of the Ajp13 protocol. <p/> XXX Refactor to remove
|
||||
@ -38,6 +39,8 @@ import org.eclipse.jetty.server.Server;
|
||||
*/
|
||||
public class Ajp13Connection extends BlockingHttpConnection
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(Ajp13Connection.class);
|
||||
|
||||
public Ajp13Connection(Connector connector, EndPoint endPoint, Server server)
|
||||
{
|
||||
super(connector, endPoint, server,
|
||||
@ -124,8 +127,8 @@ public class Ajp13Connection extends BlockingHttpConnection
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
org.eclipse.jetty.util.log.Log.warn(e.toString());
|
||||
org.eclipse.jetty.util.log.Log.ignore(e);
|
||||
LOG.warn(e.toString());
|
||||
LOG.ignore(e);
|
||||
if (sslCert!=null)
|
||||
_request.setAttribute("javax.servlet.request.X509Certificate", sslCert.toString());
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ import org.eclipse.jetty.io.EndPoint;
|
||||
import org.eclipse.jetty.io.EofException;
|
||||
import org.eclipse.jetty.util.StringUtil;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -36,6 +37,8 @@ import org.eclipse.jetty.util.log.Log;
|
||||
*/
|
||||
public class Ajp13Generator extends AbstractGenerator
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(Ajp13Generator.class);
|
||||
|
||||
private static HashMap __headerHash = new HashMap();
|
||||
|
||||
static
|
||||
@ -214,7 +217,7 @@ public class Ajp13Generator extends AbstractGenerator
|
||||
|
||||
if (_last || _state == STATE_END)
|
||||
{
|
||||
Log.debug("Ignoring extra content {}", content);
|
||||
LOG.debug("Ignoring extra content {}", content);
|
||||
content.clear();
|
||||
return;
|
||||
}
|
||||
@ -627,7 +630,7 @@ public class Ajp13Generator extends AbstractGenerator
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
Log.ignore(e);
|
||||
LOG.ignore(e);
|
||||
throw (e instanceof EofException) ? e : new EofException(e);
|
||||
}
|
||||
|
||||
|
@ -27,12 +27,15 @@ import org.eclipse.jetty.io.EndPoint;
|
||||
import org.eclipse.jetty.io.EofException;
|
||||
import org.eclipse.jetty.io.View;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class Ajp13Parser implements Parser
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(Ajp13Parser.class);
|
||||
|
||||
private final static int STATE_START = -1;
|
||||
private final static int STATE_END = 0;
|
||||
private final static int STATE_AJP13CHUNK_START = 1;
|
||||
@ -205,7 +208,7 @@ public class Ajp13Parser implements Parser
|
||||
catch (IOException e)
|
||||
{
|
||||
// This is normal in AJP since the socket closes on timeout only
|
||||
Log.debug(e);
|
||||
LOG.debug(e);
|
||||
reset();
|
||||
throw (e instanceof EofException) ? e : new EofException(e);
|
||||
}
|
||||
@ -328,7 +331,7 @@ public class Ajp13Parser implements Parser
|
||||
default:
|
||||
// XXX Throw an Exception here?? Close
|
||||
// connection!
|
||||
Log.warn("AJP13 message type ({PING}: "+packetType+" ) not supported/recognized as an AJP request");
|
||||
LOG.warn("AJP13 message type ({PING}: "+packetType+" ) not supported/recognized as an AJP request");
|
||||
throw new IllegalStateException("PING is not implemented");
|
||||
}
|
||||
|
||||
@ -459,7 +462,7 @@ public class Ajp13Parser implements Parser
|
||||
|
||||
break;
|
||||
default:
|
||||
Log.warn("Unsupported Ajp13 Request Attribute {}", new Integer(attr_type));
|
||||
LOG.warn("Unsupported Ajp13 Request Attribute {}", new Integer(attr_type));
|
||||
break;
|
||||
}
|
||||
|
||||
@ -681,37 +684,37 @@ public class Ajp13Parser implements Parser
|
||||
|
||||
if(!Ajp13SocketConnector.__allowShutdown)
|
||||
{
|
||||
Log.warn("AJP13: Shutdown Request is Denied, allowShutdown is set to false!!!");
|
||||
LOG.warn("AJP13: Shutdown Request is Denied, allowShutdown is set to false!!!");
|
||||
return;
|
||||
}
|
||||
|
||||
if(Ajp13SocketConnector.__secretWord != null)
|
||||
{
|
||||
Log.warn("AJP13: Validating Secret Word");
|
||||
LOG.warn("AJP13: Validating Secret Word");
|
||||
try
|
||||
{
|
||||
String secretWord = Ajp13RequestPacket.getString(_buffer, _tok1).toString();
|
||||
|
||||
if(!Ajp13SocketConnector.__secretWord.equals(secretWord))
|
||||
{
|
||||
Log.warn("AJP13: Shutdown Request Denied, Invalid Sercret word!!!");
|
||||
LOG.warn("AJP13: Shutdown Request Denied, Invalid Sercret word!!!");
|
||||
throw new IllegalStateException("AJP13: Secret Word is Invalid: Peer has requested shutdown but, Secret Word did not match");
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.warn("AJP13: Secret Word is Required!!!");
|
||||
Log.debug(e);
|
||||
LOG.warn("AJP13: Secret Word is Required!!!");
|
||||
LOG.debug(e);
|
||||
throw new IllegalStateException("AJP13: Secret Word is Required: Peer has requested shutdown but, has not provided a Secret Word");
|
||||
}
|
||||
|
||||
|
||||
Log.warn("AJP13: Shutdown Request is Denied, allowShutdown is set to false!!!");
|
||||
LOG.warn("AJP13: Shutdown Request is Denied, allowShutdown is set to false!!!");
|
||||
return;
|
||||
}
|
||||
|
||||
Log.warn("AJP13: Peer Has Requested for Shutdown!!!");
|
||||
Log.warn("AJP13: Jetty 6 is shutting down !!!");
|
||||
LOG.warn("AJP13: Peer Has Requested for Shutdown!!!");
|
||||
LOG.warn("AJP13: Jetty 6 is shutting down !!!");
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
|
@ -21,6 +21,7 @@ import org.eclipse.jetty.io.EndPoint;
|
||||
import org.eclipse.jetty.server.Request;
|
||||
import org.eclipse.jetty.server.bio.SocketConnector;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -29,6 +30,8 @@ import org.eclipse.jetty.util.log.Log;
|
||||
*/
|
||||
public class Ajp13SocketConnector extends SocketConnector
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(Ajp13SocketConnector.class);
|
||||
|
||||
static String __secretWord = null;
|
||||
static boolean __allowShutdown = false;
|
||||
public Ajp13SocketConnector()
|
||||
@ -46,7 +49,7 @@ public class Ajp13SocketConnector extends SocketConnector
|
||||
protected void doStart() throws Exception
|
||||
{
|
||||
super.doStart();
|
||||
Log.info("AJP13 is not a secure protocol. Please protect port {}",Integer.toString(getLocalPort()));
|
||||
LOG.info("AJP13 is not a secure protocol. Please protect port {}",Integer.toString(getLocalPort()));
|
||||
}
|
||||
|
||||
|
||||
@ -90,34 +93,34 @@ public class Ajp13SocketConnector extends SocketConnector
|
||||
@Deprecated
|
||||
public void setHeaderBufferSize(int headerBufferSize)
|
||||
{
|
||||
Log.debug(Log.IGNORED);
|
||||
LOG.debug(Log.IGNORED);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
@Override
|
||||
public void setRequestBufferSize(int requestBufferSize)
|
||||
{
|
||||
Log.debug(Log.IGNORED);
|
||||
LOG.debug(Log.IGNORED);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
@Override
|
||||
public void setResponseBufferSize(int responseBufferSize)
|
||||
{
|
||||
Log.debug(Log.IGNORED);
|
||||
LOG.debug(Log.IGNORED);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public void setAllowShutdown(boolean allowShutdown)
|
||||
{
|
||||
Log.warn("AJP13: Shutdown Request is: " + allowShutdown);
|
||||
LOG.warn("AJP13: Shutdown Request is: " + allowShutdown);
|
||||
__allowShutdown = allowShutdown;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public void setSecretWord(String secretWord)
|
||||
{
|
||||
Log.warn("AJP13: Shutdown Request secret word is : " + secretWord);
|
||||
LOG.warn("AJP13: Shutdown Request secret word is : " + secretWord);
|
||||
__secretWord = secretWord;
|
||||
}
|
||||
|
||||
|
@ -32,6 +32,7 @@ import org.eclipse.jetty.server.handler.AbstractHandler;
|
||||
import org.eclipse.jetty.util.IO;
|
||||
import org.eclipse.jetty.util.TypeUtil;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
@ -42,6 +43,8 @@ import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class Ajp13ConnectionTest
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(Ajp13ConnectionTest.class);
|
||||
|
||||
private static Server _server;
|
||||
private static Ajp13SocketConnector _connector;
|
||||
private Socket _client;
|
||||
@ -305,7 +308,7 @@ public class Ajp13ConnectionTest
|
||||
}
|
||||
catch(SocketTimeoutException e)
|
||||
{
|
||||
Log.ignore(e);
|
||||
LOG.ignore(e);
|
||||
}
|
||||
return bout.toString("utf-8");
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ import javax.servlet.annotation.HandlesTypes;
|
||||
import org.eclipse.jetty.annotations.AnnotationParser.DiscoverableAnnotationHandler;
|
||||
import org.eclipse.jetty.plus.annotation.ContainerInitializer;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.util.resource.Resource;
|
||||
import org.eclipse.jetty.webapp.Configuration;
|
||||
import org.eclipse.jetty.webapp.AbstractConfiguration;
|
||||
@ -44,6 +45,7 @@ import org.eclipse.jetty.webapp.WebDescriptor;
|
||||
*/
|
||||
public class AnnotationConfiguration extends AbstractConfiguration
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(AnnotationConfiguration.class);
|
||||
public static final String CLASS_INHERITANCE_MAP = "org.eclipse.jetty.classInheritanceMap";
|
||||
|
||||
public void preConfigure(final WebAppContext context) throws Exception
|
||||
@ -59,14 +61,14 @@ public class AnnotationConfiguration extends AbstractConfiguration
|
||||
if (metadataComplete)
|
||||
{
|
||||
//Never scan any jars or classes for annotations if metadata is complete
|
||||
if (Log.isDebugEnabled()) Log.debug("Metadata-complete==true, not processing annotations for context "+context);
|
||||
if (LOG.isDebugEnabled()) LOG.debug("Metadata-complete==true, not processing annotations for context "+context);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Only scan jars and classes if metadata is not complete and the web app is version 3.0, or
|
||||
//a 2.5 version webapp that has specifically asked to discover annotations
|
||||
if (Log.isDebugEnabled()) Log.debug("parsing annotations");
|
||||
if (LOG.isDebugEnabled()) LOG.debug("parsing annotations");
|
||||
|
||||
AnnotationParser parser = createAnnotationParser();
|
||||
//Discoverable annotations - those that you have to look for without loading a class
|
||||
@ -79,7 +81,7 @@ public class AnnotationConfiguration extends AbstractConfiguration
|
||||
|
||||
if (context.getServletContext().getEffectiveMajorVersion() >= 3 || context.isConfigurationDiscovered())
|
||||
{
|
||||
if (Log.isDebugEnabled()) Log.debug("Scanning all classses for annotations: webxmlVersion="+context.getServletContext().getEffectiveMajorVersion()+" configurationDiscovered="+context.isConfigurationDiscovered());
|
||||
if (LOG.isDebugEnabled()) LOG.debug("Scanning all classses for annotations: webxmlVersion="+context.getServletContext().getEffectiveMajorVersion()+" configurationDiscovered="+context.isConfigurationDiscovered());
|
||||
parseContainerPath(context, parser);
|
||||
//email from Rajiv Mordani jsrs 315 7 April 2010
|
||||
// If there is a <others/> then the ordering should be
|
||||
@ -149,16 +151,16 @@ public class AnnotationConfiguration extends AbstractConfiguration
|
||||
{
|
||||
if (c.isAnnotation())
|
||||
{
|
||||
if (Log.isDebugEnabled()) Log.debug("Registering annotation handler for "+c.getName());
|
||||
if (LOG.isDebugEnabled()) LOG.debug("Registering annotation handler for "+c.getName());
|
||||
parser.registerAnnotationHandler(c.getName(), new ContainerInitializerAnnotationHandler(initializer, c));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
if (Log.isDebugEnabled()) Log.debug("No classes in HandlesTypes on initializer "+service.getClass());
|
||||
if (LOG.isDebugEnabled()) LOG.debug("No classes in HandlesTypes on initializer "+service.getClass());
|
||||
}
|
||||
else
|
||||
if (Log.isDebugEnabled()) Log.debug("No annotation on initializer "+service.getClass());
|
||||
if (LOG.isDebugEnabled()) LOG.debug("No annotation on initializer "+service.getClass());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -208,7 +210,7 @@ public class AnnotationConfiguration extends AbstractConfiguration
|
||||
throws Exception
|
||||
{
|
||||
//if no pattern for the container path is defined, then by default scan NOTHING
|
||||
Log.debug("Scanning container jars");
|
||||
LOG.debug("Scanning container jars");
|
||||
|
||||
//clear any previously discovered annotations
|
||||
clearAnnotationList(parser.getAnnotationHandlers());
|
||||
@ -305,7 +307,7 @@ public class AnnotationConfiguration extends AbstractConfiguration
|
||||
public void parseWebInfClasses (final WebAppContext context, final AnnotationParser parser)
|
||||
throws Exception
|
||||
{
|
||||
Log.debug("Scanning classes in WEB-INF/classes");
|
||||
LOG.debug("Scanning classes in WEB-INF/classes");
|
||||
if (context.getWebInf() != null)
|
||||
{
|
||||
Resource classesDir = context.getWebInf().addPath("classes/");
|
||||
|
@ -28,6 +28,7 @@ import java.util.jar.JarEntry;
|
||||
|
||||
import org.eclipse.jetty.util.Loader;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.util.resource.Resource;
|
||||
import org.eclipse.jetty.webapp.JarScanner;
|
||||
import org.objectweb.asm.AnnotationVisitor;
|
||||
@ -44,6 +45,8 @@ import org.objectweb.asm.commons.EmptyVisitor;
|
||||
*/
|
||||
public class AnnotationParser
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(AnnotationParser.class);
|
||||
|
||||
protected List<String> _parsedClassNames = new ArrayList<String>();
|
||||
protected Map<String, List<DiscoverableAnnotationHandler>> _annotationHandlers = new HashMap<String, List<DiscoverableAnnotationHandler>>();
|
||||
protected List<ClassHandler> _classHandlers = new ArrayList<ClassHandler>();
|
||||
@ -528,7 +531,7 @@ public class AnnotationParser
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.warn(Log.EXCEPTION,ex);
|
||||
LOG.warn(Log.EXCEPTION,ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -574,7 +577,7 @@ public class AnnotationParser
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.warn("Problem processing jar entry "+entry, e);
|
||||
LOG.warn("Problem processing jar entry "+entry, e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -619,7 +622,7 @@ public class AnnotationParser
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.warn("Problem processing jar entry "+entry, e);
|
||||
LOG.warn("Problem processing jar entry "+entry, e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,7 @@ import java.util.List;
|
||||
import org.eclipse.jetty.annotations.AnnotationParser.ClassHandler;
|
||||
import org.eclipse.jetty.util.MultiMap;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
|
||||
/**
|
||||
* ClassInheritanceHandler
|
||||
@ -26,6 +27,8 @@ import org.eclipse.jetty.util.log.Log;
|
||||
*/
|
||||
public class ClassInheritanceHandler implements ClassHandler
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(ClassInheritanceHandler.class);
|
||||
|
||||
|
||||
MultiMap _inheritanceMap = new MultiMap();
|
||||
|
||||
@ -47,7 +50,7 @@ public class ClassInheritanceHandler implements ClassHandler
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.warn(e);
|
||||
LOG.warn(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -26,11 +26,14 @@ import org.eclipse.jetty.annotations.AnnotationIntrospector.AbstractIntrospectab
|
||||
import org.eclipse.jetty.plus.annotation.Injection;
|
||||
import org.eclipse.jetty.plus.annotation.InjectionCollection;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.webapp.MetaData;
|
||||
import org.eclipse.jetty.webapp.WebAppContext;
|
||||
|
||||
public class ResourceAnnotationHandler extends AbstractIntrospectableAnnotationHandler
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(ResourceAnnotationHandler.class);
|
||||
|
||||
protected WebAppContext _context;
|
||||
|
||||
|
||||
@ -84,7 +87,7 @@ public class ResourceAnnotationHandler extends AbstractIntrospectableAnnotationH
|
||||
}
|
||||
catch (NamingException e)
|
||||
{
|
||||
Log.warn(e);
|
||||
LOG.warn(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -97,14 +100,14 @@ public class ResourceAnnotationHandler extends AbstractIntrospectableAnnotationH
|
||||
//JavaEE Spec 5.2.3: Field cannot be static
|
||||
if (Modifier.isStatic(field.getModifiers()))
|
||||
{
|
||||
Log.warn("Skipping Resource annotation on "+clazz.getName()+"."+field.getName()+": cannot be static");
|
||||
LOG.warn("Skipping Resource annotation on "+clazz.getName()+"."+field.getName()+": cannot be static");
|
||||
return;
|
||||
}
|
||||
|
||||
//JavaEE Spec 5.2.3: Field cannot be final
|
||||
if (Modifier.isFinal(field.getModifiers()))
|
||||
{
|
||||
Log.warn("Skipping Resource annotation on "+clazz.getName()+"."+field.getName()+": cannot be final");
|
||||
LOG.warn("Skipping Resource annotation on "+clazz.getName()+"."+field.getName()+": cannot be final");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -165,7 +168,7 @@ public class ResourceAnnotationHandler extends AbstractIntrospectableAnnotationH
|
||||
//Check there is a JNDI entry for this annotation
|
||||
if (bound)
|
||||
{
|
||||
Log.debug("Bound "+(mappedName==null?name:mappedName) + " as "+ name);
|
||||
LOG.debug("Bound "+(mappedName==null?name:mappedName) + " as "+ name);
|
||||
// Make the Injection for it if the binding succeeded
|
||||
injection = new Injection();
|
||||
injection.setTarget(clazz, field, type);
|
||||
@ -230,7 +233,7 @@ public class ResourceAnnotationHandler extends AbstractIntrospectableAnnotationH
|
||||
//JavaEE Spec 5.2.3: Method cannot be static
|
||||
if (Modifier.isStatic(method.getModifiers()))
|
||||
{
|
||||
Log.warn("Skipping Resource annotation on "+clazz.getName()+"."+method.getName()+": cannot be static");
|
||||
LOG.warn("Skipping Resource annotation on "+clazz.getName()+"."+method.getName()+": cannot be static");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -238,19 +241,19 @@ public class ResourceAnnotationHandler extends AbstractIntrospectableAnnotationH
|
||||
// only 1 parameter
|
||||
if (!method.getName().startsWith("set"))
|
||||
{
|
||||
Log.warn("Skipping Resource annotation on "+clazz.getName()+"."+method.getName()+": invalid java bean, does not start with 'set'");
|
||||
LOG.warn("Skipping Resource annotation on "+clazz.getName()+"."+method.getName()+": invalid java bean, does not start with 'set'");
|
||||
return;
|
||||
}
|
||||
|
||||
if (method.getParameterTypes().length != 1)
|
||||
{
|
||||
Log.warn("Skipping Resource annotation on "+clazz.getName()+"."+method.getName()+": invalid java bean, not single argument to method");
|
||||
LOG.warn("Skipping Resource annotation on "+clazz.getName()+"."+method.getName()+": invalid java bean, not single argument to method");
|
||||
return;
|
||||
}
|
||||
|
||||
if (Void.TYPE != method.getReturnType())
|
||||
{
|
||||
Log.warn("Skipping Resource annotation on "+clazz.getName()+"."+method.getName()+": invalid java bean, not void");
|
||||
LOG.warn("Skipping Resource annotation on "+clazz.getName()+"."+method.getName()+": invalid java bean, not void");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -320,7 +323,7 @@ public class ResourceAnnotationHandler extends AbstractIntrospectableAnnotationH
|
||||
|
||||
if (bound)
|
||||
{
|
||||
Log.debug("Bound "+(mappedName==null?name:mappedName) + " as "+ name);
|
||||
LOG.debug("Bound "+(mappedName==null?name:mappedName) + " as "+ name);
|
||||
// Make the Injection for it
|
||||
injection = new Injection();
|
||||
injection.setTarget(clazz, method,paramType,resourceType);
|
||||
|
@ -19,10 +19,13 @@ import javax.naming.NamingException;
|
||||
|
||||
import org.eclipse.jetty.annotations.AnnotationIntrospector.AbstractIntrospectableAnnotationHandler;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.webapp.WebAppContext;
|
||||
|
||||
public class ResourcesAnnotationHandler extends AbstractIntrospectableAnnotationHandler
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(ResourcesAnnotationHandler.class);
|
||||
|
||||
|
||||
protected WebAppContext _wac;
|
||||
|
||||
@ -40,7 +43,7 @@ public class ResourcesAnnotationHandler extends AbstractIntrospectableAnnotation
|
||||
Resource[] resArray = resources.value();
|
||||
if (resArray==null||resArray.length==0)
|
||||
{
|
||||
Log.warn ("Skipping empty or incorrect Resources annotation on "+clazz.getName());
|
||||
LOG.warn ("Skipping empty or incorrect Resources annotation on "+clazz.getName());
|
||||
return;
|
||||
}
|
||||
|
||||
@ -62,11 +65,11 @@ public class ResourcesAnnotationHandler extends AbstractIntrospectableAnnotation
|
||||
|
||||
if (!org.eclipse.jetty.plus.jndi.NamingEntryUtil.bindToENC(_wac, name, mappedName))
|
||||
if (!org.eclipse.jetty.plus.jndi.NamingEntryUtil.bindToENC(_wac.getServer(), name, mappedName))
|
||||
Log.warn("Skipping Resources(Resource) annotation on "+clazz.getName()+" for name "+name+": No resource bound at "+(mappedName==null?name:mappedName));
|
||||
LOG.warn("Skipping Resources(Resource) annotation on "+clazz.getName()+" for name "+name+": No resource bound at "+(mappedName==null?name:mappedName));
|
||||
}
|
||||
catch (NamingException e)
|
||||
{
|
||||
Log.warn(e);
|
||||
LOG.warn(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ import org.eclipse.jetty.annotations.AnnotationParser.Value;
|
||||
import org.eclipse.jetty.plus.annotation.RunAsCollection;
|
||||
import org.eclipse.jetty.servlet.ServletHolder;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.webapp.Descriptor;
|
||||
import org.eclipse.jetty.webapp.MetaData;
|
||||
import org.eclipse.jetty.webapp.WebAppContext;
|
||||
@ -29,6 +30,8 @@ import org.eclipse.jetty.webapp.WebAppContext;
|
||||
|
||||
public class RunAsAnnotationHandler extends AbstractIntrospectableAnnotationHandler
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(RunAsAnnotationHandler.class);
|
||||
|
||||
protected WebAppContext _context;
|
||||
|
||||
public RunAsAnnotationHandler (WebAppContext wac)
|
||||
@ -74,7 +77,7 @@ public class RunAsAnnotationHandler extends AbstractIntrospectableAnnotationHand
|
||||
}
|
||||
}
|
||||
else
|
||||
Log.warn("Bad value for @RunAs annotation on class "+clazz.getName());
|
||||
LOG.warn("Bad value for @RunAs annotation on class "+clazz.getName());
|
||||
}
|
||||
|
||||
}
|
||||
@ -82,13 +85,13 @@ public class RunAsAnnotationHandler extends AbstractIntrospectableAnnotationHand
|
||||
public void handleField(String className, String fieldName, int access, String fieldType, String signature, Object value, String annotation,
|
||||
List<Value> values)
|
||||
{
|
||||
Log.warn ("@RunAs annotation not applicable for fields: "+className+"."+fieldName);
|
||||
LOG.warn ("@RunAs annotation not applicable for fields: "+className+"."+fieldName);
|
||||
}
|
||||
|
||||
public void handleMethod(String className, String methodName, int access, String params, String signature, String[] exceptions, String annotation,
|
||||
List<Value> values)
|
||||
{
|
||||
Log.warn("@RunAs annotation ignored on method: "+className+"."+methodName+" "+signature);
|
||||
LOG.warn("@RunAs annotation ignored on method: "+className+"."+methodName+" "+signature);
|
||||
}
|
||||
|
||||
private ServletHolder getServletHolderForClass (Class clazz)
|
||||
|
@ -30,6 +30,7 @@ import org.eclipse.jetty.servlet.ServletHolder;
|
||||
import org.eclipse.jetty.servlet.ServletMapping;
|
||||
import org.eclipse.jetty.util.LazyList;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.webapp.WebAppContext;
|
||||
|
||||
/**
|
||||
@ -51,6 +52,7 @@ import org.eclipse.jetty.webapp.WebAppContext;
|
||||
*/
|
||||
public class ServletSecurityAnnotationHandler extends AbstractIntrospectableAnnotationHandler
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(ServletSecurityAnnotationHandler.class);
|
||||
|
||||
private WebAppContext _context;
|
||||
|
||||
@ -67,7 +69,7 @@ public class ServletSecurityAnnotationHandler extends AbstractIntrospectableAnno
|
||||
{
|
||||
if (!(_context.getSecurityHandler() instanceof ConstraintAware))
|
||||
{
|
||||
Log.warn("SecurityHandler not ConstraintAware, skipping security annotation processing");
|
||||
LOG.warn("SecurityHandler not ConstraintAware, skipping security annotation processing");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -83,7 +85,7 @@ public class ServletSecurityAnnotationHandler extends AbstractIntrospectableAnno
|
||||
|
||||
if (constraintsExist(servletMappings, constraintMappings))
|
||||
{
|
||||
Log.warn("Constraints already defined for "+clazz.getName()+", skipping ServletSecurity annotation");
|
||||
LOG.warn("Constraints already defined for "+clazz.getName()+", skipping ServletSecurity annotation");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -25,6 +25,7 @@ import org.eclipse.jetty.servlet.FilterHolder;
|
||||
import org.eclipse.jetty.servlet.FilterMapping;
|
||||
import org.eclipse.jetty.servlet.Holder;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.webapp.DiscoveredAnnotation;
|
||||
import org.eclipse.jetty.webapp.MetaData;
|
||||
import org.eclipse.jetty.webapp.WebAppContext;
|
||||
@ -37,6 +38,7 @@ import org.eclipse.jetty.webapp.Origin;
|
||||
*/
|
||||
public class WebFilterAnnotation extends DiscoveredAnnotation
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(WebFilterAnnotation.class);
|
||||
|
||||
/**
|
||||
* @param context
|
||||
@ -57,7 +59,7 @@ public class WebFilterAnnotation extends DiscoveredAnnotation
|
||||
Class clazz = getTargetClass();
|
||||
if (clazz == null)
|
||||
{
|
||||
Log.warn(_className+" cannot be loaded");
|
||||
LOG.warn(_className+" cannot be loaded");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -65,7 +67,7 @@ public class WebFilterAnnotation extends DiscoveredAnnotation
|
||||
//Servlet Spec 8.1.2
|
||||
if (!Filter.class.isAssignableFrom(clazz))
|
||||
{
|
||||
Log.warn(clazz.getName()+" is not assignable from javax.servlet.Filter");
|
||||
LOG.warn(clazz.getName()+" is not assignable from javax.servlet.Filter");
|
||||
return;
|
||||
}
|
||||
MetaData metaData = _context.getMetaData();
|
||||
@ -74,7 +76,7 @@ public class WebFilterAnnotation extends DiscoveredAnnotation
|
||||
|
||||
if (filterAnnotation.value().length > 0 && filterAnnotation.urlPatterns().length > 0)
|
||||
{
|
||||
Log.warn(clazz.getName()+" defines both @WebFilter.value and @WebFilter.urlPatterns");
|
||||
LOG.warn(clazz.getName()+" defines both @WebFilter.value and @WebFilter.urlPatterns");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,7 @@ import java.util.List;
|
||||
import org.eclipse.jetty.annotations.AnnotationParser.DiscoverableAnnotationHandler;
|
||||
import org.eclipse.jetty.annotations.AnnotationParser.Value;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.webapp.DiscoveredAnnotation;
|
||||
import org.eclipse.jetty.webapp.WebAppContext;
|
||||
|
||||
@ -28,6 +29,8 @@ import org.eclipse.jetty.webapp.WebAppContext;
|
||||
*/
|
||||
public class WebFilterAnnotationHandler extends AbstractDiscoverableAnnotationHandler
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(WebFilterAnnotationHandler.class);
|
||||
|
||||
public WebFilterAnnotationHandler (WebAppContext context)
|
||||
{
|
||||
super(context);
|
||||
@ -43,13 +46,13 @@ public class WebFilterAnnotationHandler extends AbstractDiscoverableAnnotationHa
|
||||
public void handleField(String className, String fieldName, int access, String fieldType, String signature, Object value, String annotation,
|
||||
List<Value> values)
|
||||
{
|
||||
Log.warn ("@WebFilter not applicable for fields: "+className+"."+fieldName);
|
||||
LOG.warn ("@WebFilter not applicable for fields: "+className+"."+fieldName);
|
||||
}
|
||||
|
||||
public void handleMethod(String className, String methodName, int access, String params, String signature, String[] exceptions, String annotation,
|
||||
List<Value> values)
|
||||
{
|
||||
Log.warn ("@WebFilter not applicable for methods: "+className+"."+methodName+" "+signature);
|
||||
LOG.warn ("@WebFilter not applicable for methods: "+className+"."+methodName+" "+signature);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ import javax.servlet.http.HttpSessionAttributeListener;
|
||||
import javax.servlet.http.HttpSessionListener;
|
||||
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.webapp.DiscoveredAnnotation;
|
||||
import org.eclipse.jetty.webapp.MetaData;
|
||||
import org.eclipse.jetty.webapp.WebAppContext;
|
||||
@ -33,6 +34,7 @@ import org.eclipse.jetty.webapp.Origin;
|
||||
*/
|
||||
public class WebListenerAnnotation extends DiscoveredAnnotation
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(WebListenerAnnotation.class);
|
||||
|
||||
/**
|
||||
* @param context
|
||||
@ -54,7 +56,7 @@ public class WebListenerAnnotation extends DiscoveredAnnotation
|
||||
|
||||
if (clazz == null)
|
||||
{
|
||||
Log.warn(_className+" cannot be loaded");
|
||||
LOG.warn(_className+" cannot be loaded");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -73,11 +75,11 @@ public class WebListenerAnnotation extends DiscoveredAnnotation
|
||||
_context.addEventListener(listener);
|
||||
}
|
||||
else
|
||||
Log.warn(clazz.getName()+" does not implement one of the servlet listener interfaces");
|
||||
LOG.warn(clazz.getName()+" does not implement one of the servlet listener interfaces");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.warn(e);
|
||||
LOG.warn(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,10 +16,13 @@ import java.util.List;
|
||||
|
||||
import org.eclipse.jetty.annotations.AnnotationParser.Value;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.webapp.WebAppContext;
|
||||
|
||||
public class WebListenerAnnotationHandler extends AbstractDiscoverableAnnotationHandler
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(WebListenerAnnotationHandler.class);
|
||||
|
||||
public WebListenerAnnotationHandler (WebAppContext context)
|
||||
{
|
||||
super(context);
|
||||
@ -38,13 +41,13 @@ public class WebListenerAnnotationHandler extends AbstractDiscoverableAnnotation
|
||||
public void handleField(String className, String fieldName, int access, String fieldType, String signature, Object value, String annotation,
|
||||
List<Value> values)
|
||||
{
|
||||
Log.warn ("@WebListener is not applicable to fields: "+className+"."+fieldName);
|
||||
LOG.warn ("@WebListener is not applicable to fields: "+className+"."+fieldName);
|
||||
}
|
||||
|
||||
public void handleMethod(String className, String methodName, int access, String params, String signature, String[] exceptions, String annotation,
|
||||
List<Value> values)
|
||||
{
|
||||
Log.warn ("@WebListener is not applicable to methods: "+className+"."+methodName+" "+signature);
|
||||
LOG.warn ("@WebListener is not applicable to methods: "+className+"."+methodName+" "+signature);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ import org.eclipse.jetty.servlet.ServletHolder;
|
||||
import org.eclipse.jetty.servlet.ServletMapping;
|
||||
import org.eclipse.jetty.util.LazyList;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.webapp.DiscoveredAnnotation;
|
||||
import org.eclipse.jetty.webapp.MetaData;
|
||||
import org.eclipse.jetty.webapp.WebAppContext;
|
||||
@ -36,6 +37,7 @@ import org.eclipse.jetty.webapp.Origin;
|
||||
*/
|
||||
public class WebServletAnnotation extends DiscoveredAnnotation
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(WebServletAnnotation.class);
|
||||
|
||||
public WebServletAnnotation (WebAppContext context, String className)
|
||||
{
|
||||
@ -52,14 +54,14 @@ public class WebServletAnnotation extends DiscoveredAnnotation
|
||||
|
||||
if (clazz == null)
|
||||
{
|
||||
Log.warn(_className+" cannot be loaded");
|
||||
LOG.warn(_className+" cannot be loaded");
|
||||
return;
|
||||
}
|
||||
|
||||
//Servlet Spec 8.1.1
|
||||
if (!HttpServlet.class.isAssignableFrom(clazz))
|
||||
{
|
||||
Log.warn(clazz.getName()+" is not assignable from javax.servlet.http.HttpServlet");
|
||||
LOG.warn(clazz.getName()+" is not assignable from javax.servlet.http.HttpServlet");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -67,7 +69,7 @@ public class WebServletAnnotation extends DiscoveredAnnotation
|
||||
|
||||
if (annotation.urlPatterns().length > 0 && annotation.value().length > 0)
|
||||
{
|
||||
Log.warn(clazz.getName()+ " defines both @WebServlet.value and @WebServlet.urlPatterns");
|
||||
LOG.warn(clazz.getName()+ " defines both @WebServlet.value and @WebServlet.urlPatterns");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -77,7 +79,7 @@ public class WebServletAnnotation extends DiscoveredAnnotation
|
||||
|
||||
if (urlPatterns.length == 0)
|
||||
{
|
||||
Log.warn(clazz.getName()+ " defines neither @WebServlet.value nor @WebServlet.urlPatterns");
|
||||
LOG.warn(clazz.getName()+ " defines neither @WebServlet.value nor @WebServlet.urlPatterns");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,7 @@ import java.util.List;
|
||||
import org.eclipse.jetty.annotations.AnnotationParser.DiscoverableAnnotationHandler;
|
||||
import org.eclipse.jetty.annotations.AnnotationParser.Value;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.webapp.DiscoveredAnnotation;
|
||||
import org.eclipse.jetty.webapp.WebAppContext;
|
||||
|
||||
@ -29,6 +30,7 @@ import org.eclipse.jetty.webapp.WebAppContext;
|
||||
*/
|
||||
public class WebServletAnnotationHandler extends AbstractDiscoverableAnnotationHandler
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(WebServletAnnotationHandler.class);
|
||||
|
||||
public WebServletAnnotationHandler (WebAppContext context)
|
||||
{
|
||||
@ -55,12 +57,12 @@ public class WebServletAnnotationHandler extends AbstractDiscoverableAnnotationH
|
||||
public void handleField(String className, String fieldName, int access, String fieldType, String signature, Object value, String annotation,
|
||||
List<Value> values)
|
||||
{
|
||||
Log.warn ("@WebServlet annotation not supported for fields");
|
||||
LOG.warn ("@WebServlet annotation not supported for fields");
|
||||
}
|
||||
|
||||
public void handleMethod(String className, String methodName, int access, String params, String signature, String[] exceptions, String annotation,
|
||||
List<Value> values)
|
||||
{
|
||||
Log.warn ("@WebServlet annotation not supported for methods");
|
||||
LOG.warn ("@WebServlet annotation not supported for methods");
|
||||
}
|
||||
}
|
||||
|
@ -18,10 +18,10 @@ import java.io.InputStream;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.Enumeration;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
import javax.net.ssl.SSLContext;
|
||||
|
||||
import org.eclipse.jetty.client.security.Authentication;
|
||||
@ -33,11 +33,9 @@ import org.eclipse.jetty.http.ssl.SslContextFactory;
|
||||
import org.eclipse.jetty.io.Buffers.Type;
|
||||
import org.eclipse.jetty.util.Attributes;
|
||||
import org.eclipse.jetty.util.AttributesMap;
|
||||
import org.eclipse.jetty.util.TypeUtil;
|
||||
import org.eclipse.jetty.util.component.AggregateLifeCycle;
|
||||
import org.eclipse.jetty.util.component.Dumpable;
|
||||
import org.eclipse.jetty.util.component.LifeCycle;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.thread.QueuedThreadPool;
|
||||
import org.eclipse.jetty.util.thread.ThreadPool;
|
||||
import org.eclipse.jetty.util.thread.Timeout;
|
||||
|
@ -42,6 +42,7 @@ import org.eclipse.jetty.io.nio.SslSelectChannelEndPoint;
|
||||
import org.eclipse.jetty.util.component.AggregateLifeCycle;
|
||||
import org.eclipse.jetty.util.component.Dumpable;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.util.thread.Timeout;
|
||||
|
||||
/**
|
||||
@ -50,6 +51,8 @@ import org.eclipse.jetty.util.thread.Timeout;
|
||||
*/
|
||||
public class HttpConnection extends AbstractConnection implements Dumpable
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(HttpConnection.class);
|
||||
|
||||
private HttpDestination _destination;
|
||||
private HttpGenerator _generator;
|
||||
private HttpParser _parser;
|
||||
@ -70,7 +73,7 @@ public class HttpConnection extends AbstractConnection implements Dumpable
|
||||
HttpConnection(Buffers requestBuffers, Buffers responseBuffers, EndPoint endp)
|
||||
{
|
||||
super(endp);
|
||||
|
||||
|
||||
_generator = new HttpGenerator(requestBuffers,endp);
|
||||
_parser = new HttpParser(responseBuffers,endp,new Handler());
|
||||
}
|
||||
@ -195,7 +198,7 @@ public class HttpConnection extends AbstractConnection implements Dumpable
|
||||
_parser.skipCRLF();
|
||||
if (_parser.isMoreInBuffer())
|
||||
{
|
||||
Log.warn("Unexpected data received but no request sent");
|
||||
LOG.warn("Unexpected data received but no request sent");
|
||||
close();
|
||||
}
|
||||
}
|
||||
@ -292,7 +295,7 @@ public class HttpConnection extends AbstractConnection implements Dumpable
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
Log.debug("Failure on " + _exchange, e);
|
||||
LOG.debug("Failure on " + _exchange, e);
|
||||
|
||||
if (e instanceof ThreadDeath)
|
||||
throw (ThreadDeath)e;
|
||||
@ -571,14 +574,24 @@ public class HttpConnection extends AbstractConnection implements Dumpable
|
||||
@Override
|
||||
public void startResponse(Buffer version, int status, Buffer reason) throws IOException
|
||||
{
|
||||
|
||||
HttpExchange exchange = _exchange;
|
||||
if (exchange!=null)
|
||||
{
|
||||
// handle special case for CONNECT 200 responses
|
||||
if (status==HttpStatus.OK_200 && HttpMethods.CONNECT.equalsIgnoreCase(exchange.getMethod()))
|
||||
_parser.setHeadResponse(true);
|
||||
|
||||
switch(status)
|
||||
{
|
||||
case HttpStatus.CONTINUE_100:
|
||||
case HttpStatus.PROCESSING_102:
|
||||
// TODO check if appropriate expect was sent in the request.
|
||||
exchange.setEventListener(new NonFinalResponseListener(exchange));
|
||||
break;
|
||||
|
||||
case HttpStatus.OK_200:
|
||||
// handle special case for CONNECT 200 responses
|
||||
if (HttpMethods.CONNECT.equalsIgnoreCase(exchange.getMethod()))
|
||||
_parser.setHeadResponse(true);
|
||||
break;
|
||||
}
|
||||
|
||||
_http11 = HttpVersions.HTTP_1_1_BUFFER.equals(version);
|
||||
_status=status;
|
||||
exchange.getEventListener().onResponseStatus(version,status,reason);
|
||||
@ -706,7 +719,7 @@ public class HttpConnection extends AbstractConnection implements Dumpable
|
||||
}
|
||||
catch (IOException x)
|
||||
{
|
||||
Log.ignore(x);
|
||||
LOG.ignore(x);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -734,8 +747,10 @@ public class HttpConnection extends AbstractConnection implements Dumpable
|
||||
}
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
private class ConnectionIdleTask extends Timeout.Task
|
||||
{
|
||||
/* ------------------------------------------------------------ */
|
||||
@Override
|
||||
public void expired()
|
||||
{
|
||||
@ -746,4 +761,87 @@ public class HttpConnection extends AbstractConnection implements Dumpable
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
private class NonFinalResponseListener implements HttpEventListener
|
||||
{
|
||||
final HttpExchange _exchange;
|
||||
final HttpEventListener _next;
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public NonFinalResponseListener(HttpExchange exchange)
|
||||
{
|
||||
_exchange=exchange;
|
||||
_next=exchange.getEventListener();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public void onRequestCommitted() throws IOException
|
||||
{
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public void onRequestComplete() throws IOException
|
||||
{
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public void onResponseStatus(Buffer version, int status, Buffer reason) throws IOException
|
||||
{
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public void onResponseHeader(Buffer name, Buffer value) throws IOException
|
||||
{
|
||||
_next.onResponseHeader(name,value);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public void onResponseHeaderComplete() throws IOException
|
||||
{
|
||||
_next.onResponseHeaderComplete();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public void onResponseContent(Buffer content) throws IOException
|
||||
{
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public void onResponseComplete() throws IOException
|
||||
{
|
||||
_exchange.setEventListener(_next);
|
||||
_exchange.setStatus(HttpExchange.STATUS_WAITING_FOR_RESPONSE);
|
||||
_parser.reset();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public void onConnectionFailed(Throwable ex)
|
||||
{
|
||||
_exchange.setEventListener(_next);
|
||||
_next.onConnectionFailed(ex);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public void onException(Throwable ex)
|
||||
{
|
||||
_exchange.setEventListener(_next);
|
||||
_next.onException(ex);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public void onExpire()
|
||||
{
|
||||
_exchange.setEventListener(_next);
|
||||
_next.onExpire();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public void onRetry()
|
||||
{
|
||||
_exchange.setEventListener(_next);
|
||||
_next.onRetry();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -38,12 +38,15 @@ import org.eclipse.jetty.io.EndPoint;
|
||||
import org.eclipse.jetty.util.component.AggregateLifeCycle;
|
||||
import org.eclipse.jetty.util.component.Dumpable;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
|
||||
/**
|
||||
* @version $Revision: 879 $ $Date: 2009-09-11 16:13:28 +0200 (Fri, 11 Sep 2009) $
|
||||
*/
|
||||
public class HttpDestination implements Dumpable
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(HttpDestination.class);
|
||||
|
||||
private final List<HttpExchange> _queue = new LinkedList<HttpExchange>();
|
||||
private final List<HttpConnection> _connections = new LinkedList<HttpConnection>();
|
||||
private final BlockingQueue<Object> _newQueue = new ArrayBlockingQueue<Object>(10, true);
|
||||
@ -197,7 +200,7 @@ public class HttpDestination implements Dumpable
|
||||
}
|
||||
catch (InterruptedException e)
|
||||
{
|
||||
Log.ignore(e);
|
||||
LOG.ignore(e);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -210,7 +213,7 @@ public class HttpDestination implements Dumpable
|
||||
}
|
||||
catch (InterruptedException e)
|
||||
{
|
||||
Log.ignore(e);
|
||||
LOG.ignore(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -266,7 +269,7 @@ public class HttpDestination implements Dumpable
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.debug(e);
|
||||
LOG.debug(e);
|
||||
onConnectionFailed(e);
|
||||
}
|
||||
}
|
||||
@ -308,7 +311,7 @@ public class HttpDestination implements Dumpable
|
||||
}
|
||||
catch (InterruptedException e)
|
||||
{
|
||||
Log.ignore(e);
|
||||
LOG.ignore(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -373,7 +376,7 @@ public class HttpDestination implements Dumpable
|
||||
}
|
||||
catch (InterruptedException e)
|
||||
{
|
||||
Log.ignore(e);
|
||||
LOG.ignore(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -391,7 +394,7 @@ public class HttpDestination implements Dumpable
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
Log.ignore(e);
|
||||
LOG.ignore(e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -438,7 +441,7 @@ public class HttpDestination implements Dumpable
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
Log.ignore(e);
|
||||
LOG.ignore(e);
|
||||
}
|
||||
|
||||
boolean startConnection = false;
|
||||
@ -675,7 +678,7 @@ public class HttpDestination implements Dumpable
|
||||
setMethod(HttpMethods.CONNECT);
|
||||
setVersion(exchange.getVersion());
|
||||
String serverHostAndPort = serverAddress.toString();
|
||||
setURI(serverHostAndPort);
|
||||
setRequestURI(serverHostAndPort);
|
||||
addRequestHeader(HttpHeaders.HOST, serverHostAndPort);
|
||||
addRequestHeader(HttpHeaders.PROXY_CONNECTION, "keep-alive");
|
||||
addRequestHeader(HttpHeaders.USER_AGENT, "Jetty-Client");
|
||||
|
@ -15,6 +15,7 @@ package org.eclipse.jetty.client;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URI;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import org.eclipse.jetty.client.security.SecurityListener;
|
||||
@ -30,6 +31,7 @@ import org.eclipse.jetty.io.ByteArrayBuffer;
|
||||
import org.eclipse.jetty.io.Connection;
|
||||
import org.eclipse.jetty.io.EndPoint;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.util.thread.Timeout;
|
||||
|
||||
/**
|
||||
@ -37,8 +39,8 @@ import org.eclipse.jetty.util.thread.Timeout;
|
||||
*
|
||||
* This object encapsulates:
|
||||
* <ul>
|
||||
* <li>The HTTP server address, see {@link #setAddress(Address)} or {@link #setURL(String)})
|
||||
* <li>The HTTP request method, URI and HTTP version (see {@link #setMethod(String)}, {@link #setURI(String)}, and {@link #setVersion(int)}
|
||||
* <li>The HTTP server address, see {@link #setAddress(Address)}, or {@link #setURI(URI)}, or {@link #setURL(String)})
|
||||
* <li>The HTTP request method, URI and HTTP version (see {@link #setMethod(String)}, {@link #setRequestURI(String)}, and {@link #setVersion(int)})
|
||||
* <li>The request headers (see {@link #addRequestHeader(String, String)} or {@link #setRequestHeader(String, String)})
|
||||
* <li>The request content (see {@link #setRequestContent(Buffer)} or {@link #setRequestContentSource(InputStream)})
|
||||
* <li>The status of the exchange (see {@link #getStatus()})
|
||||
@ -66,6 +68,8 @@ import org.eclipse.jetty.util.thread.Timeout;
|
||||
*/
|
||||
public class HttpExchange
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(HttpExchange.class);
|
||||
|
||||
public static final int STATUS_START = 0;
|
||||
public static final int STATUS_WAITING_FOR_CONNECTION = 1;
|
||||
public static final int STATUS_WAITING_FOR_COMMIT = 2;
|
||||
@ -302,6 +306,7 @@ public class HttpExchange
|
||||
{
|
||||
case STATUS_START:
|
||||
case STATUS_EXCEPTED:
|
||||
case STATUS_WAITING_FOR_RESPONSE:
|
||||
set=_status.compareAndSet(oldStatus,newStatus);
|
||||
break;
|
||||
case STATUS_CANCELLING:
|
||||
@ -344,11 +349,11 @@ public class HttpExchange
|
||||
}
|
||||
|
||||
if (!set)
|
||||
throw new IllegalStateException(oldStatus + " => " + newStatus);
|
||||
throw new IllegalStateException(toState(oldStatus) + " => " + toState(newStatus));
|
||||
}
|
||||
catch (IOException x)
|
||||
{
|
||||
Log.warn(x);
|
||||
LOG.warn(x);
|
||||
}
|
||||
}
|
||||
|
||||
@ -390,33 +395,11 @@ public class HttpExchange
|
||||
}
|
||||
|
||||
/**
|
||||
* @param url Including protocol, host and port
|
||||
* @param url an absolute URL (for example 'http://localhost/foo/bar?a=1')
|
||||
*/
|
||||
public void setURL(String url)
|
||||
{
|
||||
HttpURI uri = new HttpURI(url);
|
||||
String scheme = uri.getScheme();
|
||||
if (scheme != null)
|
||||
{
|
||||
if (HttpSchemes.HTTP.equalsIgnoreCase(scheme))
|
||||
setScheme(HttpSchemes.HTTP_BUFFER);
|
||||
else if (HttpSchemes.HTTPS.equalsIgnoreCase(scheme))
|
||||
setScheme(HttpSchemes.HTTPS_BUFFER);
|
||||
else
|
||||
setScheme(new ByteArrayBuffer(scheme));
|
||||
}
|
||||
|
||||
int port = uri.getPort();
|
||||
if (port <= 0)
|
||||
port = "https".equalsIgnoreCase(scheme)?443:80;
|
||||
|
||||
setAddress(new Address(uri.getHost(),port));
|
||||
|
||||
String completePath = uri.getCompletePath();
|
||||
if (completePath == null)
|
||||
completePath = "/";
|
||||
|
||||
setURI(completePath);
|
||||
setURI(URI.create(url));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -455,6 +438,22 @@ public class HttpExchange
|
||||
{
|
||||
_scheme = scheme;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param scheme the scheme of the URL (for example 'http')
|
||||
*/
|
||||
public void setScheme(String scheme)
|
||||
{
|
||||
if (scheme != null)
|
||||
{
|
||||
if (HttpSchemes.HTTP.equalsIgnoreCase(scheme))
|
||||
setScheme(HttpSchemes.HTTP_BUFFER);
|
||||
else if (HttpSchemes.HTTPS.equalsIgnoreCase(scheme))
|
||||
setScheme(HttpSchemes.HTTPS_BUFFER);
|
||||
else
|
||||
setScheme(new ByteArrayBuffer(scheme));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the scheme of the URL
|
||||
@ -510,20 +509,81 @@ public class HttpExchange
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the path of the URL
|
||||
* @return request URI
|
||||
* @see #getRequestURI()
|
||||
* @deprecated
|
||||
*/
|
||||
@Deprecated
|
||||
public String getURI()
|
||||
{
|
||||
return getRequestURI();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return request URI
|
||||
*/
|
||||
public String getRequestURI()
|
||||
{
|
||||
return _uri;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param uri the path of the URL (for example '/foo/bar?a=1')
|
||||
* Set the request URI
|
||||
*
|
||||
* @param uri new request URI
|
||||
* @see #setRequestURI(String)
|
||||
* @deprecated
|
||||
*/
|
||||
@Deprecated
|
||||
public void setURI(String uri)
|
||||
{
|
||||
setRequestURI(uri);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the request URI
|
||||
*
|
||||
* Per RFC 2616 sec5, Request-URI = "*" | absoluteURI | abs_path | authority<br/>
|
||||
* where:<br/><br/>
|
||||
* "*" - request applies to server itself<br/>
|
||||
* absoluteURI - required for proxy requests, e.g. http://localhost:8080/context<br/>
|
||||
* (this form is generated automatically by HttpClient)<br/>
|
||||
* abs_path - used for most methods, e.g. /context<br/>
|
||||
* authority - used for CONNECT method only, e.g. localhost:8080<br/>
|
||||
* <br/>
|
||||
* For complete definition of URI components, see RFC 2396 sec3.<br/>
|
||||
*
|
||||
* @param uri new request URI
|
||||
*/
|
||||
public void setRequestURI(String uri)
|
||||
{
|
||||
_uri = uri;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @param uri an absolute URI (for example 'http://localhost/foo/bar?a=1')
|
||||
*/
|
||||
public void setURI(URI uri)
|
||||
{
|
||||
if (!uri.isAbsolute())
|
||||
throw new IllegalArgumentException("!Absolute URI: "+uri);
|
||||
|
||||
if (uri.isOpaque())
|
||||
throw new IllegalArgumentException("Opaque URI: "+uri);
|
||||
|
||||
String scheme = uri.getScheme();
|
||||
int port = uri.getPort();
|
||||
if (port <= 0)
|
||||
port = "https".equalsIgnoreCase(scheme)?443:80;
|
||||
|
||||
setScheme(scheme);
|
||||
setAddress(new Address(uri.getHost(),port));
|
||||
|
||||
HttpURI httpUri = new HttpURI(uri);
|
||||
String completePath = httpUri.getCompletePath();
|
||||
setRequestURI(completePath==null ? "/" : completePath);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the specified request header
|
||||
@ -693,7 +753,7 @@ public class HttpExchange
|
||||
}
|
||||
catch (IOException x)
|
||||
{
|
||||
Log.debug(x);
|
||||
LOG.debug(x);
|
||||
}
|
||||
finally
|
||||
{
|
||||
@ -726,11 +786,10 @@ public class HttpExchange
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
public static String toState(int s)
|
||||
{
|
||||
String state;
|
||||
switch(getStatus())
|
||||
switch(s)
|
||||
{
|
||||
case STATUS_START: state="START"; break;
|
||||
case STATUS_WAITING_FOR_CONNECTION: state="CONNECTING"; break;
|
||||
@ -746,6 +805,13 @@ public class HttpExchange
|
||||
case STATUS_CANCELLED: state="CANCELLED"; break;
|
||||
default: state="UNKNOWN";
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
String state=toState(getStatus());
|
||||
long now=System.currentTimeMillis();
|
||||
long forMs = now -_lastStateChange;
|
||||
String s= String.format("%s@%x=%s//%s%s#%s(%dms)",getClass().getSimpleName(),hashCode(),_method,_address,_uri,state,forMs);
|
||||
@ -838,7 +904,7 @@ public class HttpExchange
|
||||
*/
|
||||
protected void onConnectionFailed(Throwable x)
|
||||
{
|
||||
Log.warn("CONNECTION FAILED " + this,x);
|
||||
LOG.warn("CONNECTION FAILED " + this,x);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -848,7 +914,7 @@ public class HttpExchange
|
||||
*/
|
||||
protected void onException(Throwable x)
|
||||
{
|
||||
Log.warn("EXCEPTION " + this,x);
|
||||
LOG.warn("EXCEPTION " + this,x);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -857,7 +923,7 @@ public class HttpExchange
|
||||
*/
|
||||
protected void onExpire()
|
||||
{
|
||||
Log.warn("EXPIRED " + this);
|
||||
LOG.warn("EXPIRED " + this);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1042,7 +1108,7 @@ public class HttpExchange
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
Log.debug(e);
|
||||
LOG.debug(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -112,7 +112,7 @@ public class RedirectListener extends HttpEventListenerWrapper
|
||||
if (_location.indexOf("://")>0)
|
||||
_exchange.setURL(_location);
|
||||
else
|
||||
_exchange.setURI(_location);
|
||||
_exchange.setRequestURI(_location);
|
||||
|
||||
// destination may have changed
|
||||
HttpDestination destination=_destination.getHttpClient().getDestination(_exchange.getAddress(),HttpSchemes.HTTPS.equals(String.valueOf(_exchange.getScheme())));
|
||||
|
@ -38,10 +38,13 @@ import org.eclipse.jetty.io.nio.SelectorManager;
|
||||
import org.eclipse.jetty.io.nio.SslSelectChannelEndPoint;
|
||||
import org.eclipse.jetty.util.component.AbstractLifeCycle;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.util.thread.Timeout;
|
||||
|
||||
class SelectConnector extends AbstractLifeCycle implements HttpClient.Connector, Runnable
|
||||
class SelectConnector extends AbstractLifeCycle implements HttpClient.Connector
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(SelectConnector.class);
|
||||
|
||||
private final HttpClient _httpClient;
|
||||
private final Manager _selectorManager=new Manager();
|
||||
private final Map<SocketChannel, Timeout.Task> _connectingChannels = new ConcurrentHashMap<SocketChannel, Timeout.Task>();
|
||||
@ -62,7 +65,6 @@ class SelectConnector extends AbstractLifeCycle implements HttpClient.Connector,
|
||||
{
|
||||
super.doStart();
|
||||
|
||||
_selectorManager.start();
|
||||
|
||||
final boolean direct=_httpClient.getUseDirectBuffers();
|
||||
|
||||
@ -73,7 +75,7 @@ class SelectConnector extends AbstractLifeCycle implements HttpClient.Connector,
|
||||
direct?Type.DIRECT:Type.INDIRECT,ssl_session.getApplicationBufferSize(),
|
||||
direct?Type.DIRECT:Type.INDIRECT,1024);
|
||||
|
||||
_httpClient._threadPool.dispatch(this);
|
||||
_selectorManager.start();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
@ -114,25 +116,6 @@ class SelectConnector extends AbstractLifeCycle implements HttpClient.Connector,
|
||||
{
|
||||
destination.onConnectionFailed(ex);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public void run()
|
||||
{
|
||||
while (_httpClient.isRunning())
|
||||
{
|
||||
try
|
||||
{
|
||||
_selectorManager.doSelect(0);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.warn(e.toString());
|
||||
Log.debug(e);
|
||||
Thread.yield();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
@ -175,7 +158,7 @@ class SelectConnector extends AbstractLifeCycle implements HttpClient.Connector,
|
||||
Timeout.Task connectTimeout = _connectingChannels.remove(channel);
|
||||
if (connectTimeout != null)
|
||||
connectTimeout.cancel();
|
||||
Log.debug("Channels with connection pending: {}", _connectingChannels.size());
|
||||
LOG.debug("Channels with connection pending: {}", _connectingChannels.size());
|
||||
|
||||
// key should have destination at this point (will be replaced by endpoint after this call)
|
||||
HttpDestination dest=(HttpDestination)key.attachment();
|
||||
@ -261,7 +244,7 @@ class SelectConnector extends AbstractLifeCycle implements HttpClient.Connector,
|
||||
{
|
||||
if (channel.isConnectionPending())
|
||||
{
|
||||
Log.debug("Channel {} timed out while connecting, closing it", channel);
|
||||
LOG.debug("Channel {} timed out while connecting, closing it", channel);
|
||||
try
|
||||
{
|
||||
// This will unregister the channel from the selector
|
||||
@ -269,7 +252,7 @@ class SelectConnector extends AbstractLifeCycle implements HttpClient.Connector,
|
||||
}
|
||||
catch (IOException x)
|
||||
{
|
||||
Log.ignore(x);
|
||||
LOG.ignore(x);
|
||||
}
|
||||
destination.onConnectionFailed(new SocketTimeoutException());
|
||||
}
|
||||
|
@ -24,9 +24,12 @@ import org.eclipse.jetty.io.EndPoint;
|
||||
import org.eclipse.jetty.io.bio.SocketEndPoint;
|
||||
import org.eclipse.jetty.util.component.AbstractLifeCycle;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
|
||||
class SocketConnector extends AbstractLifeCycle implements HttpClient.Connector
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(SocketConnector.class);
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@ -51,7 +54,7 @@ class SocketConnector extends AbstractLifeCycle implements HttpClient.Connector
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.debug("Using Regular Socket");
|
||||
LOG.debug("Using Regular Socket");
|
||||
socket = SocketFactory.getDefault().createSocket();
|
||||
}
|
||||
|
||||
@ -87,10 +90,10 @@ class SocketConnector extends AbstractLifeCycle implements HttpClient.Connector
|
||||
catch (IOException e)
|
||||
{
|
||||
if (e instanceof InterruptedIOException)
|
||||
Log.ignore(e);
|
||||
LOG.ignore(e);
|
||||
else
|
||||
{
|
||||
Log.debug(e);
|
||||
LOG.debug(e);
|
||||
destination.onException(e);
|
||||
}
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ import org.eclipse.jetty.http.HttpStatus;
|
||||
import org.eclipse.jetty.io.Buffer;
|
||||
import org.eclipse.jetty.util.StringUtil;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
|
||||
|
||||
/**
|
||||
@ -35,7 +36,9 @@ import org.eclipse.jetty.util.log.Log;
|
||||
* HttpExchange.
|
||||
*/
|
||||
public class SecurityListener extends HttpEventListenerWrapper
|
||||
{
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(SecurityListener.class);
|
||||
|
||||
private HttpDestination _destination;
|
||||
private HttpExchange _exchange;
|
||||
private boolean _requestComplete;
|
||||
@ -105,7 +108,7 @@ public class SecurityListener extends HttpEventListenerWrapper
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.debug("SecurityListener: missed scraping authentication details - " + token );
|
||||
LOG.debug("SecurityListener: missed scraping authentication details - " + token );
|
||||
}
|
||||
}
|
||||
return authenticationDetails;
|
||||
@ -116,8 +119,8 @@ public class SecurityListener extends HttpEventListenerWrapper
|
||||
public void onResponseStatus( Buffer version, int status, Buffer reason )
|
||||
throws IOException
|
||||
{
|
||||
if (Log.isDebugEnabled())
|
||||
Log.debug("SecurityListener:Response Status: " + status );
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("SecurityListener:Response Status: " + status );
|
||||
|
||||
if ( status == HttpStatus.UNAUTHORIZED_401 && _attempts<_destination.getHttpClient().maxRetries())
|
||||
{
|
||||
@ -139,8 +142,8 @@ public class SecurityListener extends HttpEventListenerWrapper
|
||||
public void onResponseHeader( Buffer name, Buffer value )
|
||||
throws IOException
|
||||
{
|
||||
if (Log.isDebugEnabled())
|
||||
Log.debug( "SecurityListener:Header: " + name.toString() + " / " + value.toString() );
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug( "SecurityListener:Header: " + name.toString() + " / " + value.toString() );
|
||||
|
||||
|
||||
if (!isDelegatingResponses())
|
||||
@ -168,7 +171,7 @@ public class SecurityListener extends HttpEventListenerWrapper
|
||||
|
||||
if ( realm == null )
|
||||
{
|
||||
Log.warn( "Unknown Security Realm: " + details.get("realm") );
|
||||
LOG.warn( "Unknown Security Realm: " + details.get("realm") );
|
||||
}
|
||||
else if ("digest".equalsIgnoreCase(type))
|
||||
{
|
||||
@ -196,8 +199,8 @@ public class SecurityListener extends HttpEventListenerWrapper
|
||||
{
|
||||
if (_requestComplete && _responseComplete)
|
||||
{
|
||||
if (Log.isDebugEnabled())
|
||||
Log.debug("onRequestComplete, Both complete: Resending from onResponseComplete "+_exchange);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("onRequestComplete, Both complete: Resending from onResponseComplete "+_exchange);
|
||||
_responseComplete = false;
|
||||
_requestComplete = false;
|
||||
setDelegatingRequests(true);
|
||||
@ -206,15 +209,15 @@ public class SecurityListener extends HttpEventListenerWrapper
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Log.isDebugEnabled())
|
||||
Log.debug("onRequestComplete, Response not yet complete onRequestComplete, calling super for "+_exchange);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("onRequestComplete, Response not yet complete onRequestComplete, calling super for "+_exchange);
|
||||
super.onRequestComplete();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Log.isDebugEnabled())
|
||||
Log.debug("onRequestComplete, delegating to super with Request complete="+_requestComplete+", response complete="+_responseComplete+" "+_exchange);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("onRequestComplete, delegating to super with Request complete="+_requestComplete+", response complete="+_responseComplete+" "+_exchange);
|
||||
super.onRequestComplete();
|
||||
}
|
||||
}
|
||||
@ -228,8 +231,8 @@ public class SecurityListener extends HttpEventListenerWrapper
|
||||
{
|
||||
if (_requestComplete && _responseComplete)
|
||||
{
|
||||
if (Log.isDebugEnabled())
|
||||
Log.debug("onResponseComplete, Both complete: Resending from onResponseComplete"+_exchange);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("onResponseComplete, Both complete: Resending from onResponseComplete"+_exchange);
|
||||
_responseComplete = false;
|
||||
_requestComplete = false;
|
||||
setDelegatingResponses(true);
|
||||
@ -239,15 +242,15 @@ public class SecurityListener extends HttpEventListenerWrapper
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Log.isDebugEnabled())
|
||||
Log.debug("onResponseComplete, Request not yet complete from onResponseComplete, calling super "+_exchange);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("onResponseComplete, Request not yet complete from onResponseComplete, calling super "+_exchange);
|
||||
super.onResponseComplete();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Log.isDebugEnabled())
|
||||
Log.debug("OnResponseComplete, delegating to super with Request complete="+_requestComplete+", response complete="+_responseComplete+" "+_exchange);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("OnResponseComplete, delegating to super with Request complete="+_requestComplete+", response complete="+_responseComplete+" "+_exchange);
|
||||
super.onResponseComplete();
|
||||
}
|
||||
}
|
||||
|
@ -19,10 +19,13 @@ import org.eclipse.jetty.client.CachedExchange;
|
||||
import org.eclipse.jetty.http.HttpStatus;
|
||||
import org.eclipse.jetty.io.Buffer;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
|
||||
|
||||
public class MkcolExchange extends CachedExchange
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(MkcolExchange.class);
|
||||
|
||||
boolean exists = false;
|
||||
|
||||
public MkcolExchange()
|
||||
@ -36,13 +39,13 @@ public class MkcolExchange extends CachedExchange
|
||||
{
|
||||
if ( status == HttpStatus.CREATED_201 )
|
||||
{
|
||||
Log.debug( "MkcolExchange:Status: Successfully created resource" );
|
||||
LOG.debug( "MkcolExchange:Status: Successfully created resource" );
|
||||
exists = true;
|
||||
}
|
||||
|
||||
if ( status == HttpStatus.METHOD_NOT_ALLOWED_405 ) // returned when resource exists
|
||||
{
|
||||
Log.debug( "MkcolExchange:Status: Resource must exist" );
|
||||
LOG.debug( "MkcolExchange:Status: Resource must exist" );
|
||||
exists = true;
|
||||
}
|
||||
|
||||
|
@ -19,10 +19,13 @@ import org.eclipse.jetty.client.HttpExchange;
|
||||
import org.eclipse.jetty.http.HttpStatus;
|
||||
import org.eclipse.jetty.io.Buffer;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
|
||||
|
||||
public class PropfindExchange extends HttpExchange
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(PropfindExchange.class);
|
||||
|
||||
boolean _propertyExists = false;
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
@ -31,12 +34,12 @@ public class PropfindExchange extends HttpExchange
|
||||
{
|
||||
if ( status == HttpStatus.OK_200 )
|
||||
{
|
||||
Log.debug( "PropfindExchange:Status: Exists" );
|
||||
LOG.debug( "PropfindExchange:Status: Exists" );
|
||||
_propertyExists = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.debug( "PropfindExchange:Status: Not Exists" );
|
||||
LOG.debug( "PropfindExchange:Status: Not Exists" );
|
||||
}
|
||||
|
||||
super.onResponseStatus(version, status, reason);
|
||||
|
@ -25,6 +25,7 @@ import org.eclipse.jetty.http.HttpStatus;
|
||||
import org.eclipse.jetty.io.Buffer;
|
||||
import org.eclipse.jetty.util.URIUtil;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
|
||||
/**
|
||||
* WebdavListener
|
||||
@ -35,6 +36,8 @@ import org.eclipse.jetty.util.log.Log;
|
||||
*/
|
||||
public class WebdavListener extends HttpEventListenerWrapper
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(WebdavListener.class);
|
||||
|
||||
private HttpDestination _destination;
|
||||
private HttpExchange _exchange;
|
||||
private boolean _requestComplete;
|
||||
@ -67,8 +70,8 @@ public class WebdavListener extends HttpEventListenerWrapper
|
||||
return;
|
||||
}
|
||||
|
||||
if (Log.isDebugEnabled())
|
||||
Log.debug("WebdavListener:Response Status: " + status );
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("WebdavListener:Response Status: " + status );
|
||||
|
||||
// The dav spec says that CONFLICT should be returned when the parent collection doesn't exist but I am seeing
|
||||
// FORBIDDEN returned instead so running with that.
|
||||
@ -76,15 +79,15 @@ public class WebdavListener extends HttpEventListenerWrapper
|
||||
{
|
||||
if ( _webdavEnabled )
|
||||
{
|
||||
if (Log.isDebugEnabled())
|
||||
Log.debug("WebdavListener:Response Status: dav enabled, taking a stab at resolving put issue" );
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("WebdavListener:Response Status: dav enabled, taking a stab at resolving put issue" );
|
||||
setDelegatingResponses( false ); // stop delegating, we can try and fix this request
|
||||
_needIntercept = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Log.isDebugEnabled())
|
||||
Log.debug("WebdavListener:Response Status: Webdav Disabled" );
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("WebdavListener:Response Status: Webdav Disabled" );
|
||||
setDelegatingResponses( true ); // just make sure we delegate
|
||||
setDelegatingRequests( true );
|
||||
_needIntercept = false;
|
||||
@ -130,14 +133,14 @@ public class WebdavListener extends HttpEventListenerWrapper
|
||||
}
|
||||
catch ( IOException ioe )
|
||||
{
|
||||
Log.debug("WebdavListener:Complete:IOException: might not be dealing with dav server, delegate");
|
||||
LOG.debug("WebdavListener:Complete:IOException: might not be dealing with dav server, delegate");
|
||||
super.onResponseComplete();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Log.isDebugEnabled())
|
||||
Log.debug("WebdavListener:Not ready, calling super");
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("WebdavListener:Not ready, calling super");
|
||||
super.onResponseComplete();
|
||||
}
|
||||
}
|
||||
@ -178,14 +181,14 @@ public class WebdavListener extends HttpEventListenerWrapper
|
||||
}
|
||||
catch ( IOException ioe )
|
||||
{
|
||||
Log.debug("WebdavListener:Complete:IOException: might not be dealing with dav server, delegate");
|
||||
LOG.debug("WebdavListener:Complete:IOException: might not be dealing with dav server, delegate");
|
||||
super.onRequestComplete();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Log.isDebugEnabled())
|
||||
Log.debug("WebdavListener:Not ready, calling super");
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("WebdavListener:Not ready, calling super");
|
||||
super.onRequestComplete();
|
||||
}
|
||||
}
|
||||
@ -253,7 +256,7 @@ public class WebdavListener extends HttpEventListenerWrapper
|
||||
propfindExchange.setScheme( _exchange.getScheme() );
|
||||
propfindExchange.setEventListener( new SecurityListener( _destination, propfindExchange ) );
|
||||
propfindExchange.setConfigureListeners( false );
|
||||
propfindExchange.setURI( uri );
|
||||
propfindExchange.setRequestURI( uri );
|
||||
|
||||
_destination.send( propfindExchange );
|
||||
|
||||
@ -265,7 +268,7 @@ public class WebdavListener extends HttpEventListenerWrapper
|
||||
}
|
||||
catch ( InterruptedException ie )
|
||||
{
|
||||
Log.ignore( ie );
|
||||
LOG.ignore( ie );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -278,7 +281,7 @@ public class WebdavListener extends HttpEventListenerWrapper
|
||||
mkcolExchange.setScheme( _exchange.getScheme() );
|
||||
mkcolExchange.setEventListener( new SecurityListener( _destination, mkcolExchange ) );
|
||||
mkcolExchange.setConfigureListeners( false );
|
||||
mkcolExchange.setURI( uri );
|
||||
mkcolExchange.setRequestURI( uri );
|
||||
|
||||
_destination.send( mkcolExchange );
|
||||
|
||||
@ -290,7 +293,7 @@ public class WebdavListener extends HttpEventListenerWrapper
|
||||
}
|
||||
catch ( InterruptedException ie )
|
||||
{
|
||||
Log.ignore( ie );
|
||||
LOG.ignore( ie );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -304,7 +307,7 @@ public class WebdavListener extends HttpEventListenerWrapper
|
||||
supportedExchange.setScheme( _exchange.getScheme() );
|
||||
supportedExchange.setEventListener( new SecurityListener( _destination, supportedExchange ) );
|
||||
supportedExchange.setConfigureListeners( false );
|
||||
supportedExchange.setURI( _exchange.getURI() );
|
||||
supportedExchange.setRequestURI( _exchange.getURI() );
|
||||
|
||||
_destination.send( supportedExchange );
|
||||
|
||||
@ -315,7 +318,7 @@ public class WebdavListener extends HttpEventListenerWrapper
|
||||
}
|
||||
catch (InterruptedException ie )
|
||||
{
|
||||
Log.ignore( ie );
|
||||
LOG.ignore( ie );
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -18,18 +18,21 @@ import java.io.IOException;
|
||||
import org.eclipse.jetty.client.HttpExchange;
|
||||
import org.eclipse.jetty.io.Buffer;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
|
||||
|
||||
public class WebdavSupportedExchange extends HttpExchange
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(WebdavSupportedExchange.class);
|
||||
|
||||
private boolean _webdavSupported = false;
|
||||
private boolean _isComplete = false;
|
||||
|
||||
@Override
|
||||
protected void onResponseHeader(Buffer name, Buffer value) throws IOException
|
||||
{
|
||||
if (Log.isDebugEnabled())
|
||||
Log.debug("WebdavSupportedExchange:Header:" + name.toString() + " / " + value.toString() );
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("WebdavSupportedExchange:Header:" + name.toString() + " / " + value.toString() );
|
||||
if ( "DAV".equals( name.toString() ) )
|
||||
{
|
||||
if ( value.toString().indexOf( "1" ) >= 0 || value.toString().indexOf( "2" ) >= 0 )
|
||||
|
@ -53,7 +53,7 @@ public abstract class AbstractConnectionTest
|
||||
CountDownLatch latch = new CountDownLatch(1);
|
||||
HttpExchange exchange = new ConnectionExchange(latch);
|
||||
exchange.setAddress(new Address("localhost", port));
|
||||
exchange.setURI("/");
|
||||
exchange.setRequestURI("/");
|
||||
httpClient.send(exchange);
|
||||
|
||||
Socket remote = serverSocket.accept();
|
||||
@ -109,7 +109,7 @@ public abstract class AbstractConnectionTest
|
||||
CountDownLatch latch = new CountDownLatch(1);
|
||||
HttpExchange exchange = new ConnectionExchange(latch);
|
||||
exchange.setAddress(new Address("localhost", port));
|
||||
exchange.setURI("/");
|
||||
exchange.setRequestURI("/");
|
||||
httpClient.send(exchange);
|
||||
|
||||
boolean passed = latch.await(4000, TimeUnit.MILLISECONDS);
|
||||
@ -158,7 +158,7 @@ public abstract class AbstractConnectionTest
|
||||
}
|
||||
};
|
||||
exchange.setAddress(new Address("localhost", port));
|
||||
exchange.setURI("/");
|
||||
exchange.setRequestURI("/");
|
||||
exchanges[i] = exchange;
|
||||
}
|
||||
|
||||
@ -189,7 +189,7 @@ public abstract class AbstractConnectionTest
|
||||
HttpExchange exchange = new ConnectionExchange(latch);
|
||||
// Using a IP address has a different behavior than using a host name
|
||||
exchange.setAddress(new Address("127.0.0.1", 1));
|
||||
exchange.setURI("/");
|
||||
exchange.setRequestURI("/");
|
||||
httpClient.send(exchange);
|
||||
|
||||
boolean passed = latch.await(connectTimeout * 2L, TimeUnit.MILLISECONDS);
|
||||
@ -218,7 +218,7 @@ public abstract class AbstractConnectionTest
|
||||
{
|
||||
HttpExchange exchange = new ConnectionExchange();
|
||||
exchange.setAddress(new Address("localhost", port));
|
||||
exchange.setURI("/");
|
||||
exchange.setRequestURI("/");
|
||||
HttpDestination dest = httpClient.getDestination(new Address("localhost", port),false);
|
||||
|
||||
httpClient.send(exchange);
|
||||
@ -236,7 +236,7 @@ public abstract class AbstractConnectionTest
|
||||
|
||||
exchange = new ConnectionExchange();
|
||||
exchange.setAddress(new Address("localhost", port));
|
||||
exchange.setURI("/");
|
||||
exchange.setRequestURI("/");
|
||||
|
||||
httpClient.send(exchange);
|
||||
s.getInputStream().read(buf);
|
||||
|
@ -28,11 +28,13 @@ import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.eclipse.jetty.io.Buffer;
|
||||
import org.eclipse.jetty.server.Connector;
|
||||
import org.eclipse.jetty.server.HttpConnection;
|
||||
import org.eclipse.jetty.server.Request;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.handler.AbstractHandler;
|
||||
import org.eclipse.jetty.server.nio.SelectChannelConnector;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.util.log.StdErrLog;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
@ -43,6 +45,8 @@ import org.junit.Test;
|
||||
*/
|
||||
public abstract class AbstractHttpExchangeCancelTest
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(AbstractHttpExchangeCancelTest.class);
|
||||
|
||||
private Server server;
|
||||
private Connector connector;
|
||||
|
||||
@ -84,7 +88,7 @@ public abstract class AbstractHttpExchangeCancelTest
|
||||
}
|
||||
};
|
||||
exchange.setAddress(newAddress());
|
||||
exchange.setURI("/");
|
||||
exchange.setRequestURI("/");
|
||||
|
||||
getHttpClient().send(exchange);
|
||||
// Cancelling here is wrong and makes the test fail spuriously
|
||||
@ -122,7 +126,7 @@ public abstract class AbstractHttpExchangeCancelTest
|
||||
}
|
||||
};
|
||||
exchange.setAddress(newAddress());
|
||||
exchange.setURI("/");
|
||||
exchange.setRequestURI("/");
|
||||
|
||||
getHttpClient().send(exchange);
|
||||
// Cancelling here is wrong and makes the test fail spuriously
|
||||
@ -152,7 +156,7 @@ public abstract class AbstractHttpExchangeCancelTest
|
||||
}
|
||||
};
|
||||
exchange.setAddress(newAddress());
|
||||
exchange.setURI("/");
|
||||
exchange.setRequestURI("/");
|
||||
|
||||
getHttpClient().send(exchange);
|
||||
|
||||
@ -177,7 +181,7 @@ public abstract class AbstractHttpExchangeCancelTest
|
||||
}
|
||||
};
|
||||
exchange.setAddress(newAddress());
|
||||
exchange.setURI("/");
|
||||
exchange.setRequestURI("/");
|
||||
|
||||
getHttpClient().send(exchange);
|
||||
|
||||
@ -202,7 +206,7 @@ public abstract class AbstractHttpExchangeCancelTest
|
||||
}
|
||||
};
|
||||
exchange.setAddress(newAddress());
|
||||
exchange.setURI("/");
|
||||
exchange.setRequestURI("/");
|
||||
|
||||
getHttpClient().send(exchange);
|
||||
|
||||
@ -227,7 +231,7 @@ public abstract class AbstractHttpExchangeCancelTest
|
||||
}
|
||||
};
|
||||
exchange.setAddress(newAddress());
|
||||
exchange.setURI("/");
|
||||
exchange.setRequestURI("/");
|
||||
|
||||
getHttpClient().send(exchange);
|
||||
|
||||
@ -252,7 +256,7 @@ public abstract class AbstractHttpExchangeCancelTest
|
||||
}
|
||||
};
|
||||
exchange.setAddress(newAddress());
|
||||
exchange.setURI("/");
|
||||
exchange.setRequestURI("/");
|
||||
|
||||
getHttpClient().send(exchange);
|
||||
|
||||
@ -277,7 +281,7 @@ public abstract class AbstractHttpExchangeCancelTest
|
||||
}
|
||||
};
|
||||
exchange.setAddress(newAddress());
|
||||
exchange.setURI("/?action=body");
|
||||
exchange.setRequestURI("/?action=body");
|
||||
|
||||
getHttpClient().send(exchange);
|
||||
|
||||
@ -302,7 +306,7 @@ public abstract class AbstractHttpExchangeCancelTest
|
||||
}
|
||||
};
|
||||
exchange.setAddress(newAddress());
|
||||
exchange.setURI("/");
|
||||
exchange.setRequestURI("/");
|
||||
|
||||
getHttpClient().send(exchange);
|
||||
|
||||
@ -319,10 +323,10 @@ public abstract class AbstractHttpExchangeCancelTest
|
||||
{
|
||||
try
|
||||
{
|
||||
((StdErrLog)Log.getLog()).setHideStacks(!Log.isDebugEnabled());
|
||||
((StdErrLog)Log.getLogger(HttpConnection.class)).setHideStacks(true);
|
||||
TestHttpExchange exchange = new TestHttpExchange();
|
||||
exchange.setAddress(newAddress());
|
||||
exchange.setURI("/?action=throw");
|
||||
exchange.setRequestURI("/?action=throw");
|
||||
|
||||
getHttpClient().send(exchange);
|
||||
|
||||
@ -334,7 +338,7 @@ public abstract class AbstractHttpExchangeCancelTest
|
||||
}
|
||||
finally
|
||||
{
|
||||
((StdErrLog)Log.getLog()).setHideStacks(false);
|
||||
((StdErrLog)Log.getLogger(HttpConnection.class)).setHideStacks(false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -349,7 +353,7 @@ public abstract class AbstractHttpExchangeCancelTest
|
||||
|
||||
TestHttpExchange exchange = new TestHttpExchange();
|
||||
exchange.setAddress(newAddress());
|
||||
exchange.setURI("/?action=wait5000");
|
||||
exchange.setRequestURI("/?action=wait5000");
|
||||
|
||||
long start = System.currentTimeMillis();
|
||||
httpClient.send(exchange);
|
||||
|
@ -18,7 +18,7 @@ public class AsyncSslHttpExchangeTest extends SslHttpExchangeTest
|
||||
@Override
|
||||
public void setUp() throws Exception
|
||||
{
|
||||
_scheme="https://";
|
||||
_scheme="https";
|
||||
startServer();
|
||||
_httpClient=new HttpClient();
|
||||
_httpClient.setIdleTimeout(2000);
|
||||
|
@ -23,7 +23,7 @@ public class ExternalKeyStoreAsyncSslHttpExchangeTest extends SslHttpExchangeTes
|
||||
@Override
|
||||
public void setUp() throws Exception
|
||||
{
|
||||
_scheme = "https://";
|
||||
_scheme = "https";
|
||||
startServer();
|
||||
_httpClient = new HttpClient();
|
||||
_httpClient.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL);
|
||||
|
@ -0,0 +1,240 @@
|
||||
// ========================================================================
|
||||
// Copyright (c) Webtide LLC
|
||||
// ------------------------------------------------------------------------
|
||||
// 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.client;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.eclipse.jetty.http.HttpMethods;
|
||||
import org.eclipse.jetty.http.HttpStatus;
|
||||
import org.eclipse.jetty.server.Connector;
|
||||
import org.eclipse.jetty.server.Request;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.handler.AbstractHandler;
|
||||
import org.eclipse.jetty.server.nio.SelectChannelConnector;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public class Http100ContinueTest
|
||||
{
|
||||
private static final int TIMEOUT = 500;
|
||||
|
||||
private static final String CONTENT = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. In quis felis nunc. "
|
||||
+ "Quisque suscipit mauris et ante auctor ornare rhoncus lacus aliquet. Pellentesque "
|
||||
+ "habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. "
|
||||
+ "Vestibulum sit amet felis augue, vel convallis dolor. Cras accumsan vehicula diam "
|
||||
+ "at faucibus. Etiam in urna turpis, sed congue mi. Morbi et lorem eros. Donec vulputate "
|
||||
+ "velit in risus suscipit lobortis. Aliquam id urna orci, nec sollicitudin ipsum. "
|
||||
+ "Cras a orci turpis. Donec suscipit vulputate cursus. Mauris nunc tellus, fermentum "
|
||||
+ "eu auctor ut, mollis at diam. Quisque porttitor ultrices metus, vitae tincidunt massa "
|
||||
+ "sollicitudin a. Vivamus porttitor libero eget purus hendrerit cursus. Integer aliquam "
|
||||
+ "consequat mauris quis luctus. Cras enim nibh, dignissim eu faucibus ac, mollis nec neque. "
|
||||
+ "Aliquam purus mauris, consectetur nec convallis lacinia, porta sed ante. Suspendisse "
|
||||
+ "et cursus magna. Donec orci enim, molestie a lobortis eu, imperdiet vitae neque.";
|
||||
|
||||
private static TestFeature _feature;
|
||||
|
||||
private static Server _server;
|
||||
private static TestHandler _handler;
|
||||
private static HttpClient _client;
|
||||
private static String _requestUrl;
|
||||
|
||||
@BeforeClass
|
||||
public static void init() throws Exception
|
||||
{
|
||||
File docRoot = new File("target/test-output/docroot/");
|
||||
if (!docRoot.exists())
|
||||
assertTrue(docRoot.mkdirs());
|
||||
docRoot.deleteOnExit();
|
||||
|
||||
_server = new Server();
|
||||
Connector connector = new SelectChannelConnector();
|
||||
_server.addConnector(connector);
|
||||
|
||||
_handler = new TestHandler();
|
||||
_server.setHandler(_handler);
|
||||
|
||||
_server.start();
|
||||
|
||||
_client = new HttpClient();
|
||||
_client.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL);
|
||||
_client.setTimeout(TIMEOUT);
|
||||
_client.setMaxRetries(0);
|
||||
_client.start();
|
||||
|
||||
_requestUrl = "http://localhost:" + connector.getLocalPort() + "/";
|
||||
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void destroy() throws Exception
|
||||
{
|
||||
_client.stop();
|
||||
|
||||
_server.stop();
|
||||
_server.join();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess() throws Exception
|
||||
{
|
||||
// Handler to send CONTINUE 100
|
||||
_feature = TestFeature.CONTINUE;
|
||||
|
||||
ContentExchange exchange = sendExchange();
|
||||
|
||||
int state = exchange.waitForDone();
|
||||
assertEquals(HttpExchange.STATUS_COMPLETED, state);
|
||||
|
||||
int responseStatus = exchange.getResponseStatus();
|
||||
assertEquals(HttpStatus.OK_200,responseStatus);
|
||||
|
||||
String content = exchange.getResponseContent();
|
||||
assertEquals(Http100ContinueTest.CONTENT,content);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMissingContinue() throws Exception
|
||||
{
|
||||
// Handler does not send CONTINUE 100
|
||||
_feature = TestFeature.NORMAL;
|
||||
|
||||
ContentExchange exchange = sendExchange();
|
||||
|
||||
int state = exchange.waitForDone();
|
||||
assertEquals(HttpExchange.STATUS_COMPLETED, state);
|
||||
|
||||
int responseStatus = exchange.getResponseStatus();
|
||||
assertEquals(HttpStatus.OK_200,responseStatus);
|
||||
|
||||
String content = exchange.getResponseContent();
|
||||
assertEquals(Http100ContinueTest.CONTENT,content);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testError() throws Exception
|
||||
{
|
||||
// Handler sends NOT FOUND 404 response
|
||||
_feature = TestFeature.NOTFOUND;
|
||||
|
||||
ContentExchange exchange = sendExchange();
|
||||
|
||||
int state = exchange.waitForDone();
|
||||
assertEquals(HttpExchange.STATUS_COMPLETED, state);
|
||||
|
||||
int responseStatus = exchange.getResponseStatus();
|
||||
assertEquals(HttpStatus.NOT_FOUND_404,responseStatus);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTimeout() throws Exception
|
||||
{
|
||||
// Handler delays response till client times out
|
||||
_feature = TestFeature.TIMEOUT;
|
||||
|
||||
final CountDownLatch expires = new CountDownLatch(1);
|
||||
ContentExchange exchange = new ContentExchange()
|
||||
{
|
||||
@Override
|
||||
protected void onExpire()
|
||||
{
|
||||
expires.countDown();
|
||||
}
|
||||
};
|
||||
|
||||
configureExchange(exchange);
|
||||
_client.send(exchange);
|
||||
|
||||
assertTrue(expires.await(TIMEOUT*10,TimeUnit.MILLISECONDS));
|
||||
}
|
||||
|
||||
public ContentExchange sendExchange() throws Exception
|
||||
{
|
||||
ContentExchange exchange = new ContentExchange();
|
||||
|
||||
configureExchange(exchange);
|
||||
_client.send(exchange);
|
||||
|
||||
return exchange;
|
||||
}
|
||||
|
||||
public void configureExchange(ContentExchange exchange)
|
||||
{
|
||||
exchange.setURL(_requestUrl);
|
||||
exchange.setMethod(HttpMethods.GET);
|
||||
exchange.addRequestHeader("User-Agent","Jetty-Client/7.0");
|
||||
exchange.addRequestHeader("Expect","100-continue"); //server to send CONTINUE 100
|
||||
}
|
||||
|
||||
private static class TestHandler extends AbstractHandler
|
||||
{
|
||||
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
|
||||
{
|
||||
if (baseRequest.isHandled())
|
||||
return;
|
||||
|
||||
baseRequest.setHandled(true);
|
||||
|
||||
switch (_feature)
|
||||
{
|
||||
case CONTINUE:
|
||||
// force 100 Continue response to be sent
|
||||
request.getInputStream();
|
||||
// next send data
|
||||
|
||||
case NORMAL:
|
||||
response.setContentType("text/plain");
|
||||
response.setStatus(HttpServletResponse.SC_OK);
|
||||
response.getWriter().print(CONTENT);
|
||||
break;
|
||||
|
||||
case NOTFOUND:
|
||||
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
|
||||
break;
|
||||
|
||||
case TIMEOUT:
|
||||
try
|
||||
{
|
||||
Thread.sleep(TIMEOUT*4);
|
||||
}
|
||||
catch (InterruptedException ex)
|
||||
{
|
||||
Log.ignore(ex);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enum TestFeature {
|
||||
CONTINUE,
|
||||
NORMAL,
|
||||
NOTFOUND,
|
||||
TIMEOUT
|
||||
}
|
||||
}
|
@ -16,12 +16,15 @@ package org.eclipse.jetty.client;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.matchers.JUnitMatchers.containsString;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.URI;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
@ -32,8 +35,10 @@ import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.eclipse.jetty.client.security.ProxyAuthorization;
|
||||
import org.eclipse.jetty.http.HttpFields;
|
||||
import org.eclipse.jetty.http.HttpHeaders;
|
||||
import org.eclipse.jetty.http.HttpMethods;
|
||||
import org.eclipse.jetty.http.HttpStatus;
|
||||
import org.eclipse.jetty.io.Buffer;
|
||||
import org.eclipse.jetty.io.ByteArrayBuffer;
|
||||
import org.eclipse.jetty.io.Connection;
|
||||
@ -47,6 +52,7 @@ import org.eclipse.jetty.server.nio.SelectChannelConnector;
|
||||
import org.eclipse.jetty.toolchain.test.Stress;
|
||||
import org.eclipse.jetty.util.IO;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@ -57,8 +63,10 @@ import org.junit.Test;
|
||||
*/
|
||||
public class HttpExchangeTest
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(HttpExchangeTest.class);
|
||||
|
||||
protected int _maxConnectionsPerAddress = 2;
|
||||
protected String _scheme = "http://";
|
||||
protected String _scheme = "http";
|
||||
protected Server _server;
|
||||
protected int _port;
|
||||
protected HttpClient _httpClient;
|
||||
@ -233,7 +241,7 @@ public class HttpExchangeTest
|
||||
}
|
||||
};
|
||||
|
||||
httpExchange[n].setURL(_scheme+"localhost:"+_port+"/"+n);
|
||||
httpExchange[n].setURL(_scheme+"://localhost:"+_port+"/"+n);
|
||||
httpExchange[n].addRequestHeader("arbitrary","value");
|
||||
if (close)
|
||||
httpExchange[n].setRequestHeader("Connection","close");
|
||||
@ -261,8 +269,7 @@ public class HttpExchangeTest
|
||||
for (int i=0;i<20;i++)
|
||||
{
|
||||
ContentExchange httpExchange=new ContentExchange();
|
||||
//httpExchange.setURL(_scheme+"localhost:"+_port+"/");
|
||||
httpExchange.setURL(_scheme+"localhost:"+_port);
|
||||
httpExchange.setURI(new URI(_scheme, null, "localhost", _port, null, null, null));
|
||||
httpExchange.setMethod(HttpMethods.POST);
|
||||
httpExchange.setRequestContent(new ByteArrayBuffer("<hello />"));
|
||||
_httpClient.send(httpExchange);
|
||||
@ -281,7 +288,7 @@ public class HttpExchangeTest
|
||||
for (int i=0;i<10;i++)
|
||||
{
|
||||
ContentExchange httpExchange=new ContentExchange();
|
||||
httpExchange.setURL(_scheme+"localhost:"+_port+"/?i="+i);
|
||||
httpExchange.setURI(new URI(_scheme, null, "localhost", _port, "/", "i="+i, null));
|
||||
httpExchange.setMethod(HttpMethods.GET);
|
||||
_httpClient.send(httpExchange);
|
||||
int status = httpExchange.waitForDone();
|
||||
@ -301,7 +308,7 @@ public class HttpExchangeTest
|
||||
for (int i=0;i<10;i++)
|
||||
{
|
||||
ContentExchange httpExchange=new ContentExchange();
|
||||
httpExchange.setURL(_scheme+"localhost:"+_port+"/?i="+i);
|
||||
httpExchange.setURL(_scheme+"://localhost:"+_port+"/?i="+i);
|
||||
httpExchange.setMethod(HttpMethods.GET);
|
||||
_httpClient.send(httpExchange);
|
||||
int status = httpExchange.waitForDone();
|
||||
@ -348,7 +355,7 @@ public class HttpExchangeTest
|
||||
throwable.set(x);
|
||||
}
|
||||
};
|
||||
httpExchange.setURL(_scheme+"localhost:"+_port+"/");
|
||||
httpExchange.setURL(_scheme+"://localhost:"+_port+"/");
|
||||
httpExchange.setMethod("SLEEP");
|
||||
_httpClient.send(httpExchange);
|
||||
new Thread()
|
||||
@ -387,7 +394,7 @@ public class HttpExchangeTest
|
||||
niobuf.put(bytes);
|
||||
}
|
||||
|
||||
httpExchange.setURL(_scheme+"localhost:"+_port+"/");
|
||||
httpExchange.setURL(_scheme+"://localhost:"+_port+"/");
|
||||
httpExchange.setMethod(HttpMethods.POST);
|
||||
httpExchange.setRequestContentType("application/data");
|
||||
httpExchange.setRequestContent(babuf);
|
||||
@ -400,7 +407,7 @@ public class HttpExchangeTest
|
||||
assertEquals(babuf.length(),result.length());
|
||||
|
||||
httpExchange.reset();
|
||||
httpExchange.setURL(_scheme+"localhost:"+_port+"/");
|
||||
httpExchange.setURL(_scheme+"://localhost:"+_port+"/");
|
||||
httpExchange.setMethod(HttpMethods.POST);
|
||||
httpExchange.setRequestContentType("application/data");
|
||||
httpExchange.setRequestContent(niobuf);
|
||||
@ -419,8 +426,7 @@ public class HttpExchangeTest
|
||||
{
|
||||
|
||||
};
|
||||
//httpExchange.setURL(_scheme+"localhost:"+_port+"/");
|
||||
httpExchange.setURL(_scheme+"localhost:"+_port);
|
||||
httpExchange.setURL(_scheme+"://localhost:"+_port);
|
||||
httpExchange.setMethod(HttpMethods.POST);
|
||||
|
||||
final String data="012345678901234567890123456789012345678901234567890123456789";
|
||||
@ -478,7 +484,7 @@ public class HttpExchangeTest
|
||||
@Test
|
||||
public void testProxy() throws Exception
|
||||
{
|
||||
if (_scheme.equals("https://"))
|
||||
if (_scheme.equals("https"))
|
||||
return;
|
||||
try
|
||||
{
|
||||
@ -488,7 +494,7 @@ public class HttpExchangeTest
|
||||
ContentExchange httpExchange=new ContentExchange();
|
||||
httpExchange.setAddress(new Address("jetty.eclipse.org",8080));
|
||||
httpExchange.setMethod(HttpMethods.GET);
|
||||
httpExchange.setURI("/jetty-6");
|
||||
httpExchange.setRequestURI("/jetty-6");
|
||||
_httpClient.send(httpExchange);
|
||||
int status = httpExchange.waitForDone();
|
||||
//httpExchange.waitForStatus(HttpExchange.STATUS_COMPLETED);
|
||||
@ -509,14 +515,14 @@ public class HttpExchangeTest
|
||||
@Test
|
||||
public void testReserveConnections () throws Exception
|
||||
{
|
||||
final HttpDestination destination = _httpClient.getDestination (new Address("localhost", _port), _scheme.equalsIgnoreCase("https://"));
|
||||
final HttpDestination destination = _httpClient.getDestination (new Address("localhost", _port), _scheme.equalsIgnoreCase("https"));
|
||||
final org.eclipse.jetty.client.HttpConnection[] connections = new org.eclipse.jetty.client.HttpConnection[_maxConnectionsPerAddress];
|
||||
for (int i=0; i < _maxConnectionsPerAddress; i++)
|
||||
{
|
||||
connections[i] = destination.reserveConnection(200);
|
||||
assertNotNull(connections[i]);
|
||||
HttpExchange ex = new ContentExchange();
|
||||
ex.setURL(_scheme+"localhost:"+_port+"/?i="+i);
|
||||
ex.setURL(_scheme+"://localhost:"+_port+"/?i="+i);
|
||||
ex.setMethod(HttpMethods.GET);
|
||||
connections[i].send(ex);
|
||||
}
|
||||
@ -533,6 +539,35 @@ public class HttpExchangeTest
|
||||
c = destination.reserveConnection(500);
|
||||
assertNotNull(c);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOptionsWithExchange() throws Exception
|
||||
{
|
||||
ContentExchange httpExchange = new ContentExchange(true);
|
||||
httpExchange.setURL(_scheme+"://localhost:"+_port);
|
||||
httpExchange.setRequestURI("*");
|
||||
httpExchange.setMethod(HttpMethods.OPTIONS);
|
||||
// httpExchange.setRequestHeader("Connection","close");
|
||||
_httpClient.send(httpExchange);
|
||||
|
||||
int state = httpExchange.waitForDone();
|
||||
assertEquals(HttpExchange.STATUS_COMPLETED, state);
|
||||
assertEquals(HttpStatus.OK_200,httpExchange.getResponseStatus());
|
||||
|
||||
HttpFields headers = httpExchange.getResponseFields();
|
||||
assertTrue("Response contains Allow header", headers.containsKey("Allow"));
|
||||
|
||||
String allow = headers.getStringField("Allow");
|
||||
String expectedMethods[] =
|
||||
{ "GET", "HEAD", "POST", "PUT", "DELETE", "MOVE", "OPTIONS", "TRACE" };
|
||||
for (String expectedMethod : expectedMethods)
|
||||
{
|
||||
assertThat(allow,containsString(expectedMethod));
|
||||
}
|
||||
|
||||
assertTrue("Response contains Content-Length header", headers.containsKey("Content-Length"));
|
||||
assertEquals("Content-Length header value", 0, headers.getLongField("Content-Length"));
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public static void copyStream(InputStream in, OutputStream out)
|
||||
@ -600,6 +635,14 @@ public class HttpExchangeTest
|
||||
}
|
||||
response.getOutputStream().println("</hello>");
|
||||
}
|
||||
else if (request.getMethod().equalsIgnoreCase("OPTIONS"))
|
||||
{
|
||||
if ("*".equals(target))
|
||||
{
|
||||
response.setContentLength(0);
|
||||
response.setHeader("Allow","GET,HEAD,POST,PUT,DELETE,MOVE,OPTIONS,TRACE");
|
||||
}
|
||||
}
|
||||
else if (request.getMethod().equalsIgnoreCase("SLEEP"))
|
||||
{
|
||||
Thread.sleep(10000);
|
||||
@ -615,7 +658,7 @@ public class HttpExchangeTest
|
||||
}
|
||||
catch(InterruptedException e)
|
||||
{
|
||||
Log.debug(e);
|
||||
LOG.debug(e);
|
||||
}
|
||||
catch(IOException e)
|
||||
{
|
||||
|
@ -34,12 +34,15 @@ import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.handler.AbstractHandler;
|
||||
import org.eclipse.jetty.server.nio.SelectChannelConnector;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class HttpHeadersTest
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(HttpHeadersTest.class);
|
||||
|
||||
private static final String CONTENT = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. In quis felis nunc. "
|
||||
+ "Quisque suscipit mauris et ante auctor ornare rhoncus lacus aliquet. Pellentesque "
|
||||
+ "habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. "
|
||||
@ -133,7 +136,7 @@ public class HttpHeadersTest
|
||||
protected void onException(Throwable x)
|
||||
{
|
||||
// suppress exception
|
||||
Log.ignore(x);
|
||||
LOG.ignore(x);
|
||||
}
|
||||
};
|
||||
exchange.setURL(requestUrl);
|
||||
|
@ -139,36 +139,37 @@ public class ProxyFakeTunnelTest extends ProxyTunnellingTest
|
||||
}
|
||||
out.flush();
|
||||
|
||||
System.err.println(toserver);
|
||||
final InputStream from = toserver.getInputStream();
|
||||
|
||||
Thread copy = new Thread()
|
||||
if (toserver!=null)
|
||||
{
|
||||
public void run()
|
||||
final InputStream from = toserver.getInputStream();
|
||||
|
||||
Thread copy = new Thread()
|
||||
{
|
||||
try
|
||||
{
|
||||
IO.copy(from,out);
|
||||
out.close();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
}
|
||||
finally
|
||||
public void run()
|
||||
{
|
||||
try
|
||||
{
|
||||
IO.copy(from,out);
|
||||
out.close();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
}
|
||||
finally
|
||||
{
|
||||
try
|
||||
{
|
||||
out.close();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
copy.setDaemon(true);
|
||||
copy.start();
|
||||
|
||||
};
|
||||
copy.setDaemon(true);
|
||||
copy.start();
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
|
@ -40,7 +40,7 @@ public class SslHttpExchangeTest extends HttpExchangeTest
|
||||
@Override
|
||||
public void setUp() throws Exception
|
||||
{
|
||||
_scheme="https://";
|
||||
_scheme="https";
|
||||
startServer();
|
||||
_httpClient=new HttpClient();
|
||||
_httpClient.setIdleTimeout(2000);
|
||||
|
@ -50,6 +50,7 @@ import org.eclipse.jetty.server.handler.AbstractHandler;
|
||||
import org.eclipse.jetty.server.ssl.SslSocketConnector;
|
||||
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@ -60,6 +61,8 @@ import org.junit.Test;
|
||||
*/
|
||||
public class SslSecurityListenerTest
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(SslSecurityListenerTest.class);
|
||||
|
||||
protected Server _server;
|
||||
protected int _port;
|
||||
protected HttpClient _httpClient;
|
||||
@ -120,7 +123,7 @@ public class SslSecurityListenerTest
|
||||
// TODO Resolve problems on IBM JVM https://bugs.eclipse.org/bugs/show_bug.cgi?id=304532
|
||||
if (System.getProperty("java.vendor").toLowerCase().indexOf("ibm")>=0)
|
||||
{
|
||||
Log.warn("Skipped SSL testSslGet on IBM JVM");
|
||||
LOG.warn("Skipped SSL testSslGet on IBM JVM");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -33,29 +33,18 @@ import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.handler.AbstractHandler;
|
||||
import org.eclipse.jetty.server.nio.SelectChannelConnector;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
public class TimeoutExchangeTest
|
||||
{
|
||||
private HttpClient _httpClient;
|
||||
private Server _server;
|
||||
private int _port;
|
||||
private static HttpClient _httpClient;
|
||||
private static Server _server;
|
||||
private static int _port;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception
|
||||
{
|
||||
startServer();
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception
|
||||
{
|
||||
stopClient();
|
||||
stopServer();
|
||||
}
|
||||
|
||||
private void startServer() throws Exception
|
||||
@BeforeClass
|
||||
public static void startServer() throws Exception
|
||||
{
|
||||
_server = new Server();
|
||||
_server.setGracefulShutdown(500);
|
||||
@ -63,7 +52,8 @@ public class TimeoutExchangeTest
|
||||
_server.addConnector(_connector);
|
||||
Handler handler = new AbstractHandler()
|
||||
{
|
||||
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
|
||||
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException,
|
||||
ServletException
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -86,13 +76,24 @@ public class TimeoutExchangeTest
|
||||
_port = _connector.getLocalPort();
|
||||
}
|
||||
|
||||
private void stopServer() throws Exception
|
||||
@AfterClass
|
||||
public static void stopServer() throws Exception
|
||||
{
|
||||
_server.stop();
|
||||
_server.join();
|
||||
_server = null;
|
||||
}
|
||||
|
||||
@After
|
||||
public void stopClient() throws Exception
|
||||
{
|
||||
if (_httpClient != null)
|
||||
{
|
||||
_httpClient.stop();
|
||||
_httpClient = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void startClient(long clientTimeout) throws Exception
|
||||
{
|
||||
startClient(clientTimeout, 20000);
|
||||
@ -108,17 +109,11 @@ public class TimeoutExchangeTest
|
||||
_httpClient.start();
|
||||
}
|
||||
|
||||
private void stopClient() throws Exception
|
||||
{
|
||||
_httpClient.stop();
|
||||
// Thread.sleep(500);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDefaultTimeoutNotExpiring() throws Exception
|
||||
{
|
||||
startClient(1000);
|
||||
long serverSleep = 500;
|
||||
startClient(300);
|
||||
long serverSleep = 100;
|
||||
|
||||
CustomContentExchange httpExchange = new CustomContentExchange();
|
||||
httpExchange.setURL("http://localhost:" + _port + "/?sleep=" + serverSleep);
|
||||
@ -135,8 +130,8 @@ public class TimeoutExchangeTest
|
||||
@Test
|
||||
public void testDefaultTimeoutExpiring() throws Exception
|
||||
{
|
||||
startClient(500);
|
||||
long serverSleep = 1000;
|
||||
startClient(100);
|
||||
long serverSleep = 200;
|
||||
|
||||
CustomContentExchange httpExchange = new CustomContentExchange();
|
||||
httpExchange.setURL("http://localhost:" + _port + "/?sleep=" + serverSleep);
|
||||
@ -153,9 +148,9 @@ public class TimeoutExchangeTest
|
||||
@Test
|
||||
public void testExchangeTimeoutNotExpiring() throws Exception
|
||||
{
|
||||
startClient(500);
|
||||
long serverSleep = 1000;
|
||||
long exchangeTimeout = 1500;
|
||||
startClient(100);
|
||||
long serverSleep = 200;
|
||||
long exchangeTimeout = 300;
|
||||
|
||||
CustomContentExchange httpExchange = new CustomContentExchange();
|
||||
httpExchange.setURL("http://localhost:" + _port + "/?sleep=" + serverSleep);
|
||||
@ -173,9 +168,10 @@ public class TimeoutExchangeTest
|
||||
@Test
|
||||
public void testExchangeTimeoutExpiring() throws Exception
|
||||
{
|
||||
startClient(5000);
|
||||
long serverSleep = 1000;
|
||||
long exchangeTimeout = 500;
|
||||
startClient(500);
|
||||
|
||||
long serverSleep = 300;
|
||||
long exchangeTimeout = 100;
|
||||
|
||||
CustomContentExchange httpExchange = new CustomContentExchange();
|
||||
httpExchange.setURL("http://localhost:" + _port + "/?sleep=" + serverSleep);
|
||||
@ -193,8 +189,8 @@ public class TimeoutExchangeTest
|
||||
@Test
|
||||
public void testDefaultTimeoutWithSmallerIdleTimeoutNotExpiring() throws Exception
|
||||
{
|
||||
startClient(3000, 1000);
|
||||
long serverSleep = 2000;
|
||||
startClient(500,150);
|
||||
long serverSleep = 300;
|
||||
|
||||
// The idle timeout is shorter than the default timeout, but will be
|
||||
// temporarily increased on the endpoint in order for the exchange to complete.
|
||||
@ -214,9 +210,9 @@ public class TimeoutExchangeTest
|
||||
@Test
|
||||
public void testExchangeTimeoutWithSmallerIdleTimeoutNotExpiring() throws Exception
|
||||
{
|
||||
startClient(4000, 3000);
|
||||
long serverSleep = 1000;
|
||||
long exchangeTimeout = 2000;
|
||||
startClient(500,150);
|
||||
long serverSleep = 150;
|
||||
long exchangeTimeout = 300;
|
||||
|
||||
// The idle timeout is shorter than the default timeout, but will be
|
||||
// temporarily increased on the endpoint in order for the exchange to complete.
|
||||
|
@ -0,0 +1,203 @@
|
||||
// ========================================================================
|
||||
// Copyright 2006-2007 Mort Bay Consulting Pty. Ltd.
|
||||
// ------------------------------------------------------------------------
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// ========================================================================
|
||||
|
||||
package org.eclipse.jetty.client;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.eclipse.jetty.server.Connector;
|
||||
import org.eclipse.jetty.http.HttpMethods;
|
||||
import org.eclipse.jetty.io.EofException;
|
||||
import org.eclipse.jetty.server.Request;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.handler.AbstractHandler;
|
||||
import org.eclipse.jetty.server.nio.SelectChannelConnector;
|
||||
import org.eclipse.jetty.util.IO;
|
||||
|
||||
|
||||
/**
|
||||
* Functional testing for HttpExchange.
|
||||
*
|
||||
* @author Matthew Purland
|
||||
* @author Greg Wilkins
|
||||
*/
|
||||
public class UnexpectedDataTest extends TestCase
|
||||
{
|
||||
protected int _maxConnectionsPerAddress = 1;
|
||||
protected String _scheme = "http://";
|
||||
protected Server _server;
|
||||
protected int _port;
|
||||
protected HttpClient _httpClient;
|
||||
protected Connector _connector;
|
||||
protected AtomicInteger _count = new AtomicInteger();
|
||||
|
||||
protected void setUp() throws Exception
|
||||
{
|
||||
startServer();
|
||||
_httpClient=new HttpClient();
|
||||
_httpClient.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL);
|
||||
_httpClient.setMaxConnectionsPerAddress(_maxConnectionsPerAddress);
|
||||
_httpClient.start();
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception
|
||||
{
|
||||
_httpClient.stop();
|
||||
Thread.sleep(500);
|
||||
stopServer();
|
||||
}
|
||||
|
||||
public void testUnexpectedData() throws Exception
|
||||
{
|
||||
for (int i=0; i<4; i++)
|
||||
{
|
||||
final CountDownLatch done=new CountDownLatch(1);
|
||||
ContentExchange httpExchange=new ContentExchange()
|
||||
{
|
||||
protected void onResponseComplete() throws IOException
|
||||
{
|
||||
super.onResponseComplete();
|
||||
|
||||
done.countDown();
|
||||
}
|
||||
};
|
||||
httpExchange.setURL(_scheme+"localhost:"+_port+"/?i="+i);
|
||||
httpExchange.setMethod(HttpMethods.GET);
|
||||
_httpClient.send(httpExchange);
|
||||
|
||||
done.await(1,TimeUnit.SECONDS);
|
||||
|
||||
int status = httpExchange.getStatus();
|
||||
String result=httpExchange.getResponseContent();
|
||||
assertEquals("i="+i,0,result.indexOf("<hello>"));
|
||||
assertEquals("i="+i,result.length()-10,result.indexOf("</hello>"));
|
||||
assertEquals(HttpExchange.STATUS_COMPLETED, status);
|
||||
|
||||
Thread.sleep(5);
|
||||
}
|
||||
}
|
||||
|
||||
public static void copyStream(InputStream in, OutputStream out)
|
||||
{
|
||||
try
|
||||
{
|
||||
byte[] buffer=new byte[1024];
|
||||
int len;
|
||||
while ((len=in.read(buffer))>=0)
|
||||
{
|
||||
out.write(buffer,0,len);
|
||||
}
|
||||
}
|
||||
catch (EofException e)
|
||||
{
|
||||
System.err.println(e);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
protected void newServer() throws Exception
|
||||
{
|
||||
_server=new Server();
|
||||
_server.setGracefulShutdown(500);
|
||||
_connector=new SelectChannelConnector();
|
||||
|
||||
_connector.setPort(0);
|
||||
_server.setConnectors(new Connector[] { _connector });
|
||||
}
|
||||
|
||||
protected void startServer() throws Exception
|
||||
{
|
||||
newServer();
|
||||
_server.setHandler(new AbstractHandler()
|
||||
{
|
||||
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response)
|
||||
throws IOException, ServletException
|
||||
{
|
||||
int i=0;
|
||||
try
|
||||
{
|
||||
baseRequest.setHandled(true);
|
||||
response.setStatus(200);
|
||||
_count.incrementAndGet();
|
||||
|
||||
if (request.getMethod().equalsIgnoreCase("GET"))
|
||||
{
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
buffer.append("<hello>\r\n");
|
||||
for (; i<100; i++)
|
||||
{
|
||||
buffer.append(" <world>"+i+"</world>\r\n");
|
||||
}
|
||||
buffer.append("</hello>\r\n");
|
||||
|
||||
byte[] buff = buffer.toString().getBytes();
|
||||
response.setContentLength(buff.length);
|
||||
|
||||
buffer.append("extra data");
|
||||
buff = buffer.toString().getBytes();
|
||||
|
||||
OutputStream out = response.getOutputStream();
|
||||
out.write(buff, 0, buff.length);
|
||||
out.flush();
|
||||
}
|
||||
else
|
||||
{
|
||||
response.setContentType(request.getContentType());
|
||||
int size=request.getContentLength();
|
||||
ByteArrayOutputStream bout = new ByteArrayOutputStream(size>0?size:32768);
|
||||
IO.copy(request.getInputStream(),bout);
|
||||
response.getOutputStream().write(bout.toByteArray());
|
||||
}
|
||||
}
|
||||
catch(IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
}
|
||||
catch(Throwable e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
throw new ServletException(e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
// System.err.println("HANDLED "+i);
|
||||
}
|
||||
}
|
||||
});
|
||||
_server.start();
|
||||
_port=_connector.getLocalPort();
|
||||
}
|
||||
|
||||
private void stopServer() throws Exception
|
||||
{
|
||||
_server.stop();
|
||||
}
|
||||
|
||||
}
|
@ -8,8 +8,7 @@ import javax.servlet.ServletResponse;
|
||||
import javax.servlet.ServletResponseWrapper;
|
||||
|
||||
import org.mortbay.log.Log;
|
||||
|
||||
|
||||
import org.mortbay.log.Logger;
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
@ -19,6 +18,8 @@ import org.mortbay.log.Log;
|
||||
*/
|
||||
public class Jetty6Continuation implements ContinuationFilter.FilteredContinuation
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(Jetty6Continuation.class.getName());
|
||||
|
||||
// Exception reused for all continuations
|
||||
// Turn on debug in ContinuationFilter to see real stack trace.
|
||||
private final static ContinuationThrowable __exception = new ContinuationThrowable();
|
||||
@ -40,7 +41,7 @@ public class Jetty6Continuation implements ContinuationFilter.FilteredContinuati
|
||||
{
|
||||
if (!ContinuationFilter._initialized)
|
||||
{
|
||||
Log.warn("!ContinuationFilter installed");
|
||||
LOG.warn("!ContinuationFilter installed",null,null);
|
||||
throw new IllegalStateException("!ContinuationFilter installed");
|
||||
}
|
||||
_request=request;
|
||||
|
@ -25,6 +25,7 @@ import java.util.Set;
|
||||
import org.eclipse.jetty.deploy.graph.Graph;
|
||||
import org.eclipse.jetty.deploy.graph.Node;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
|
||||
/**
|
||||
* The lifecycle of an App in the {@link DeploymentManager}.
|
||||
@ -36,6 +37,8 @@ import org.eclipse.jetty.util.log.Log;
|
||||
*/
|
||||
public class AppLifeCycle extends Graph
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(AppLifeCycle.class);
|
||||
|
||||
private static final String ALL_NODES = "*";
|
||||
|
||||
public static interface Binding
|
||||
@ -175,8 +178,8 @@ public class AppLifeCycle extends Graph
|
||||
{
|
||||
for (Binding binding : getBindings(node))
|
||||
{
|
||||
if (Log.isDebugEnabled())
|
||||
Log.debug("Calling " + binding.getClass().getName()+" for "+app);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Calling " + binding.getClass().getName()+" for "+app);
|
||||
binding.processBinding(node,app);
|
||||
}
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ import org.eclipse.jetty.util.AttributesMap;
|
||||
import org.eclipse.jetty.util.Scanner;
|
||||
import org.eclipse.jetty.util.component.AbstractLifeCycle;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.util.resource.Resource;
|
||||
import org.eclipse.jetty.xml.XmlConfiguration;
|
||||
|
||||
@ -75,6 +76,8 @@ import org.eclipse.jetty.xml.XmlConfiguration;
|
||||
@Deprecated
|
||||
public class ContextDeployer extends AbstractLifeCycle
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(ContextDeployer.class);
|
||||
|
||||
private int _scanInterval=10;
|
||||
private Scanner _scanner;
|
||||
private ScannerListener _scannerListener;
|
||||
@ -130,7 +133,7 @@ public class ContextDeployer extends AbstractLifeCycle
|
||||
*/
|
||||
public ContextDeployer()
|
||||
{
|
||||
Log.warn("ContextDeployer is deprecated. Use ContextProvider");
|
||||
LOG.warn("ContextDeployer is deprecated. Use ContextProvider");
|
||||
_scanner=new Scanner();
|
||||
}
|
||||
|
||||
@ -344,7 +347,7 @@ public class ContextDeployer extends AbstractLifeCycle
|
||||
private void deploy(String filename) throws Exception
|
||||
{
|
||||
ContextHandler context=createContext(filename);
|
||||
Log.info("Deploy "+filename+" -> "+ context);
|
||||
LOG.info("Deploy "+filename+" -> "+ context);
|
||||
_contexts.addHandler(context);
|
||||
_currentDeployments.put(filename,context);
|
||||
if (_contexts.isStarted())
|
||||
@ -355,7 +358,7 @@ public class ContextDeployer extends AbstractLifeCycle
|
||||
private void undeploy(String filename) throws Exception
|
||||
{
|
||||
ContextHandler context=(ContextHandler)_currentDeployments.get(filename);
|
||||
Log.info("Undeploy "+filename+" -> "+context);
|
||||
LOG.info("Undeploy "+filename+" -> "+context);
|
||||
if (context==null)
|
||||
return;
|
||||
context.stop();
|
||||
@ -402,7 +405,7 @@ public class ContextDeployer extends AbstractLifeCycle
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.warn(e);
|
||||
LOG.warn(e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -37,6 +37,7 @@ import org.eclipse.jetty.server.handler.ContextHandlerCollection;
|
||||
import org.eclipse.jetty.util.AttributesMap;
|
||||
import org.eclipse.jetty.util.component.AggregateLifeCycle;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
|
||||
/**
|
||||
* The Deployment Manager.
|
||||
@ -54,6 +55,8 @@ import org.eclipse.jetty.util.log.Log;
|
||||
*/
|
||||
public class DeploymentManager extends AggregateLifeCycle
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(DeploymentManager.class);
|
||||
|
||||
/**
|
||||
* Represents a single tracked app within the deployment manager.
|
||||
*/
|
||||
@ -123,7 +126,7 @@ public class DeploymentManager extends AggregateLifeCycle
|
||||
*/
|
||||
public void addApp(App app)
|
||||
{
|
||||
Log.info("Deployable added: " + app.getOriginId());
|
||||
LOG.info("Deployable added: " + app.getOriginId());
|
||||
AppEntry entry = new AppEntry();
|
||||
entry.app = app;
|
||||
entry.setLifeCycleNode(_lifecycle.getNodeByName("undeployed"));
|
||||
@ -205,7 +208,7 @@ public class DeploymentManager extends AggregateLifeCycle
|
||||
{
|
||||
if (_useStandardBindings)
|
||||
{
|
||||
Log.debug("DeploymentManager using standard bindings");
|
||||
LOG.debug("DeploymentManager using standard bindings");
|
||||
addLifeCycleBinding(new StandardDeployer());
|
||||
addLifeCycleBinding(new StandardStarter());
|
||||
addLifeCycleBinding(new StandardStopper());
|
||||
@ -232,7 +235,7 @@ public class DeploymentManager extends AggregateLifeCycle
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.warn("Unable to start AppProvider",e);
|
||||
LOG.warn("Unable to start AppProvider",e);
|
||||
}
|
||||
}
|
||||
super.doStop();
|
||||
@ -389,7 +392,7 @@ public class DeploymentManager extends AggregateLifeCycle
|
||||
if (! AppLifeCycle.UNDEPLOYED.equals(entry.lifecyleNode.getName()))
|
||||
requestAppGoal(entry.app,AppLifeCycle.UNDEPLOYED);
|
||||
it.remove();
|
||||
Log.info("Deployable removed: " + entry.app);
|
||||
LOG.info("Deployable removed: " + entry.app);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -408,7 +411,7 @@ public class DeploymentManager extends AggregateLifeCycle
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.warn("Unable to stop Provider",e);
|
||||
LOG.warn("Unable to stop Provider",e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -478,7 +481,7 @@ public class DeploymentManager extends AggregateLifeCycle
|
||||
while (it.hasNext())
|
||||
{
|
||||
Node node = it.next();
|
||||
Log.debug("Executing Node: " + node);
|
||||
LOG.debug("Executing Node: " + node);
|
||||
_lifecycle.runBindings(node,appentry.app,this);
|
||||
appentry.setLifeCycleNode(node);
|
||||
}
|
||||
@ -486,7 +489,7 @@ public class DeploymentManager extends AggregateLifeCycle
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
Log.warn("Unable to reach node goal: " + nodeName,t);
|
||||
LOG.warn("Unable to reach node goal: " + nodeName,t);
|
||||
}
|
||||
}
|
||||
|
||||
@ -544,13 +547,13 @@ public class DeploymentManager extends AggregateLifeCycle
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.warn("Unable to start AppProvider",e);
|
||||
LOG.warn("Unable to start AppProvider",e);
|
||||
}
|
||||
}
|
||||
|
||||
public void undeployAll()
|
||||
{
|
||||
Log.info("Undeploy All");
|
||||
LOG.info("Undeploy All");
|
||||
for (AppEntry appentry : _apps)
|
||||
{
|
||||
requestAppGoal(appentry,"undeployed");
|
||||
|
@ -24,6 +24,7 @@ import org.eclipse.jetty.util.AttributesMap;
|
||||
import org.eclipse.jetty.util.URIUtil;
|
||||
import org.eclipse.jetty.util.component.AbstractLifeCycle;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.util.resource.Resource;
|
||||
import org.eclipse.jetty.webapp.WebAppContext;
|
||||
|
||||
@ -52,6 +53,8 @@ import org.eclipse.jetty.webapp.WebAppContext;
|
||||
@SuppressWarnings("unchecked")
|
||||
public class WebAppDeployer extends AbstractLifeCycle
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(WebAppDeployer.class);
|
||||
|
||||
private HandlerCollection _contexts;
|
||||
private String _webAppDir;
|
||||
private String _defaultsDescriptor;
|
||||
@ -65,7 +68,7 @@ public class WebAppDeployer extends AbstractLifeCycle
|
||||
|
||||
public WebAppDeployer()
|
||||
{
|
||||
Log.warn("WebAppDeployer is deprecated. Use WebAppProvider");
|
||||
LOG.warn("WebAppDeployer is deprecated. Use WebAppProvider");
|
||||
}
|
||||
|
||||
public String[] getConfigurationClasses()
|
||||
@ -254,13 +257,13 @@ public class WebAppDeployer extends AbstractLifeCycle
|
||||
|
||||
if (path != null && path.equals(app.getFile().getCanonicalPath()))
|
||||
{
|
||||
Log.debug("Already deployed:"+path);
|
||||
LOG.debug("Already deployed:"+path);
|
||||
continue files;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.ignore(e);
|
||||
LOG.ignore(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -19,9 +19,12 @@ import org.eclipse.jetty.deploy.App;
|
||||
import org.eclipse.jetty.deploy.AppLifeCycle;
|
||||
import org.eclipse.jetty.deploy.graph.Node;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
|
||||
public class DebugBinding implements AppLifeCycle.Binding
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(DebugBinding.class);
|
||||
|
||||
final String[] _targets;
|
||||
|
||||
public DebugBinding(String target)
|
||||
@ -41,6 +44,6 @@ public class DebugBinding implements AppLifeCycle.Binding
|
||||
|
||||
public void processBinding(Node node, App app) throws Exception
|
||||
{
|
||||
Log.info("processBinding {} {}",node,app.getContextHandler());
|
||||
LOG.info("processBinding {} {}",node,app.getContextHandler());
|
||||
}
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ import org.eclipse.jetty.deploy.AppLifeCycle;
|
||||
import org.eclipse.jetty.deploy.graph.Node;
|
||||
import org.eclipse.jetty.server.handler.ContextHandler;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.util.resource.FileResource;
|
||||
import org.eclipse.jetty.util.resource.Resource;
|
||||
import org.eclipse.jetty.webapp.WebAppContext;
|
||||
@ -43,6 +44,8 @@ import org.eclipse.jetty.xml.XmlConfiguration;
|
||||
*/
|
||||
public class GlobalWebappConfigBinding implements AppLifeCycle.Binding
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(GlobalWebappConfigBinding.class);
|
||||
|
||||
|
||||
private String _jettyXml;
|
||||
|
||||
@ -73,14 +76,14 @@ public class GlobalWebappConfigBinding implements AppLifeCycle.Binding
|
||||
{
|
||||
WebAppContext context = (WebAppContext)handler;
|
||||
|
||||
if (Log.isDebugEnabled())
|
||||
if (LOG.isDebugEnabled())
|
||||
{
|
||||
Log.debug("Binding: Configuring webapp context with global settings from: " + _jettyXml);
|
||||
LOG.debug("Binding: Configuring webapp context with global settings from: " + _jettyXml);
|
||||
}
|
||||
|
||||
if ( _jettyXml == null )
|
||||
{
|
||||
Log.warn("Binding: global context binding is enabled but no jetty-web.xml file has been registered");
|
||||
LOG.warn("Binding: global context binding is enabled but no jetty-web.xml file has been registered");
|
||||
}
|
||||
|
||||
Resource globalContextSettings = Resource.newResource(_jettyXml);
|
||||
@ -93,7 +96,7 @@ public class GlobalWebappConfigBinding implements AppLifeCycle.Binding
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.info("Binding: Unable to locate global webapp context settings: " + _jettyXml);
|
||||
LOG.info("Binding: Unable to locate global webapp context settings: " + _jettyXml);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -23,9 +23,12 @@ import org.eclipse.jetty.server.handler.ContextHandler;
|
||||
import org.eclipse.jetty.server.handler.ContextHandlerCollection;
|
||||
import org.eclipse.jetty.server.handler.HandlerCollection;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
|
||||
public class StandardUndeployer implements AppLifeCycle.Binding
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(StandardUndeployer.class);
|
||||
|
||||
public String[] getBindingTargets()
|
||||
{
|
||||
return new String[]
|
||||
@ -48,13 +51,13 @@ public class StandardUndeployer implements AppLifeCycle.Binding
|
||||
for (int i = 0, n = children.length; i < n; i++)
|
||||
{
|
||||
Handler child = children[i];
|
||||
Log.debug("Child handler: " + child);
|
||||
LOG.debug("Child handler: " + child);
|
||||
if (child.equals(context))
|
||||
{
|
||||
Log.debug("Removing handler: " + child);
|
||||
LOG.debug("Removing handler: " + child);
|
||||
coll.removeHandler(child);
|
||||
child.destroy();
|
||||
Log.debug(String.format("After removal: %d (originally %d)",coll.getHandlers().length,originalCount));
|
||||
LOG.debug(String.format("After removal: %d (originally %d)",coll.getHandlers().length,originalCount));
|
||||
}
|
||||
else if (child instanceof HandlerCollection)
|
||||
{
|
||||
|
@ -27,12 +27,15 @@ import org.eclipse.jetty.deploy.DeploymentManager;
|
||||
import org.eclipse.jetty.util.Scanner;
|
||||
import org.eclipse.jetty.util.component.AbstractLifeCycle;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.util.resource.Resource;
|
||||
|
||||
/**
|
||||
*/
|
||||
public abstract class ScanningAppProvider extends AbstractLifeCycle implements AppProvider
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(ScanningAppProvider.class);
|
||||
|
||||
private Map<String, App> _appMap = new HashMap<String, App>();
|
||||
|
||||
private DeploymentManager _deploymentManager;
|
||||
@ -96,14 +99,14 @@ public abstract class ScanningAppProvider extends AbstractLifeCycle implements A
|
||||
@Override
|
||||
protected void doStart() throws Exception
|
||||
{
|
||||
if (Log.isDebugEnabled()) Log.debug(this.getClass().getSimpleName() + ".doStart()");
|
||||
if (LOG.isDebugEnabled()) LOG.debug(this.getClass().getSimpleName() + ".doStart()");
|
||||
if (_monitoredDir == null)
|
||||
{
|
||||
throw new IllegalStateException("No configuration dir specified");
|
||||
}
|
||||
|
||||
File scandir = _monitoredDir.getFile();
|
||||
Log.info("Deployment monitor " + scandir + " at interval " + _scanInterval);
|
||||
LOG.info("Deployment monitor " + scandir + " at interval " + _scanInterval);
|
||||
_scanner = new Scanner();
|
||||
_scanner.setScanDirs(Collections.singletonList(scandir));
|
||||
_scanner.setScanInterval(_scanInterval);
|
||||
@ -129,7 +132,7 @@ public abstract class ScanningAppProvider extends AbstractLifeCycle implements A
|
||||
/* ------------------------------------------------------------ */
|
||||
protected void fileAdded(String filename) throws Exception
|
||||
{
|
||||
if (Log.isDebugEnabled()) Log.debug("added ",filename);
|
||||
if (LOG.isDebugEnabled()) LOG.debug("added ",filename);
|
||||
App app = ScanningAppProvider.this.createApp(filename);
|
||||
if (app != null)
|
||||
{
|
||||
@ -141,7 +144,7 @@ public abstract class ScanningAppProvider extends AbstractLifeCycle implements A
|
||||
/* ------------------------------------------------------------ */
|
||||
protected void fileChanged(String filename) throws Exception
|
||||
{
|
||||
if (Log.isDebugEnabled()) Log.debug("changed ",filename);
|
||||
if (LOG.isDebugEnabled()) LOG.debug("changed ",filename);
|
||||
App app = _appMap.remove(filename);
|
||||
if (app != null)
|
||||
{
|
||||
@ -158,7 +161,7 @@ public abstract class ScanningAppProvider extends AbstractLifeCycle implements A
|
||||
/* ------------------------------------------------------------ */
|
||||
protected void fileRemoved(String filename) throws Exception
|
||||
{
|
||||
if (Log.isDebugEnabled()) Log.debug("removed ",filename);
|
||||
if (LOG.isDebugEnabled()) LOG.debug("removed ",filename);
|
||||
App app = _appMap.remove(filename);
|
||||
if (app != null)
|
||||
_deploymentManager.removeApp(app);
|
||||
|
@ -25,6 +25,7 @@ import org.eclipse.jetty.toolchain.test.OS;
|
||||
import org.eclipse.jetty.toolchain.test.TestingDir;
|
||||
import org.eclipse.jetty.util.Scanner;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.junit.After;
|
||||
import org.junit.Assume;
|
||||
import org.junit.Before;
|
||||
@ -37,6 +38,8 @@ import org.junit.Test;
|
||||
*/
|
||||
public class ScanningAppProviderRuntimeUpdatesTest
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(ScanningAppProviderRuntimeUpdatesTest.class);
|
||||
|
||||
@Rule
|
||||
public TestingDir testdir = new TestingDir();
|
||||
private static XmlConfiguredJetty jetty;
|
||||
@ -93,7 +96,7 @@ public class ScanningAppProviderRuntimeUpdatesTest
|
||||
}
|
||||
catch(InterruptedException e)
|
||||
{
|
||||
Log.warn(e);
|
||||
LOG.warn(e);
|
||||
}
|
||||
}
|
||||
while(_scans.get()<scan);
|
||||
|
@ -76,7 +76,7 @@
|
||||
<url url="${jetty-orbit-url}/javax.servlet.jsp_${orbit-javax-servlet-jsp-version}.jar" />
|
||||
<url url="${jetty-orbit-url}/javax.servlet.jsp.jstl_${orbit-javax-servlet-jsp-jstl-version}.jar" />
|
||||
<url url="${jetty-orbit-url}/com.sun.el_${orbit-com-sun-el-version}.jar" />
|
||||
<url url="${jetty-orbit-url}/org.apache.jasper.glassfish_${orbit-org-apache-jasper-version}.jar" />
|
||||
<url url="${jetty-orbit-url}/org.apache.jasper.glassfish_${orbit-org-apache-jasper-version}.jar"/>
|
||||
<url url="${jetty-orbit-url}/org.apache.taglibs.standard.glassfish_${orbit-org-apache-taglibs-standard-version}.jar" />
|
||||
<url url="${jetty-orbit-url}/org.objectweb.asm_${orbit-org-objectweb-asm-version}.jar" />
|
||||
<url url="${jetty-orbit-url}/javax.transaction_${orbit-javax-transaction-version}.jar" />
|
||||
@ -127,7 +127,6 @@
|
||||
<include name="org.apache.jasper.glassfish_${orbit-org-apache-jasper-version}.jar" />
|
||||
</fileset>
|
||||
</copy>
|
||||
<copy file="../VERSION.txt" todir="${assembly-directory}" />
|
||||
<chmod dir="${assembly-directory}/bin" perm="755" includes="**/*.sh" />
|
||||
</tasks>
|
||||
</configuration>
|
||||
@ -315,6 +314,16 @@
|
||||
</goals>
|
||||
<configuration>
|
||||
<artifactItems>
|
||||
<artifactItem>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-project</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<classifier>version</classifier>
|
||||
<type>txt</type>
|
||||
<overWrite>true</overWrite>
|
||||
<outputDirectory>${assembly-directory}/</outputDirectory>
|
||||
<destFileName>VERSION.txt</destFileName>
|
||||
</artifactItem>
|
||||
<artifactItem>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-util</artifactId>
|
||||
|
@ -22,6 +22,7 @@ import org.eclipse.jetty.io.EndPoint;
|
||||
import org.eclipse.jetty.io.EofException;
|
||||
import org.eclipse.jetty.io.View;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
@ -34,6 +35,8 @@ import org.eclipse.jetty.util.log.Log;
|
||||
*/
|
||||
public abstract class AbstractGenerator implements Generator
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(AbstractGenerator.class);
|
||||
|
||||
// states
|
||||
public final static int STATE_HEADER = 0;
|
||||
public final static int STATE_CONTENT = 2;
|
||||
@ -111,7 +114,7 @@ public abstract class AbstractGenerator implements Generator
|
||||
_contentLength = HttpTokens.UNKNOWN_CONTENT;
|
||||
_date = null;
|
||||
|
||||
// always return the buffer
|
||||
// always return the body buffer
|
||||
if (_buffer!=null)
|
||||
_buffers.returnBuffer(_buffer);
|
||||
_buffer=null;
|
||||
@ -129,6 +132,22 @@ public abstract class AbstractGenerator implements Generator
|
||||
_method=null;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------------- */
|
||||
public void returnBuffers()
|
||||
{
|
||||
if (_buffer!=null && _buffer.length()==0)
|
||||
{
|
||||
_buffers.returnBuffer(_buffer);
|
||||
_buffer=null;
|
||||
}
|
||||
|
||||
if (_header!=null && _header.length()==0)
|
||||
{
|
||||
_buffers.returnBuffer(_header);
|
||||
_header=null;
|
||||
}
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------------- */
|
||||
public void resetBuffer()
|
||||
{
|
||||
@ -410,8 +429,8 @@ public abstract class AbstractGenerator implements Generator
|
||||
|
||||
if (_contentLength >= 0 && _contentLength != _contentWritten && !_head)
|
||||
{
|
||||
if (Log.isDebugEnabled())
|
||||
Log.debug("ContentLength written=="+_contentWritten+" != contentLength=="+_contentLength);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("ContentLength written=="+_contentWritten+" != contentLength=="+_contentLength);
|
||||
_persistent = false;
|
||||
}
|
||||
}
|
||||
|
@ -73,6 +73,8 @@ public interface Generator
|
||||
void reset(boolean returnBuffers);
|
||||
|
||||
void resetBuffer();
|
||||
|
||||
void returnBuffers();
|
||||
|
||||
void sendError(int code, String reason, String content, boolean close) throws IOException;
|
||||
|
||||
|
@ -46,6 +46,7 @@ import org.eclipse.jetty.util.QuotedStringTokenizer;
|
||||
import org.eclipse.jetty.util.StringMap;
|
||||
import org.eclipse.jetty.util.StringUtil;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
@ -57,7 +58,9 @@ import org.eclipse.jetty.util.log.Log;
|
||||
*
|
||||
*/
|
||||
public class HttpFields
|
||||
{
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(HttpFields.class);
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public static final String __COOKIE_DELIM="\"\\\n\r\t\f\b%+ ;=";
|
||||
public static final TimeZone __GMT = TimeZone.getTimeZone("GMT");
|
||||
@ -244,7 +247,7 @@ public class HttpFields
|
||||
}
|
||||
catch (java.lang.Exception e)
|
||||
{
|
||||
// Log.ignore(e);
|
||||
// LOG.ignore(e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -261,7 +264,7 @@ public class HttpFields
|
||||
}
|
||||
catch (java.lang.Exception e)
|
||||
{
|
||||
// Log.ignore(e);
|
||||
// LOG.ignore(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1100,7 +1103,7 @@ public class HttpFields
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.warn(e);
|
||||
LOG.warn(e);
|
||||
return e.toString();
|
||||
}
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ import org.eclipse.jetty.io.EndPoint;
|
||||
import org.eclipse.jetty.io.EofException;
|
||||
import org.eclipse.jetty.util.StringUtil;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
@ -35,6 +36,8 @@ import org.eclipse.jetty.util.log.Log;
|
||||
*/
|
||||
public class HttpGenerator extends AbstractGenerator
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(HttpGenerator.class);
|
||||
|
||||
// Build cache of response lines for status
|
||||
private static class Status
|
||||
{
|
||||
@ -154,7 +157,7 @@ public class HttpGenerator extends AbstractGenerator
|
||||
|
||||
if (_last || _state==STATE_END)
|
||||
{
|
||||
Log.debug("Ignoring extra content {}",content);
|
||||
LOG.debug("Ignoring extra content {}",content);
|
||||
content.clear();
|
||||
return;
|
||||
}
|
||||
@ -239,7 +242,7 @@ public class HttpGenerator extends AbstractGenerator
|
||||
|
||||
if (_last || _state==STATE_END)
|
||||
{
|
||||
Log.debug("Ignoring extra content {}",Byte.valueOf(b));
|
||||
LOG.debug("Ignoring extra content {}",Byte.valueOf(b));
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -345,7 +348,7 @@ public class HttpGenerator extends AbstractGenerator
|
||||
}
|
||||
catch(InterruptedException e)
|
||||
{
|
||||
Log.debug(e);
|
||||
LOG.debug(e);
|
||||
throw new InterruptedIOException(e.toString());
|
||||
}
|
||||
}
|
||||
@ -912,7 +915,7 @@ public class HttpGenerator extends AbstractGenerator
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
Log.ignore(e);
|
||||
LOG.ignore(e);
|
||||
throw (e instanceof EofException) ? e:new EofException(e);
|
||||
}
|
||||
}
|
||||
|
@ -26,9 +26,12 @@ import org.eclipse.jetty.io.View;
|
||||
import org.eclipse.jetty.io.bio.StreamEndPoint;
|
||||
import org.eclipse.jetty.util.StringUtil;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
|
||||
public class HttpParser implements Parser
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(HttpParser.class);
|
||||
|
||||
// States
|
||||
public static final int STATE_START=-14;
|
||||
public static final int STATE_FIELD0=-13;
|
||||
@ -488,7 +491,7 @@ public class HttpParser implements Parser
|
||||
}
|
||||
catch(NumberFormatException e)
|
||||
{
|
||||
Log.ignore(e);
|
||||
LOG.ignore(e);
|
||||
throw new HttpException(HttpStatus.BAD_REQUEST_400);
|
||||
}
|
||||
if (_contentLength <= 0)
|
||||
@ -930,7 +933,7 @@ public class HttpParser implements Parser
|
||||
}
|
||||
catch(IOException e)
|
||||
{
|
||||
Log.debug(e);
|
||||
LOG.debug(e);
|
||||
throw (e instanceof EofException) ? e:new EofException(e);
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,7 @@
|
||||
package org.eclipse.jetty.http;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URI;
|
||||
|
||||
import org.eclipse.jetty.util.MultiMap;
|
||||
import org.eclipse.jetty.util.StringUtil;
|
||||
@ -96,6 +97,11 @@ public class HttpURI
|
||||
{
|
||||
parse2(raw,offset,length);
|
||||
}
|
||||
|
||||
public HttpURI(URI uri)
|
||||
{
|
||||
parse(uri.toASCIIString());
|
||||
}
|
||||
|
||||
public void parse(String raw)
|
||||
{
|
||||
|
@ -25,6 +25,7 @@ import org.eclipse.jetty.io.BufferCache;
|
||||
import org.eclipse.jetty.io.BufferCache.CachedBuffer;
|
||||
import org.eclipse.jetty.util.StringUtil;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
@ -33,6 +34,8 @@ import org.eclipse.jetty.util.log.Log;
|
||||
*/
|
||||
public class MimeTypes
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(MimeTypes.class);
|
||||
|
||||
public final static String
|
||||
FORM_ENCODED="application/x-www-form-urlencoded",
|
||||
MESSAGE_HTTP="message/http",
|
||||
@ -132,8 +135,8 @@ public class MimeTypes
|
||||
}
|
||||
catch(MissingResourceException e)
|
||||
{
|
||||
Log.warn(e.toString());
|
||||
Log.debug(e);
|
||||
LOG.warn(e.toString());
|
||||
LOG.debug(e);
|
||||
}
|
||||
|
||||
try
|
||||
@ -148,8 +151,8 @@ public class MimeTypes
|
||||
}
|
||||
catch(MissingResourceException e)
|
||||
{
|
||||
Log.warn(e.toString());
|
||||
Log.debug(e);
|
||||
LOG.warn(e.toString());
|
||||
LOG.debug(e);
|
||||
}
|
||||
|
||||
|
||||
|
@ -19,6 +19,7 @@ import java.security.MessageDigest;
|
||||
import org.eclipse.jetty.util.StringUtil;
|
||||
import org.eclipse.jetty.util.TypeUtil;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
@ -37,6 +38,8 @@ import org.eclipse.jetty.util.log.Log;
|
||||
*/
|
||||
public abstract class Credential implements Serializable
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(Credential.class);
|
||||
|
||||
private static final long serialVersionUID = -7760551052768181572L;
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
@ -91,7 +94,7 @@ public abstract class Credential implements Serializable
|
||||
if (credentials instanceof char[])
|
||||
credentials=new String((char[])credentials);
|
||||
if (!(credentials instanceof String) && !(credentials instanceof Password))
|
||||
Log.warn("Can't check " + credentials.getClass() + " against CRYPT");
|
||||
LOG.warn("Can't check " + credentials.getClass() + " against CRYPT");
|
||||
|
||||
String passwd = credentials.toString();
|
||||
return _cooked.equals(UnixCrypt.crypt(passwd, _cooked));
|
||||
@ -172,13 +175,13 @@ public abstract class Credential implements Serializable
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.warn("Can't check " + credentials.getClass() + " against MD5");
|
||||
LOG.warn("Can't check " + credentials.getClass() + " against MD5");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.warn(e);
|
||||
LOG.warn(e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -199,7 +202,7 @@ public abstract class Credential implements Serializable
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.warn(e);
|
||||
LOG.warn(e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -213,7 +216,7 @@ public abstract class Credential implements Serializable
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.warn(e);
|
||||
LOG.warn(e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
@ -48,6 +49,8 @@ import org.eclipse.jetty.util.log.Log;
|
||||
*/
|
||||
public class Password extends Credential
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(Password.class);
|
||||
|
||||
private static final long serialVersionUID = 5062906681431569445L;
|
||||
|
||||
public static final String __OBFUSCATE = "OBF:";
|
||||
@ -210,7 +213,7 @@ public class Password extends Credential
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
Log.warn(Log.EXCEPTION, e);
|
||||
LOG.warn(Log.EXCEPTION, e);
|
||||
}
|
||||
if (passwd == null || passwd.length() == 0) passwd = promptDft;
|
||||
}
|
||||
|
@ -0,0 +1,62 @@
|
||||
// ========================================================================
|
||||
// Copyright (c) Webtide LLC
|
||||
// ------------------------------------------------------------------------
|
||||
// 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.http;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public class HttpURITest
|
||||
{
|
||||
public static final String __input = "http://example.com:8080/path/to/context?parameter=%22value%22#fragment";
|
||||
public static final String __scheme = "http";
|
||||
public static final String __host = "example.com";
|
||||
public static final int __port = 8080;
|
||||
public static final String __path = "/path/to/context";
|
||||
public static final String __query = "parameter=%22value%22";
|
||||
public static final String __fragment = "fragment";
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
@Test
|
||||
public void testFromString() throws Exception
|
||||
{
|
||||
HttpURI uri = new HttpURI(__input);
|
||||
|
||||
assertEquals(__scheme, uri.getScheme());
|
||||
assertEquals(__host,uri.getHost());
|
||||
assertEquals(__port,uri.getPort());
|
||||
assertEquals(__path,uri.getPath());
|
||||
assertEquals(__query,uri.getQuery());
|
||||
assertEquals(__fragment,uri.getFragment());
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
@Test
|
||||
public void testFromURI() throws Exception
|
||||
{
|
||||
HttpURI uri = new HttpURI(new URI(__input));
|
||||
|
||||
assertEquals(__scheme, uri.getScheme());
|
||||
assertEquals(__host,uri.getHost());
|
||||
assertEquals(__port,uri.getPort());
|
||||
assertEquals(__path,uri.getPath());
|
||||
assertEquals(__query,uri.getQuery());
|
||||
assertEquals(__fragment,uri.getFragment());
|
||||
}
|
||||
}
|
@ -19,6 +19,7 @@ import java.io.OutputStream;
|
||||
|
||||
import org.eclipse.jetty.util.TypeUtil;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -26,6 +27,10 @@ import org.eclipse.jetty.util.log.Log;
|
||||
*/
|
||||
public abstract class AbstractBuffer implements Buffer
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(AbstractBuffer.class);
|
||||
|
||||
private final static boolean __boundsChecking = Boolean.getBoolean("org.eclipse.jetty.io.AbstractBuffer.boundsChecking");
|
||||
|
||||
protected final static String
|
||||
__IMMUTABLE = "IMMUTABLE",
|
||||
__READONLY = "READONLY",
|
||||
@ -629,7 +634,7 @@ public abstract class AbstractBuffer implements Buffer
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
Log.warn(e);
|
||||
LOG.warn(e);
|
||||
return new String(asArray(), 0, length());
|
||||
}
|
||||
}
|
||||
|
@ -3,10 +3,13 @@ package org.eclipse.jetty.io;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
|
||||
|
||||
public abstract class AbstractConnection implements Connection
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(AbstractConnection.class);
|
||||
|
||||
private final long _timeStamp;
|
||||
protected final EndPoint _endp;
|
||||
|
||||
@ -40,7 +43,7 @@ public abstract class AbstractConnection implements Connection
|
||||
}
|
||||
catch(IOException e)
|
||||
{
|
||||
Log.ignore(e);
|
||||
LOG.ignore(e);
|
||||
|
||||
try
|
||||
{
|
||||
@ -48,7 +51,7 @@ public abstract class AbstractConnection implements Connection
|
||||
}
|
||||
catch(IOException e2)
|
||||
{
|
||||
Log.ignore(e2);
|
||||
LOG.ignore(e2);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ import java.io.PrintWriter;
|
||||
import java.io.Writer;
|
||||
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
@ -31,6 +32,8 @@ import org.eclipse.jetty.util.log.Log;
|
||||
*/
|
||||
public class UncheckedPrintWriter extends PrintWriter
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(UncheckedPrintWriter.class);
|
||||
|
||||
private boolean _autoFlush = false;
|
||||
private boolean _throwUnchecked=true;
|
||||
|
||||
@ -105,7 +108,7 @@ public class UncheckedPrintWriter extends PrintWriter
|
||||
setError();
|
||||
if (_throwUnchecked)
|
||||
throw new UncheckedIOException(th);
|
||||
Log.debug(th);
|
||||
LOG.debug(th);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
@ -20,6 +20,7 @@ import java.net.Socket;
|
||||
|
||||
import org.eclipse.jetty.util.StringUtil;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -28,6 +29,8 @@ import org.eclipse.jetty.util.log.Log;
|
||||
*/
|
||||
public class SocketEndPoint extends StreamEndPoint
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(SocketEndPoint.class);
|
||||
|
||||
final Socket _socket;
|
||||
final InetSocketAddress _local;
|
||||
final InetSocketAddress _remote;
|
||||
@ -230,7 +233,7 @@ public class SocketEndPoint extends StreamEndPoint
|
||||
}
|
||||
catch(IOException e)
|
||||
{
|
||||
Log.ignore(e);
|
||||
LOG.ignore(e);
|
||||
_socket.close();
|
||||
}
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ import org.eclipse.jetty.io.Buffer;
|
||||
import org.eclipse.jetty.io.EndPoint;
|
||||
import org.eclipse.jetty.util.StringUtil;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
|
||||
/**
|
||||
* Channel End Point.
|
||||
@ -34,6 +35,8 @@ import org.eclipse.jetty.util.log.Log;
|
||||
*/
|
||||
public class ChannelEndPoint implements EndPoint
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(ChannelEndPoint.class);
|
||||
|
||||
protected final ByteChannel _channel;
|
||||
protected final ByteBuffer[] _gather2=new ByteBuffer[2];
|
||||
protected final Socket _socket;
|
||||
@ -188,12 +191,12 @@ public class ChannelEndPoint implements EndPoint
|
||||
}
|
||||
catch (IOException xx)
|
||||
{
|
||||
Log.ignore(xx);
|
||||
LOG.ignore(xx);
|
||||
}
|
||||
|
||||
if (len>0)
|
||||
throw x;
|
||||
Log.ignore(x);
|
||||
LOG.ignore(x);
|
||||
len=-1;
|
||||
}
|
||||
}
|
||||
|
@ -22,9 +22,12 @@ import java.util.List;
|
||||
import org.eclipse.jetty.io.Buffer;
|
||||
import org.eclipse.jetty.io.NetworkTrafficListener;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
|
||||
public class NetworkTrafficSelectChannelEndPoint extends SelectChannelEndPoint
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(NetworkTrafficSelectChannelEndPoint.class);
|
||||
|
||||
private final List<NetworkTrafficListener> listeners;
|
||||
|
||||
public NetworkTrafficSelectChannelEndPoint(SocketChannel channel, SelectorManager.SelectSet selectSet, SelectionKey key, int maxIdleTime, List<NetworkTrafficListener> listeners) throws IOException
|
||||
@ -74,7 +77,7 @@ public class NetworkTrafficSelectChannelEndPoint extends SelectChannelEndPoint
|
||||
}
|
||||
catch (Exception x)
|
||||
{
|
||||
Log.warn(x);
|
||||
LOG.warn(x);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -93,7 +96,7 @@ public class NetworkTrafficSelectChannelEndPoint extends SelectChannelEndPoint
|
||||
}
|
||||
catch (Exception x)
|
||||
{
|
||||
Log.warn(x);
|
||||
LOG.warn(x);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -114,7 +117,7 @@ public class NetworkTrafficSelectChannelEndPoint extends SelectChannelEndPoint
|
||||
}
|
||||
catch (Exception x)
|
||||
{
|
||||
Log.warn(x);
|
||||
LOG.warn(x);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -132,7 +135,7 @@ public class NetworkTrafficSelectChannelEndPoint extends SelectChannelEndPoint
|
||||
}
|
||||
catch (Exception x)
|
||||
{
|
||||
Log.warn(x);
|
||||
LOG.warn(x);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -250,7 +250,7 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements AsyncEndPo
|
||||
public void checkIdleTimestamp(long now)
|
||||
{
|
||||
long idleTimestamp=_idleTimestamp;
|
||||
if (idleTimestamp!=0 && _maxIdleTime!=0 && now>(idleTimestamp+_maxIdleTime))
|
||||
if (idleTimestamp!=0 && _maxIdleTime>0 && now>(idleTimestamp+_maxIdleTime))
|
||||
idleExpired();
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,7 @@ import org.eclipse.jetty.util.thread.Timeout.Task;
|
||||
*/
|
||||
public abstract class SelectorManager extends AbstractLifeCycle implements Dumpable
|
||||
{
|
||||
public static final Logger __log=Log.getLogger("org.eclipse.jetty.io.nio");
|
||||
public static final Logger LOG=Log.getLogger("org.eclipse.jetty.io.nio");
|
||||
|
||||
// TODO Tune these by approx system speed.
|
||||
private static final int __JVMBUG_THRESHHOLD=Integer.getInteger("org.eclipse.jetty.io.nio.JVMBUG_THRESHHOLD",0).intValue();
|
||||
@ -71,6 +71,7 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
|
||||
private int _selectSets=1;
|
||||
private volatile int _set;
|
||||
private boolean _deferringInterestedOps0=true;
|
||||
private int _selectorPriorityDelta=0;
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
@ -178,6 +179,25 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
|
||||
set.wakeup();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @return delta The value to add to the selector thread priority.
|
||||
*/
|
||||
public int getSelectorPriorityDelta()
|
||||
{
|
||||
return _selectorPriorityDelta;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/** Set the selector thread priorty delta.
|
||||
* @param delta The value to add to the selector thread priority.
|
||||
*/
|
||||
public void setSelectorPriorityDelta(int delta)
|
||||
{
|
||||
_selectorPriorityDelta=delta;
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @return the lowResourcesConnections
|
||||
@ -218,17 +238,6 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
|
||||
_lowResourcesMaxIdleTime=(int)lowResourcesMaxIdleTime;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @param acceptorID
|
||||
* @throws IOException
|
||||
*/
|
||||
public void doSelect(int acceptorID) throws IOException
|
||||
{
|
||||
SelectSet[] sets= _selectSet;
|
||||
if (sets!=null && sets.length>acceptorID && sets[acceptorID]!=null)
|
||||
sets[acceptorID].doSelect();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------------- */
|
||||
public abstract boolean dispatch(Runnable task);
|
||||
@ -245,6 +254,59 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
|
||||
_selectSet[i]= new SelectSet(i);
|
||||
|
||||
super.doStart();
|
||||
|
||||
// start a thread to Select
|
||||
for (int i=0;i<getSelectSets();i++)
|
||||
{
|
||||
final int id=i;
|
||||
dispatch(new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
String name=Thread.currentThread().getName();
|
||||
int priority=Thread.currentThread().getPriority();
|
||||
try
|
||||
{
|
||||
SelectSet[] sets=_selectSet;
|
||||
if (sets==null)
|
||||
return;
|
||||
SelectSet set=sets[id];
|
||||
|
||||
Thread.currentThread().setName(name+" Selector"+id);
|
||||
if (getSelectorPriorityDelta()!=0)
|
||||
Thread.currentThread().setPriority(Thread.currentThread().getPriority()+getSelectorPriorityDelta());
|
||||
LOG.debug("Starting {} on {}",Thread.currentThread(),this);
|
||||
while (isRunning())
|
||||
{
|
||||
try
|
||||
{
|
||||
set.doSelect();
|
||||
}
|
||||
catch(ThreadDeath e)
|
||||
{
|
||||
throw e;
|
||||
}
|
||||
catch(IOException e)
|
||||
{
|
||||
LOG.ignore(e);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
LOG.warn(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
LOG.debug("Stopped {} on {}",Thread.currentThread(),this);
|
||||
Thread.currentThread().setName(name);
|
||||
if (getSelectorPriorityDelta()!=0)
|
||||
Thread.currentThread().setPriority(priority);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -297,8 +359,8 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
|
||||
/* ------------------------------------------------------------------------------- */
|
||||
protected void connectionFailed(SocketChannel channel,Throwable ex,Object attachment)
|
||||
{
|
||||
__log.warn(ex+","+channel+","+attachment);
|
||||
__log.debug(ex);
|
||||
LOG.warn(ex+","+channel+","+attachment);
|
||||
LOG.debug(ex);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
@ -449,7 +511,7 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
|
||||
}
|
||||
catch (CancelledKeyException e)
|
||||
{
|
||||
__log.ignore(e);
|
||||
LOG.ignore(e);
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
@ -457,9 +519,9 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
|
||||
throw (ThreadDeath)e;
|
||||
|
||||
if (isRunning())
|
||||
__log.warn(e);
|
||||
LOG.warn(e);
|
||||
else
|
||||
__log.debug(e);
|
||||
LOG.debug(e);
|
||||
|
||||
try
|
||||
{
|
||||
@ -467,7 +529,7 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
|
||||
}
|
||||
catch(IOException e2)
|
||||
{
|
||||
__log.debug(e2);
|
||||
LOG.debug(e2);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -491,7 +553,7 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
|
||||
}
|
||||
catch(InterruptedException e)
|
||||
{
|
||||
__log.ignore(e);
|
||||
LOG.ignore(e);
|
||||
}
|
||||
now=System.currentTimeMillis();
|
||||
}
|
||||
@ -585,14 +647,14 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
|
||||
}
|
||||
catch (CancelledKeyException e)
|
||||
{
|
||||
__log.ignore(e);
|
||||
LOG.ignore(e);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
if (isRunning())
|
||||
__log.warn(e);
|
||||
LOG.warn(e);
|
||||
else
|
||||
__log.ignore(e);
|
||||
LOG.ignore(e);
|
||||
|
||||
try
|
||||
{
|
||||
@ -601,7 +663,7 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
|
||||
}
|
||||
catch(IOException e2)
|
||||
{
|
||||
__log.debug(e2);
|
||||
LOG.debug(e2);
|
||||
}
|
||||
|
||||
if (key != null && !(key.channel() instanceof ServerSocketChannel) && key.isValid())
|
||||
@ -646,13 +708,13 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
|
||||
catch (ClosedSelectorException e)
|
||||
{
|
||||
if (isRunning())
|
||||
__log.warn(e);
|
||||
LOG.warn(e);
|
||||
else
|
||||
__log.ignore(e);
|
||||
LOG.ignore(e);
|
||||
}
|
||||
catch (CancelledKeyException e)
|
||||
{
|
||||
__log.ignore(e);
|
||||
LOG.ignore(e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
@ -687,16 +749,16 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
|
||||
if (now>_log)
|
||||
{
|
||||
if (_paused>0)
|
||||
__log.debug(this+" Busy selector - injecting delay "+_paused+" times");
|
||||
LOG.debug(this+" Busy selector - injecting delay "+_paused+" times");
|
||||
|
||||
if (_jvmFix2>0)
|
||||
__log.debug(this+" JVM BUG(s) - injecting delay"+_jvmFix2+" times");
|
||||
LOG.debug(this+" JVM BUG(s) - injecting delay"+_jvmFix2+" times");
|
||||
|
||||
if (_jvmFix1>0)
|
||||
__log.debug(this+" JVM BUG(s) - recreating selector "+_jvmFix1+" times, cancelled keys "+_jvmFix0+" times");
|
||||
LOG.debug(this+" JVM BUG(s) - recreating selector "+_jvmFix1+" times, cancelled keys "+_jvmFix0+" times");
|
||||
|
||||
else if(__log.isDebugEnabled() && _jvmFix0>0)
|
||||
__log.debug(this+" JVM BUG(s) - cancelled keys "+_jvmFix0+" times");
|
||||
else if(LOG.isDebugEnabled() && _jvmFix0>0)
|
||||
LOG.debug(this+" JVM BUG(s) - cancelled keys "+_jvmFix0+" times");
|
||||
_paused=0;
|
||||
_jvmFix2=0;
|
||||
_jvmFix1=0;
|
||||
@ -720,7 +782,7 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
|
||||
}
|
||||
catch(InterruptedException e)
|
||||
{
|
||||
__log.ignore(e);
|
||||
LOG.ignore(e);
|
||||
}
|
||||
}
|
||||
else if (_jvmBug==__JVMBUG_THRESHHOLD)
|
||||
@ -754,7 +816,7 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
|
||||
if (++_busyKeyCount>__BUSY_KEY && !(busy.channel() instanceof ServerSocketChannel))
|
||||
{
|
||||
final SelectChannelEndPoint endpoint = (SelectChannelEndPoint)busy.attachment();
|
||||
__log.warn("Busy Key "+busy.channel()+" "+endpoint);
|
||||
LOG.warn("Busy Key "+busy.channel()+" "+endpoint);
|
||||
busy.cancel();
|
||||
if (endpoint!=null)
|
||||
{
|
||||
@ -768,7 +830,7 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
__log.ignore(e);
|
||||
LOG.ignore(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -907,7 +969,7 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
__log.ignore(e);
|
||||
LOG.ignore(e);
|
||||
}
|
||||
|
||||
// close endpoints and selector
|
||||
@ -927,7 +989,7 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
|
||||
}
|
||||
catch(IOException e)
|
||||
{
|
||||
__log.ignore(e);
|
||||
LOG.ignore(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -941,7 +1003,7 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
__log.ignore(e);
|
||||
LOG.ignore(e);
|
||||
}
|
||||
_selector=null;
|
||||
}
|
||||
@ -992,7 +1054,7 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
|
||||
}
|
||||
catch(InterruptedException e)
|
||||
{
|
||||
__log.ignore(e);
|
||||
LOG.ignore(e);
|
||||
}
|
||||
AggregateLifeCycle.dump(out,indent,dump);
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ import org.eclipse.jetty.io.Buffers;
|
||||
import org.eclipse.jetty.io.EofException;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
@ -41,6 +42,8 @@ import org.eclipse.jetty.util.log.Logger;
|
||||
*/
|
||||
public class SslSelectChannelEndPoint extends SelectChannelEndPoint
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(SslSelectChannelEndPoint.class);
|
||||
|
||||
public static final Logger __log=Log.getLogger("org.eclipse.jetty.io.nio").getLogger("ssl");
|
||||
|
||||
private static final ByteBuffer[] __NO_BUFFERS={};
|
||||
@ -247,7 +250,7 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint
|
||||
catch(SSLException e)
|
||||
{
|
||||
super.close();
|
||||
Log.ignore(e);
|
||||
LOG.ignore(e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
@ -299,7 +302,7 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint
|
||||
}
|
||||
catch (Exception x)
|
||||
{
|
||||
Log.debug(x);
|
||||
LOG.debug(x);
|
||||
super.close();
|
||||
}
|
||||
}
|
||||
@ -440,7 +443,7 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint
|
||||
{
|
||||
case BUFFER_OVERFLOW:
|
||||
case BUFFER_UNDERFLOW:
|
||||
Log.warn("wrap {}",_result);
|
||||
LOG.warn("wrap {}",_result);
|
||||
case CLOSED:
|
||||
_closing=true;
|
||||
}
|
||||
@ -595,7 +598,7 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint
|
||||
{
|
||||
case BUFFER_OVERFLOW:
|
||||
case BUFFER_UNDERFLOW:
|
||||
Log.warn("unwrap {}",_result);
|
||||
LOG.warn("unwrap {}",_result);
|
||||
case CLOSED:
|
||||
_closing=true;
|
||||
}
|
||||
@ -656,7 +659,7 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint
|
||||
{
|
||||
if (_handshook && !_allowRenegotiate && _channel!=null && _channel.isOpen())
|
||||
{
|
||||
Log.warn("SSL renegotiate denied: "+_channel);
|
||||
LOG.warn("SSL renegotiate denied: "+_channel);
|
||||
super.close();
|
||||
}
|
||||
}
|
||||
@ -760,7 +763,7 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint
|
||||
}
|
||||
catch(SSLException e)
|
||||
{
|
||||
Log.warn(getRemoteAddr() + ":" + getRemotePort() + " " + e);
|
||||
LOG.warn(getRemoteAddr() + ":" + getRemotePort() + " " + e);
|
||||
freeOutBuffer();
|
||||
super.close();
|
||||
throw e;
|
||||
@ -784,7 +787,7 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint
|
||||
// If we are closed, we will never get more, so EOF
|
||||
// else return and we will be tried again
|
||||
// later when more data arriving causes another dispatch.
|
||||
if (Log.isDebugEnabled()) Log.debug("unwrap {}",_result);
|
||||
if (LOG.isDebugEnabled()) LOG.debug("unwrap {}",_result);
|
||||
if(!isOpen())
|
||||
{
|
||||
_inNIOBuffer.clear();
|
||||
@ -802,7 +805,7 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint
|
||||
// return true is some bytes somewhere were moved about.
|
||||
return total_filled>0 ||_result.bytesConsumed()>0 || _result.bytesProduced()>0;
|
||||
default:
|
||||
Log.warn("unwrap "+_result);
|
||||
LOG.warn("unwrap "+_result);
|
||||
throw new IOException(_result.toString());
|
||||
}
|
||||
}
|
||||
@ -854,7 +857,7 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint
|
||||
}
|
||||
catch(SSLException e)
|
||||
{
|
||||
Log.warn(getRemoteAddr()+":"+getRemotePort()+" "+e);
|
||||
LOG.warn(getRemoteAddr()+":"+getRemotePort()+" "+e);
|
||||
super.close();
|
||||
throw e;
|
||||
}
|
||||
@ -891,7 +894,7 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint
|
||||
{
|
||||
case BUFFER_OVERFLOW:
|
||||
case BUFFER_UNDERFLOW:
|
||||
Log.warn("unwrap {}",_result);
|
||||
LOG.warn("unwrap {}",_result);
|
||||
|
||||
case OK:
|
||||
return _result.bytesConsumed();
|
||||
@ -900,7 +903,7 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint
|
||||
return _result.bytesConsumed()>0?_result.bytesConsumed():-1;
|
||||
|
||||
default:
|
||||
Log.warn("wrap "+_result);
|
||||
LOG.warn("wrap "+_result);
|
||||
throw new IOException(_result.toString());
|
||||
}
|
||||
}
|
||||
@ -935,7 +938,7 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint
|
||||
}
|
||||
catch(SSLException e)
|
||||
{
|
||||
Log.warn(getRemoteAddr()+":"+getRemotePort()+" "+e);
|
||||
LOG.warn(getRemoteAddr()+":"+getRemotePort()+" "+e);
|
||||
super.close();
|
||||
throw e;
|
||||
}
|
||||
@ -961,7 +964,7 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint
|
||||
{
|
||||
case BUFFER_OVERFLOW:
|
||||
case BUFFER_UNDERFLOW:
|
||||
Log.warn("unwrap {}",_result);
|
||||
LOG.warn("unwrap {}",_result);
|
||||
|
||||
case OK:
|
||||
return _result.bytesConsumed();
|
||||
@ -970,7 +973,7 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint
|
||||
return _result.bytesConsumed()>0?_result.bytesConsumed():-1;
|
||||
|
||||
default:
|
||||
Log.warn("wrap "+_result);
|
||||
LOG.warn("wrap "+_result);
|
||||
throw new IOException(_result.toString());
|
||||
}
|
||||
}
|
||||
|
@ -34,9 +34,12 @@ import org.eclipse.jetty.security.LoginService;
|
||||
import org.eclipse.jetty.security.Authenticator.AuthConfiguration;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
|
||||
public class JaspiAuthenticatorFactory extends DefaultAuthenticatorFactory
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(JaspiAuthenticatorFactory.class);
|
||||
|
||||
private static String MESSAGE_LAYER = "HTTP";
|
||||
|
||||
private Subject _serviceSubject;
|
||||
@ -114,7 +117,7 @@ public class JaspiAuthenticatorFactory extends DefaultAuthenticatorFactory
|
||||
}
|
||||
catch (AuthException e)
|
||||
{
|
||||
Log.warn(e);
|
||||
LOG.warn(e);
|
||||
}
|
||||
return authenticator;
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ import javax.servlet.http.HttpServletResponse;
|
||||
import org.eclipse.jetty.http.HttpHeaders;
|
||||
import org.eclipse.jetty.http.security.Constraint;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
|
||||
/**
|
||||
* @deprecated use *ServerAuthentication
|
||||
@ -36,6 +37,8 @@ import org.eclipse.jetty.util.log.Log;
|
||||
*/
|
||||
public class BasicAuthModule extends BaseAuthModule
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(BasicAuthModule.class);
|
||||
|
||||
|
||||
private String realmName;
|
||||
|
||||
@ -73,7 +76,7 @@ public class BasicAuthModule extends BaseAuthModule
|
||||
{
|
||||
if (credentials != null)
|
||||
{
|
||||
if (Log.isDebugEnabled()) Log.debug("Credentials: " + credentials);
|
||||
if (LOG.isDebugEnabled()) LOG.debug("Credentials: " + credentials);
|
||||
if (login(clientSubject, credentials, Constraint.__BASIC_AUTH, messageInfo)) { return AuthStatus.SUCCESS; }
|
||||
|
||||
}
|
||||
|
@ -35,6 +35,7 @@ import org.eclipse.jetty.util.QuotedStringTokenizer;
|
||||
import org.eclipse.jetty.util.StringUtil;
|
||||
import org.eclipse.jetty.util.TypeUtil;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
|
||||
/**
|
||||
* @deprecated use *ServerAuthentication
|
||||
@ -42,6 +43,8 @@ import org.eclipse.jetty.util.log.Log;
|
||||
*/
|
||||
public class DigestAuthModule extends BaseAuthModule
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(DigestAuthModule.class);
|
||||
|
||||
|
||||
protected long maxNonceAge = 0;
|
||||
|
||||
@ -88,7 +91,7 @@ public class DigestAuthModule extends BaseAuthModule
|
||||
long timestamp = System.currentTimeMillis();
|
||||
if (credentials != null)
|
||||
{
|
||||
if (Log.isDebugEnabled()) Log.debug("Credentials: " + credentials);
|
||||
if (LOG.isDebugEnabled()) LOG.debug("Credentials: " + credentials);
|
||||
QuotedStringTokenizer tokenizer = new QuotedStringTokenizer(credentials, "=, ", true, false);
|
||||
final Digest digest = new Digest(request.getMethod());
|
||||
String last = null;
|
||||
@ -192,7 +195,7 @@ public class DigestAuthModule extends BaseAuthModule
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.warn(e);
|
||||
LOG.warn(e);
|
||||
}
|
||||
|
||||
for (int i = 0; i < hash.length; i++)
|
||||
@ -229,7 +232,7 @@ public class DigestAuthModule extends BaseAuthModule
|
||||
}
|
||||
|
||||
long age = timestamp - ts;
|
||||
if (Log.isDebugEnabled()) Log.debug("age=" + age);
|
||||
if (LOG.isDebugEnabled()) LOG.debug("age=" + age);
|
||||
|
||||
byte[] hash = null;
|
||||
try
|
||||
@ -241,7 +244,7 @@ public class DigestAuthModule extends BaseAuthModule
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.warn(e);
|
||||
LOG.warn(e);
|
||||
}
|
||||
|
||||
for (int i = 0; i < 16; i++)
|
||||
@ -253,7 +256,7 @@ public class DigestAuthModule extends BaseAuthModule
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.ignore(e);
|
||||
LOG.ignore(e);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
@ -337,7 +340,7 @@ public class DigestAuthModule extends BaseAuthModule
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.warn(e);
|
||||
LOG.warn(e);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -40,6 +40,7 @@ import org.eclipse.jetty.security.authentication.LoginCallbackImpl;
|
||||
import org.eclipse.jetty.util.StringUtil;
|
||||
import org.eclipse.jetty.util.URIUtil;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
|
||||
/**
|
||||
* @deprecated use *ServerAuthentication
|
||||
@ -47,6 +48,8 @@ import org.eclipse.jetty.util.log.Log;
|
||||
*/
|
||||
public class FormAuthModule extends BaseAuthModule
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(FormAuthModule.class);
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public final static String __J_URI = "org.eclipse.jetty.util.URI";
|
||||
|
||||
@ -110,7 +113,7 @@ public class FormAuthModule extends BaseAuthModule
|
||||
{
|
||||
if (!path.startsWith("/"))
|
||||
{
|
||||
Log.warn("form-login-page must start with /");
|
||||
LOG.warn("form-login-page must start with /");
|
||||
path = "/" + path;
|
||||
}
|
||||
_formLoginPage = path;
|
||||
@ -130,7 +133,7 @@ public class FormAuthModule extends BaseAuthModule
|
||||
{
|
||||
if (!path.startsWith("/"))
|
||||
{
|
||||
Log.warn("form-error-page must start with /");
|
||||
LOG.warn("form-error-page must start with /");
|
||||
path = "/" + path;
|
||||
}
|
||||
_formErrorPage = path;
|
||||
@ -177,7 +180,7 @@ public class FormAuthModule extends BaseAuthModule
|
||||
return AuthStatus.SEND_CONTINUE;
|
||||
}
|
||||
// not authenticated
|
||||
if (Log.isDebugEnabled()) Log.debug("Form authentication FAILED for " + StringUtil.printable(username));
|
||||
if (LOG.isDebugEnabled()) LOG.debug("Form authentication FAILED for " + StringUtil.printable(username));
|
||||
if (_formErrorPage == null)
|
||||
{
|
||||
if (response != null) response.sendError(HttpServletResponse.SC_FORBIDDEN);
|
||||
@ -250,7 +253,7 @@ public class FormAuthModule extends BaseAuthModule
|
||||
// // If this credential is still authenticated
|
||||
// if (form_cred._userPrincipal!=null)
|
||||
// {
|
||||
// if(Log.isDebugEnabled())Log.debug("FORM Authenticated for
|
||||
// if(LOG.isDebugEnabled())LOG.debug("FORM Authenticated for
|
||||
// "+form_cred._userPrincipal.getName());
|
||||
// request.setAuthType(Constraint.__FORM_AUTH);
|
||||
// //jaspi
|
||||
@ -273,7 +276,7 @@ public class FormAuthModule extends BaseAuthModule
|
||||
// form_cred._jUserName=form_cred._userPrincipal.getName();
|
||||
// if (cred!=null)
|
||||
// form_cred._jPassword=cred.toString();
|
||||
// if(Log.isDebugEnabled())Log.debug("SSO for
|
||||
// if(LOG.isDebugEnabled())LOG.debug("SSO for
|
||||
// "+form_cred._userPrincipal);
|
||||
//
|
||||
// request.setAuthType(Constraint.__FORM_AUTH);
|
||||
@ -404,7 +407,7 @@ public class FormAuthModule extends BaseAuthModule
|
||||
|
||||
public void valueUnbound(HttpSessionBindingEvent event)
|
||||
{
|
||||
if (Log.isDebugEnabled()) Log.debug("Logout " + _jUserName);
|
||||
if (LOG.isDebugEnabled()) LOG.debug("Logout " + _jUserName);
|
||||
|
||||
// TODO jaspi call cleanSubject()
|
||||
// if (_realm instanceof SSORealm)
|
||||
|
@ -29,6 +29,7 @@ import javax.management.remote.JMXServiceURL;
|
||||
|
||||
import org.eclipse.jetty.util.component.AbstractLifeCycle;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.util.thread.ShutdownThread;
|
||||
|
||||
|
||||
@ -38,6 +39,8 @@ import org.eclipse.jetty.util.thread.ShutdownThread;
|
||||
*/
|
||||
public class ConnectorServer extends AbstractLifeCycle
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(ConnectorServer.class);
|
||||
|
||||
JMXConnectorServer _connectorServer;
|
||||
Registry _registry;
|
||||
|
||||
@ -101,7 +104,7 @@ public class ConnectorServer extends AbstractLifeCycle
|
||||
_connectorServer.start();
|
||||
ShutdownThread.register(0, this);
|
||||
|
||||
Log.info("JMX Remote URL: {}", _connectorServer.getAddress().toString());
|
||||
LOG.info("JMX Remote URL: {}", _connectorServer.getAddress().toString());
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
@ -156,7 +159,7 @@ public class ConnectorServer extends AbstractLifeCycle
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.ignore(ex);
|
||||
LOG.ignore(ex);
|
||||
}
|
||||
}
|
||||
|
||||
@ -180,7 +183,7 @@ public class ConnectorServer extends AbstractLifeCycle
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.ignore(ex);
|
||||
LOG.ignore(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -28,6 +28,8 @@ import java.util.Map;
|
||||
import java.util.MissingResourceException;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.management.Attribute;
|
||||
import javax.management.AttributeList;
|
||||
@ -49,6 +51,7 @@ import org.eclipse.jetty.util.LazyList;
|
||||
import org.eclipse.jetty.util.Loader;
|
||||
import org.eclipse.jetty.util.TypeUtil;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/** ObjectMBean.
|
||||
@ -65,6 +68,8 @@ import org.eclipse.jetty.util.log.Log;
|
||||
*/
|
||||
public class ObjectMBean implements DynamicMBean
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(ObjectMBean.class);
|
||||
|
||||
private static Class[] OBJ_ARG = new Class[]{Object.class};
|
||||
|
||||
protected Object _managed;
|
||||
@ -115,8 +120,8 @@ public class ObjectMBean implements DynamicMBean
|
||||
try
|
||||
{
|
||||
Class mClass = (Object.class.equals(oClass))?oClass=ObjectMBean.class:Loader.loadClass(oClass,mName,true);
|
||||
if (Log.isDebugEnabled())
|
||||
Log.debug("mbeanFor " + o + " mClass=" + mClass);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("mbeanFor " + o + " mClass=" + mClass);
|
||||
|
||||
try
|
||||
{
|
||||
@ -125,7 +130,7 @@ public class ObjectMBean implements DynamicMBean
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
Log.ignore(e);
|
||||
LOG.ignore(e);
|
||||
if (ModelMBean.class.isAssignableFrom(mClass))
|
||||
{
|
||||
mbean=mClass.newInstance();
|
||||
@ -133,30 +138,29 @@ public class ObjectMBean implements DynamicMBean
|
||||
}
|
||||
}
|
||||
|
||||
if (Log.isDebugEnabled())
|
||||
Log.debug("mbeanFor " + o + " is " + mbean);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("mbeanFor " + o + " is " + mbean);
|
||||
return mbean;
|
||||
}
|
||||
catch (ClassNotFoundException e)
|
||||
{
|
||||
// The code below was modified to fix bug 332200.
|
||||
// The issue was caused by additional information
|
||||
// added to the message after the class name when
|
||||
// Jetty is running in Apache Felix.
|
||||
String klass = e.getMessage().split("[ ]", 2)[0];
|
||||
if (klass.endsWith("MBean"))
|
||||
Log.ignore(e);
|
||||
// The code below was modified to fix bugs 332200 and JETTY-1416
|
||||
// The issue was caused by additional information added to the
|
||||
// message after the class name when running in Apache Felix,
|
||||
// as well as before the class name when running in JBoss.
|
||||
if (e.getMessage().contains(mName))
|
||||
LOG.ignore(e);
|
||||
else
|
||||
Log.warn(e);
|
||||
LOG.warn(e);
|
||||
}
|
||||
catch (Error e)
|
||||
{
|
||||
Log.warn(e);
|
||||
LOG.warn(e);
|
||||
mbean = null;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.warn(e);
|
||||
LOG.warn(e);
|
||||
mbean = null;
|
||||
}
|
||||
|
||||
@ -165,7 +169,7 @@ public class ObjectMBean implements DynamicMBean
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.ignore(e);
|
||||
LOG.ignore(e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -242,7 +246,7 @@ public class ObjectMBean implements DynamicMBean
|
||||
|
||||
try
|
||||
{
|
||||
Log.debug(rName);
|
||||
LOG.debug(rName);
|
||||
ResourceBundle bundle = Loader.getResourceBundle(o_class, rName,true,Locale.getDefault());
|
||||
|
||||
|
||||
@ -284,7 +288,7 @@ public class ObjectMBean implements DynamicMBean
|
||||
}
|
||||
catch(MissingResourceException e)
|
||||
{
|
||||
Log.ignore(e);
|
||||
LOG.ignore(e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -298,7 +302,7 @@ public class ObjectMBean implements DynamicMBean
|
||||
}
|
||||
catch(RuntimeException e)
|
||||
{
|
||||
Log.warn(e);
|
||||
LOG.warn(e);
|
||||
throw e;
|
||||
}
|
||||
return _info;
|
||||
@ -351,12 +355,12 @@ public class ObjectMBean implements DynamicMBean
|
||||
}
|
||||
catch (IllegalAccessException e)
|
||||
{
|
||||
Log.warn(Log.EXCEPTION, e);
|
||||
LOG.warn(Log.EXCEPTION, e);
|
||||
throw new AttributeNotFoundException(e.toString());
|
||||
}
|
||||
catch (InvocationTargetException e)
|
||||
{
|
||||
Log.warn(Log.EXCEPTION, e);
|
||||
LOG.warn(Log.EXCEPTION, e);
|
||||
throw new ReflectionException(new Exception(e.getCause()));
|
||||
}
|
||||
}
|
||||
@ -373,7 +377,7 @@ public class ObjectMBean implements DynamicMBean
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.warn(Log.EXCEPTION, e);
|
||||
LOG.warn(Log.EXCEPTION, e);
|
||||
}
|
||||
}
|
||||
return results;
|
||||
@ -385,8 +389,8 @@ public class ObjectMBean implements DynamicMBean
|
||||
if (attr == null)
|
||||
return;
|
||||
|
||||
if (Log.isDebugEnabled())
|
||||
Log.debug("setAttribute " + _managed + ":" +attr.getName() + "=" + attr.getValue());
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("setAttribute " + _managed + ":" +attr.getName() + "=" + attr.getValue());
|
||||
Method setter = (Method) _setters.get(attr.getName());
|
||||
if (setter == null)
|
||||
throw new AttributeNotFoundException(attr.getName());
|
||||
@ -419,12 +423,12 @@ public class ObjectMBean implements DynamicMBean
|
||||
}
|
||||
catch (IllegalAccessException e)
|
||||
{
|
||||
Log.warn(Log.EXCEPTION, e);
|
||||
LOG.warn(Log.EXCEPTION, e);
|
||||
throw new AttributeNotFoundException(e.toString());
|
||||
}
|
||||
catch (InvocationTargetException e)
|
||||
{
|
||||
Log.warn(Log.EXCEPTION, e);
|
||||
LOG.warn(Log.EXCEPTION, e);
|
||||
throw new ReflectionException(new Exception(e.getCause()));
|
||||
}
|
||||
}
|
||||
@ -432,7 +436,7 @@ public class ObjectMBean implements DynamicMBean
|
||||
/* ------------------------------------------------------------ */
|
||||
public AttributeList setAttributes(AttributeList attrs)
|
||||
{
|
||||
Log.debug("setAttributes");
|
||||
LOG.debug("setAttributes");
|
||||
|
||||
AttributeList results = new AttributeList(attrs.size());
|
||||
Iterator iter = attrs.iterator();
|
||||
@ -446,7 +450,7 @@ public class ObjectMBean implements DynamicMBean
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.warn(Log.EXCEPTION, e);
|
||||
LOG.warn(Log.EXCEPTION, e);
|
||||
}
|
||||
}
|
||||
return results;
|
||||
@ -455,8 +459,8 @@ public class ObjectMBean implements DynamicMBean
|
||||
/* ------------------------------------------------------------ */
|
||||
public Object invoke(String name, Object[] params, String[] signature) throws MBeanException, ReflectionException
|
||||
{
|
||||
if (Log.isDebugEnabled())
|
||||
Log.debug("invoke " + name);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("invoke " + name);
|
||||
|
||||
String methodKey = name + "(";
|
||||
if (signature != null)
|
||||
@ -479,17 +483,17 @@ public class ObjectMBean implements DynamicMBean
|
||||
}
|
||||
catch (NoSuchMethodException e)
|
||||
{
|
||||
Log.warn(Log.EXCEPTION, e);
|
||||
LOG.warn(Log.EXCEPTION, e);
|
||||
throw new ReflectionException(e);
|
||||
}
|
||||
catch (IllegalAccessException e)
|
||||
{
|
||||
Log.warn(Log.EXCEPTION, e);
|
||||
LOG.warn(Log.EXCEPTION, e);
|
||||
throw new MBeanException(e);
|
||||
}
|
||||
catch (InvocationTargetException e)
|
||||
{
|
||||
Log.warn(Log.EXCEPTION, e);
|
||||
LOG.warn(Log.EXCEPTION, e);
|
||||
throw new ReflectionException(new Exception(e.getCause()));
|
||||
}
|
||||
finally
|
||||
@ -560,8 +564,8 @@ public class ObjectMBean implements DynamicMBean
|
||||
String uName = name.substring(0, 1).toUpperCase() + name.substring(1);
|
||||
Class oClass = onMBean ? this.getClass() : _managed.getClass();
|
||||
|
||||
if (Log.isDebugEnabled())
|
||||
Log.debug("defineAttribute "+name+" "+onMBean+":"+writable+":"+oClass+":"+description);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("defineAttribute "+name+" "+onMBean+":"+writable+":"+oClass+":"+description);
|
||||
|
||||
Class type = null;
|
||||
Method getter = null;
|
||||
@ -577,13 +581,13 @@ public class ObjectMBean implements DynamicMBean
|
||||
{
|
||||
if (getter != null)
|
||||
{
|
||||
Log.warn("Multiple mbean getters for attr " + name+ " in "+oClass);
|
||||
LOG.warn("Multiple mbean getters for attr " + name+ " in "+oClass);
|
||||
continue;
|
||||
}
|
||||
getter = methods[m];
|
||||
if (type != null && !type.equals(methods[m].getReturnType()))
|
||||
{
|
||||
Log.warn("Type conflict for mbean attr " + name+ " in "+oClass);
|
||||
LOG.warn("Type conflict for mbean attr " + name+ " in "+oClass);
|
||||
continue;
|
||||
}
|
||||
type = methods[m].getReturnType();
|
||||
@ -594,13 +598,13 @@ public class ObjectMBean implements DynamicMBean
|
||||
{
|
||||
if (getter != null)
|
||||
{
|
||||
Log.warn("Multiple mbean getters for attr " + name+ " in "+oClass);
|
||||
LOG.warn("Multiple mbean getters for attr " + name+ " in "+oClass);
|
||||
continue;
|
||||
}
|
||||
getter = methods[m];
|
||||
if (type != null && !type.equals(methods[m].getReturnType()))
|
||||
{
|
||||
Log.warn("Type conflict for mbean attr " + name+ " in "+oClass);
|
||||
LOG.warn("Type conflict for mbean attr " + name+ " in "+oClass);
|
||||
continue;
|
||||
}
|
||||
type = methods[m].getReturnType();
|
||||
@ -611,13 +615,13 @@ public class ObjectMBean implements DynamicMBean
|
||||
{
|
||||
if (setter != null)
|
||||
{
|
||||
Log.warn("Multiple setters for mbean attr " + name+ " in "+oClass);
|
||||
LOG.warn("Multiple setters for mbean attr " + name+ " in "+oClass);
|
||||
continue;
|
||||
}
|
||||
setter = methods[m];
|
||||
if (type != null && !type.equals(methods[m].getParameterTypes()[0]))
|
||||
{
|
||||
Log.warn("Type conflict for mbean attr " + name+ " in "+oClass);
|
||||
LOG.warn("Type conflict for mbean attr " + name+ " in "+oClass);
|
||||
continue;
|
||||
}
|
||||
type = methods[m].getParameterTypes()[0];
|
||||
@ -628,20 +632,20 @@ public class ObjectMBean implements DynamicMBean
|
||||
{
|
||||
if (type==null)
|
||||
{
|
||||
Log.warn("No mbean type for " + name+" on "+_managed.getClass());
|
||||
LOG.warn("No mbean type for " + name+" on "+_managed.getClass());
|
||||
return null;
|
||||
}
|
||||
|
||||
if (type.isPrimitive() && !type.isArray())
|
||||
{
|
||||
Log.warn("Cannot convert mbean primative " + name);
|
||||
LOG.warn("Cannot convert mbean primative " + name);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if (getter == null && setter == null)
|
||||
{
|
||||
Log.warn("No mbean getter or setters found for " + name+ " in "+oClass);
|
||||
LOG.warn("No mbean getter or setters found for " + name+ " in "+oClass);
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -668,7 +672,7 @@ public class ObjectMBean implements DynamicMBean
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.warn(name+": "+metaData, e);
|
||||
LOG.warn(name+": "+metaData, e);
|
||||
throw new IllegalArgumentException(e.toString());
|
||||
}
|
||||
}
|
||||
@ -698,8 +702,8 @@ public class ObjectMBean implements DynamicMBean
|
||||
boolean onMBean= i==0 && ("MBean".equalsIgnoreCase(tokens[0])||"MMBean".equalsIgnoreCase(tokens[0]));
|
||||
boolean convert= i==0 && ("MObject".equalsIgnoreCase(tokens[0])||"MMBean".equalsIgnoreCase(tokens[0]));
|
||||
|
||||
if (Log.isDebugEnabled())
|
||||
Log.debug("defineOperation "+signature+" "+onMBean+":"+impact_name+":"+description);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("defineOperation "+signature+" "+onMBean+":"+impact_name+":"+description);
|
||||
|
||||
Class oClass = onMBean ? this.getClass() : _managed.getClass();
|
||||
|
||||
@ -716,7 +720,7 @@ public class ObjectMBean implements DynamicMBean
|
||||
else if (impact_name.equals("ACTION_INFO"))
|
||||
impact=MBeanOperationInfo.ACTION_INFO;
|
||||
else
|
||||
Log.warn("Unknown impact '"+impact_name+"' for "+signature);
|
||||
LOG.warn("Unknown impact '"+impact_name+"' for "+signature);
|
||||
|
||||
|
||||
// split the signature
|
||||
@ -745,8 +749,8 @@ public class ObjectMBean implements DynamicMBean
|
||||
{
|
||||
String param_desc = bundle.getString(signature + "[" + i + "]");
|
||||
parts=param_desc.split(" *: *",2);
|
||||
if (Log.isDebugEnabled())
|
||||
Log.debug(parts[0]+": "+parts[1]);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug(parts[0]+": "+parts[1]);
|
||||
pInfo[i] = new MBeanParameterInfo(parts[0].trim(), args[i], parts[1].trim());
|
||||
}
|
||||
|
||||
@ -761,7 +765,7 @@ public class ObjectMBean implements DynamicMBean
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.warn("Operation '"+signature+"'", e);
|
||||
LOG.warn("Operation '"+signature+"'", e);
|
||||
throw new IllegalArgumentException(e.toString());
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,7 @@ import javax.sql.DataSource;
|
||||
import org.eclipse.jetty.util.component.AggregateLifeCycle;
|
||||
import org.eclipse.jetty.util.component.Destroyable;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
|
||||
/**
|
||||
* Close a DataSource.
|
||||
@ -18,6 +19,8 @@ import org.eclipse.jetty.util.log.Log;
|
||||
*/
|
||||
public class DataSourceCloser implements Destroyable
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(DataSourceCloser.class);
|
||||
|
||||
final DataSource _datasource;
|
||||
final String _shutdown;
|
||||
|
||||
@ -43,7 +46,7 @@ public class DataSourceCloser implements Destroyable
|
||||
{
|
||||
if (_shutdown!=null)
|
||||
{
|
||||
Log.info("Shutdown datasource {}",_datasource);
|
||||
LOG.info("Shutdown datasource {}",_datasource);
|
||||
Statement stmt = _datasource.getConnection().createStatement();
|
||||
stmt.executeUpdate(_shutdown);
|
||||
stmt.close();
|
||||
@ -51,18 +54,18 @@ public class DataSourceCloser implements Destroyable
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.warn(e);
|
||||
LOG.warn(e);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Method close = _datasource.getClass().getMethod("close", new Class[]{});
|
||||
Log.info("Close datasource {}",_datasource);
|
||||
LOG.info("Close datasource {}",_datasource);
|
||||
close.invoke(_datasource, new Object[]{});
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.warn(e);
|
||||
LOG.warn(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ import javax.naming.NamingException;
|
||||
import javax.naming.spi.ObjectFactory;
|
||||
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
|
||||
|
||||
/** javaURLContextFactory
|
||||
@ -32,16 +33,9 @@ import org.eclipse.jetty.util.log.Log;
|
||||
* <p><h4>Usage</h4>
|
||||
* <pre>
|
||||
*/
|
||||
/*
|
||||
* </pre>
|
||||
*
|
||||
* @see
|
||||
*
|
||||
*
|
||||
* @version 1.0
|
||||
*/
|
||||
public class javaURLContextFactory implements ObjectFactory
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(javaURLContextFactory.class);
|
||||
|
||||
/**
|
||||
* Either return a new context or the resolution of a url.
|
||||
@ -59,14 +53,14 @@ public class javaURLContextFactory implements ObjectFactory
|
||||
// null object means return a root context for doing resolutions
|
||||
if (url == null)
|
||||
{
|
||||
if(Log.isDebugEnabled())Log.debug(">>> new root context requested ");
|
||||
if(LOG.isDebugEnabled())LOG.debug(">>> new root context requested ");
|
||||
return new javaRootURLContext(env);
|
||||
}
|
||||
|
||||
// return the resolution of the url
|
||||
if (url instanceof String)
|
||||
{
|
||||
if(Log.isDebugEnabled())Log.debug(">>> resolution of url "+url+" requested");
|
||||
if(LOG.isDebugEnabled())LOG.debug(">>> resolution of url "+url+" requested");
|
||||
Context rootctx = new javaRootURLContext (env);
|
||||
return rootctx.lookup ((String)url);
|
||||
}
|
||||
@ -74,7 +68,7 @@ public class javaURLContextFactory implements ObjectFactory
|
||||
// return the resolution of at least one of the urls
|
||||
if (url instanceof String[])
|
||||
{
|
||||
if(Log.isDebugEnabled())Log.debug(">>> resolution of array of urls requested");
|
||||
if(LOG.isDebugEnabled())LOG.debug(">>> resolution of array of urls requested");
|
||||
String[] urls = (String[])url;
|
||||
Context rootctx = new javaRootURLContext (env);
|
||||
Object object = null;
|
||||
@ -97,7 +91,7 @@ public class javaURLContextFactory implements ObjectFactory
|
||||
return object;
|
||||
}
|
||||
|
||||
if(Log.isDebugEnabled())Log.debug(">>> No idea what to do, so return a new root context anyway");
|
||||
if(LOG.isDebugEnabled())LOG.debug(">>> No idea what to do, so return a new root context anyway");
|
||||
return new javaRootURLContext (env);
|
||||
}
|
||||
};
|
||||
|
@ -36,6 +36,7 @@ import org.eclipse.jetty.jndi.NamingContext;
|
||||
import org.eclipse.jetty.jndi.NamingUtil;
|
||||
import org.eclipse.jetty.jndi.local.localContextRoot;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
@ -47,6 +48,8 @@ import static org.junit.Assert.fail;
|
||||
*/
|
||||
public class TestJNDI
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(TestJNDI.class);
|
||||
|
||||
static
|
||||
{
|
||||
// NamingUtil.__log.setDebugEnabled(true);
|
||||
@ -115,48 +118,48 @@ public class TestJNDI
|
||||
InitialContext initCtx = new InitialContext();
|
||||
Context sub0 = (Context)initCtx.lookup("java:");
|
||||
|
||||
if(Log.isDebugEnabled())Log.debug("------ Looked up java: --------------");
|
||||
if(LOG.isDebugEnabled())LOG.debug("------ Looked up java: --------------");
|
||||
|
||||
Name n = sub0.getNameParser("").parse("/red/green/");
|
||||
|
||||
if(Log.isDebugEnabled())Log.debug("get(0)="+n.get(0));
|
||||
if(Log.isDebugEnabled())Log.debug("getPrefix(1)="+n.getPrefix(1));
|
||||
if(LOG.isDebugEnabled())LOG.debug("get(0)="+n.get(0));
|
||||
if(LOG.isDebugEnabled())LOG.debug("getPrefix(1)="+n.getPrefix(1));
|
||||
n = n.getSuffix(1);
|
||||
if(Log.isDebugEnabled())Log.debug("getSuffix(1)="+n);
|
||||
if(Log.isDebugEnabled())Log.debug("get(0)="+n.get(0));
|
||||
if(Log.isDebugEnabled())Log.debug("getPrefix(1)="+n.getPrefix(1));
|
||||
if(LOG.isDebugEnabled())LOG.debug("getSuffix(1)="+n);
|
||||
if(LOG.isDebugEnabled())LOG.debug("get(0)="+n.get(0));
|
||||
if(LOG.isDebugEnabled())LOG.debug("getPrefix(1)="+n.getPrefix(1));
|
||||
n = n.getSuffix(1);
|
||||
if(Log.isDebugEnabled())Log.debug("getSuffix(1)="+n);
|
||||
if(Log.isDebugEnabled())Log.debug("get(0)="+n.get(0));
|
||||
if(Log.isDebugEnabled())Log.debug("getPrefix(1)="+n.getPrefix(1));
|
||||
if(LOG.isDebugEnabled())LOG.debug("getSuffix(1)="+n);
|
||||
if(LOG.isDebugEnabled())LOG.debug("get(0)="+n.get(0));
|
||||
if(LOG.isDebugEnabled())LOG.debug("getPrefix(1)="+n.getPrefix(1));
|
||||
n = n.getSuffix(1);
|
||||
if(Log.isDebugEnabled())Log.debug("getSuffix(1)="+n);
|
||||
if(LOG.isDebugEnabled())LOG.debug("getSuffix(1)="+n);
|
||||
|
||||
n = sub0.getNameParser("").parse("pink/purple/");
|
||||
if(Log.isDebugEnabled())Log.debug("get(0)="+n.get(0));
|
||||
if(Log.isDebugEnabled())Log.debug("getPrefix(1)="+n.getPrefix(1));
|
||||
if(LOG.isDebugEnabled())LOG.debug("get(0)="+n.get(0));
|
||||
if(LOG.isDebugEnabled())LOG.debug("getPrefix(1)="+n.getPrefix(1));
|
||||
n = n.getSuffix(1);
|
||||
if(Log.isDebugEnabled())Log.debug("getSuffix(1)="+n);
|
||||
if(Log.isDebugEnabled())Log.debug("get(0)="+n.get(0));
|
||||
if(Log.isDebugEnabled())Log.debug("getPrefix(1)="+n.getPrefix(1));
|
||||
if(LOG.isDebugEnabled())LOG.debug("getSuffix(1)="+n);
|
||||
if(LOG.isDebugEnabled())LOG.debug("get(0)="+n.get(0));
|
||||
if(LOG.isDebugEnabled())LOG.debug("getPrefix(1)="+n.getPrefix(1));
|
||||
|
||||
NamingContext ncontext = (NamingContext)sub0;
|
||||
|
||||
Name nn = ncontext.toCanonicalName(ncontext.getNameParser("").parse("/yellow/blue/"));
|
||||
Log.debug(nn.toString());
|
||||
LOG.debug(nn.toString());
|
||||
assertEquals (2, nn.size());
|
||||
|
||||
nn = ncontext.toCanonicalName(ncontext.getNameParser("").parse("/yellow/blue"));
|
||||
Log.debug(nn.toString());
|
||||
LOG.debug(nn.toString());
|
||||
assertEquals (2, nn.size());
|
||||
|
||||
nn = ncontext.toCanonicalName(ncontext.getNameParser("").parse("/"));
|
||||
if(Log.isDebugEnabled())Log.debug("/ parses as: "+nn+" with size="+nn.size());
|
||||
Log.debug(nn.toString());
|
||||
if(LOG.isDebugEnabled())LOG.debug("/ parses as: "+nn+" with size="+nn.size());
|
||||
LOG.debug(nn.toString());
|
||||
assertEquals (1, nn.size());
|
||||
|
||||
nn = ncontext.toCanonicalName(ncontext.getNameParser("").parse(""));
|
||||
Log.debug(nn.toString());
|
||||
LOG.debug(nn.toString());
|
||||
assertEquals (0, nn.size());
|
||||
|
||||
Context fee = ncontext.createSubcontext("fee");
|
||||
|
@ -1,3 +1,20 @@
|
||||
<!--
|
||||
// ========================================================================
|
||||
// Copyright (c) Webtide LLC
|
||||
//
|
||||
// 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.apache.org/licenses/LICENSE-2.0.txt
|
||||
//
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// ========================================================================
|
||||
-->
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<parent>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
@ -59,25 +76,69 @@
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<forkMode>always</forkMode>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>findbugs-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<onlyAnalyze>org.eclipse.jetty.jmx.*</onlyAnalyze>
|
||||
<onlyAnalyze>org.eclipse.jetty.monitor.*</onlyAnalyze>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-util</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-io</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-http</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-xml</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-client</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-jmx</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-server</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty.toolchain</groupId>
|
||||
<artifactId>jetty-test-helper</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
@ -0,0 +1,189 @@
|
||||
// ========================================================================
|
||||
// Copyright (c) Webtide LLC
|
||||
// ------------------------------------------------------------------------
|
||||
// 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.monitor;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.management.MBeanServerConnection;
|
||||
|
||||
import org.eclipse.jetty.monitor.jmx.MonitorAction;
|
||||
import org.eclipse.jetty.monitor.jmx.MonitorTask;
|
||||
import org.eclipse.jetty.monitor.jmx.ServiceConnection;
|
||||
import org.eclipse.jetty.xml.XmlConfiguration;
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* JMXMonitor
|
||||
*
|
||||
* Performs monitoring of the values of the attributes of MBeans
|
||||
* and executes specified actions as well as sends notifications
|
||||
* of the specified events that have occurred.
|
||||
*/
|
||||
public class JMXMonitor
|
||||
{
|
||||
private static JMXMonitor __monitor = new JMXMonitor();
|
||||
|
||||
private String _serverUrl;
|
||||
private ServiceConnection _serviceConnection;
|
||||
|
||||
private Set<MonitorAction> _actions = new HashSet<MonitorAction>();
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* Constructs a JMXMonitor instance. Used for XML Configuration.
|
||||
*
|
||||
* !! DO NOT INSTANTIATE EXPLICITLY !!
|
||||
*/
|
||||
public JMXMonitor() {}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* Adds monitor actions to the monitor
|
||||
*
|
||||
* @param actions monitor actions to add
|
||||
* @return true if successful
|
||||
*/
|
||||
public boolean addActions(MonitorAction... actions)
|
||||
{
|
||||
return getInstance().add(actions);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* Removes monitor actions from the monitor
|
||||
*
|
||||
* @param actions monitor actions to remove
|
||||
* @return true if successful
|
||||
*/
|
||||
public boolean removeActions(MonitorAction... actions)
|
||||
{
|
||||
return getInstance().remove(actions);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* Sets the JMX server URL
|
||||
*
|
||||
* @param url URL of the JMX server
|
||||
*/
|
||||
public void setUrl(String url)
|
||||
{
|
||||
getInstance().set(url);
|
||||
}
|
||||
|
||||
public MBeanServerConnection getConnection()
|
||||
throws IOException
|
||||
{
|
||||
return getInstance().get();
|
||||
}
|
||||
|
||||
public static JMXMonitor getInstance()
|
||||
{
|
||||
return __monitor;
|
||||
}
|
||||
|
||||
public static boolean addMonitorActions(MonitorAction... actions)
|
||||
{
|
||||
return getInstance().add(actions);
|
||||
}
|
||||
|
||||
public static boolean removeMonitorActions(MonitorAction... actions)
|
||||
{
|
||||
return getInstance().remove(actions);
|
||||
}
|
||||
|
||||
public static void setServiceUrl(String url)
|
||||
{
|
||||
getInstance().set(url);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* Retrieves a connection to JMX service
|
||||
*
|
||||
* @return server connection
|
||||
* @throws IOException
|
||||
*/
|
||||
public static MBeanServerConnection getServiceConnection()
|
||||
throws IOException
|
||||
{
|
||||
return getInstance().getConnection();
|
||||
}
|
||||
|
||||
public static void main(final String args[]) throws Exception
|
||||
{
|
||||
XmlConfiguration.main(args);
|
||||
}
|
||||
|
||||
private synchronized boolean add(MonitorAction... actions)
|
||||
{
|
||||
boolean result = true;
|
||||
|
||||
for (MonitorAction action : actions)
|
||||
{
|
||||
if (!_actions.add(action))
|
||||
{
|
||||
result = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
MonitorTask.schedule(action);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private synchronized boolean remove(MonitorAction... actions)
|
||||
{
|
||||
boolean result = true;
|
||||
|
||||
for (MonitorAction action : actions)
|
||||
{
|
||||
if (!_actions.remove(action))
|
||||
{
|
||||
result = false;
|
||||
}
|
||||
|
||||
MonitorTask.cancel(action);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private synchronized void set(String url)
|
||||
{
|
||||
_serverUrl = url;
|
||||
|
||||
if (_serviceConnection != null)
|
||||
{
|
||||
_serviceConnection.disconnect();
|
||||
_serviceConnection = null;
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized MBeanServerConnection get()
|
||||
throws IOException
|
||||
{
|
||||
if (_serviceConnection == null)
|
||||
{
|
||||
_serviceConnection = new ServiceConnection(_serverUrl);
|
||||
_serviceConnection.connect();
|
||||
}
|
||||
|
||||
return _serviceConnection.getConnection();
|
||||
}
|
||||
}
|
@ -23,15 +23,20 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.jetty.monitor.thread.ThreadMonitorException;
|
||||
import org.eclipse.jetty.monitor.thread.ThreadMonitorInfo;
|
||||
import org.eclipse.jetty.util.component.AbstractLifeCycle;
|
||||
import org.eclipse.jetty.util.component.Dumpable;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public class ThreadMonitor extends AbstractLifeCycle implements Runnable
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(ThreadMonitor.class);
|
||||
|
||||
private int _scanInterval;
|
||||
private int _logInterval;
|
||||
private int _busyThreshold;
|
||||
@ -296,7 +301,7 @@ public class ThreadMonitor extends AbstractLifeCycle implements Runnable
|
||||
_runner.setDaemon(true);
|
||||
_runner.start();
|
||||
|
||||
Log.info("Thread Monitor started successfully");
|
||||
LOG.info("Thread Monitor started successfully");
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
@ -395,7 +400,7 @@ public class ThreadMonitor extends AbstractLifeCycle implements Runnable
|
||||
}
|
||||
catch (InterruptedException ex)
|
||||
{
|
||||
Log.ignore(ex);
|
||||
LOG.ignore(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -486,7 +491,7 @@ public class ThreadMonitor extends AbstractLifeCycle implements Runnable
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.debug(ex);
|
||||
LOG.debug(ex);
|
||||
}
|
||||
return repeat;
|
||||
}
|
||||
|
@ -0,0 +1,418 @@
|
||||
// ========================================================================
|
||||
// Copyright (c) Webtide LLC
|
||||
// ------------------------------------------------------------------------
|
||||
// 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.monitor.integration;
|
||||
|
||||
import static java.lang.Integer.parseInt;
|
||||
import static java.lang.System.getProperty;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.net.Socket;
|
||||
import java.net.URL;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.management.MBeanServerConnection;
|
||||
import javax.management.MalformedObjectNameException;
|
||||
import javax.management.ObjectName;
|
||||
|
||||
import org.eclipse.jetty.client.ContentExchange;
|
||||
import org.eclipse.jetty.client.HttpClient;
|
||||
import org.eclipse.jetty.http.HttpMethods;
|
||||
import org.eclipse.jetty.http.HttpStatus;
|
||||
import org.eclipse.jetty.io.ByteArrayBuffer;
|
||||
import org.eclipse.jetty.monitor.JMXMonitor;
|
||||
import org.eclipse.jetty.monitor.jmx.EventNotifier;
|
||||
import org.eclipse.jetty.monitor.jmx.EventState;
|
||||
import org.eclipse.jetty.monitor.jmx.EventState.TriggerState;
|
||||
import org.eclipse.jetty.monitor.jmx.EventTrigger;
|
||||
import org.eclipse.jetty.monitor.jmx.MonitorAction;
|
||||
import org.eclipse.jetty.monitor.triggers.AggregateEventTrigger;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
*/
|
||||
public class JavaMonitorAction extends MonitorAction
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(JavaMonitorAction.class);
|
||||
|
||||
private final HttpClient _client;
|
||||
|
||||
private final String _url;
|
||||
private final String _uuid;
|
||||
private final String _appid;
|
||||
|
||||
private String _srvip;
|
||||
private String _session;
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @param notifier
|
||||
* @param pollInterval
|
||||
* @throws Exception
|
||||
* @throws MalformedObjectNameException
|
||||
*/
|
||||
public JavaMonitorAction(EventNotifier notifier, String url, String uuid, String appid, long pollInterval)
|
||||
throws Exception
|
||||
{
|
||||
super(new AggregateEventTrigger(),notifier,pollInterval);
|
||||
|
||||
_url = url;
|
||||
_uuid = uuid;
|
||||
_appid = appid;
|
||||
|
||||
_client = new HttpClient();
|
||||
_client.setTimeout(60000);
|
||||
_client.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL);
|
||||
|
||||
try
|
||||
{
|
||||
_client.start();
|
||||
_srvip = getServerIP();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LOG.debug(ex);
|
||||
}
|
||||
|
||||
sendData(new Properties());
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @see org.eclipse.jetty.monitor.jmx.MonitorAction#execute(org.eclipse.jetty.monitor.jmx.EventTrigger, org.eclipse.jetty.monitor.jmx.EventState, long)
|
||||
*/
|
||||
@Override
|
||||
public void execute(EventTrigger trigger, EventState<?> state, long timestamp)
|
||||
{
|
||||
exec(trigger, state, timestamp);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @param trigger
|
||||
* @param state
|
||||
* @param timestamp
|
||||
*/
|
||||
private <T> void exec(EventTrigger trigger, EventState<T> state, long timestamp)
|
||||
{
|
||||
Collection<TriggerState<T>> trs = state.values();
|
||||
|
||||
Properties data = new Properties();
|
||||
for (TriggerState<T> ts : trs)
|
||||
{
|
||||
Object value = ts.getValue();
|
||||
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
buffer.append(value == null ? "" : value.toString());
|
||||
buffer.append("|");
|
||||
buffer.append(getClassID(value));
|
||||
buffer.append("||");
|
||||
buffer.append(ts.getDescription());
|
||||
|
||||
data.setProperty(ts.getID(), buffer.toString());
|
||||
|
||||
try
|
||||
{
|
||||
sendData(data);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LOG.debug(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @param data
|
||||
* @throws Exception
|
||||
*/
|
||||
private void sendData(Properties data)
|
||||
throws Exception
|
||||
{
|
||||
data.put("account", _uuid);
|
||||
data.put("appserver", "Jetty");
|
||||
data.put("localIp", _srvip);
|
||||
if (_appid == null)
|
||||
data.put("lowestPort", getHttpPort());
|
||||
else
|
||||
data.put("lowestPort", _appid);
|
||||
if (_session != null)
|
||||
data.put("session", _session);
|
||||
|
||||
Properties response = sendRequest(data);
|
||||
|
||||
parseResponse(response);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @param request
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
private Properties sendRequest(Properties request)
|
||||
throws Exception
|
||||
{
|
||||
ByteArrayOutputStream reqStream = null;
|
||||
ByteArrayInputStream resStream = null;
|
||||
Properties response = null;
|
||||
|
||||
try {
|
||||
ContentExchange reqEx = new ContentExchange();
|
||||
reqEx.setURL(_url);
|
||||
reqEx.setMethod(HttpMethods.POST);
|
||||
reqEx.addRequestHeader("Connection","close");
|
||||
|
||||
reqStream = new ByteArrayOutputStream();
|
||||
request.storeToXML(reqStream,null);
|
||||
ByteArrayBuffer reqBuff = new ByteArrayBuffer(reqStream.toByteArray());
|
||||
|
||||
reqEx.setRequestContent(reqBuff);
|
||||
_client.send(reqEx);
|
||||
|
||||
reqEx.waitForDone();
|
||||
|
||||
if (reqEx.getResponseStatus() == HttpStatus.OK_200)
|
||||
{
|
||||
response = new Properties();
|
||||
resStream = new ByteArrayInputStream(reqEx.getResponseContentBytes());
|
||||
response.loadFromXML(resStream);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
try
|
||||
{
|
||||
if (reqStream != null)
|
||||
reqStream.close();
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
LOG.ignore(ex);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (resStream != null)
|
||||
resStream.close();
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
LOG.ignore(ex);
|
||||
}
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
private void parseResponse(Properties response)
|
||||
{
|
||||
if (response.get("onhold") != null)
|
||||
throw new Error("Suspended");
|
||||
|
||||
|
||||
if (response.get("session") != null)
|
||||
{
|
||||
_session = (String) response.remove("session");
|
||||
|
||||
AggregateEventTrigger trigger = (AggregateEventTrigger)getTrigger();
|
||||
|
||||
String queryString;
|
||||
ObjectName[] queryResults;
|
||||
for (Map.Entry<Object, Object> entry : response.entrySet())
|
||||
{
|
||||
String[] values = ((String) entry.getValue()).split("\\|");
|
||||
|
||||
queryString = values[0];
|
||||
if (queryString.startsWith("com.javamonitor.openfire"))
|
||||
continue;
|
||||
|
||||
if (queryString.startsWith("com.javamonitor"))
|
||||
{
|
||||
queryString = "org.eclipse.jetty.monitor.integration:type=javamonitortools,id=0";
|
||||
}
|
||||
|
||||
queryResults = null;
|
||||
try
|
||||
{
|
||||
queryResults = queryNames(queryString);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
LOG.debug(e);
|
||||
}
|
||||
catch (MalformedObjectNameException e)
|
||||
{
|
||||
LOG.debug(e);
|
||||
}
|
||||
|
||||
if (queryResults != null)
|
||||
{
|
||||
int idx = 0;
|
||||
for(ObjectName objName : queryResults)
|
||||
{
|
||||
String id = entry.getKey().toString()+(idx == 0 ? "" : ":"+idx);
|
||||
String name = queryString.equals(objName.toString()) ? "" : objName.toString();
|
||||
boolean repeat = Boolean.parseBoolean(values[2]);
|
||||
trigger.add(new JavaMonitorTrigger(objName, values[1], id, name, repeat));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @param value
|
||||
* @return
|
||||
*/
|
||||
private int getClassID(final Object value)
|
||||
{
|
||||
if (value == null)
|
||||
return 0;
|
||||
|
||||
if (value instanceof Byte ||
|
||||
value instanceof Short ||
|
||||
value instanceof Integer ||
|
||||
value instanceof Long)
|
||||
return 1;
|
||||
|
||||
if (value instanceof Float ||
|
||||
value instanceof Double)
|
||||
return 2;
|
||||
|
||||
if (value instanceof Boolean)
|
||||
return 3;
|
||||
|
||||
return 4; // String
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
private String getServerIP()
|
||||
throws Exception
|
||||
{
|
||||
Socket s = null;
|
||||
try {
|
||||
if (getProperty("http.proxyHost") != null)
|
||||
{
|
||||
s = new Socket(getProperty("http.proxyHost"),
|
||||
parseInt(getProperty("http.proxyPort", "80")));
|
||||
}
|
||||
else
|
||||
{
|
||||
int port = 80;
|
||||
|
||||
URL url = new URL(_url);
|
||||
if (url.getPort() != -1) {
|
||||
port = url.getPort();
|
||||
}
|
||||
s = new Socket(url.getHost(), port);
|
||||
}
|
||||
return s.getLocalAddress().getHostAddress();
|
||||
}
|
||||
finally
|
||||
{
|
||||
try
|
||||
{
|
||||
if (s != null)
|
||||
s.close();
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
LOG.ignore(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public Integer getHttpPort()
|
||||
{
|
||||
Collection<ObjectName> connectors = null;
|
||||
MBeanServerConnection service;
|
||||
try
|
||||
{
|
||||
service = JMXMonitor.getServiceConnection();
|
||||
|
||||
connectors = service.queryNames(new ObjectName("org.eclipse.jetty.nio:type=selectchannelconnector,*"), null);
|
||||
if (connectors != null && connectors.size() > 0)
|
||||
{
|
||||
Integer lowest = Integer.MAX_VALUE;
|
||||
for (final ObjectName connector : connectors) {
|
||||
lowest = (Integer)service.getAttribute(connector, "port");
|
||||
}
|
||||
|
||||
if (lowest < Integer.MAX_VALUE)
|
||||
return lowest;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LOG.debug(ex);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @param param
|
||||
* @return
|
||||
* @throws IOException
|
||||
* @throws NullPointerException
|
||||
* @throws MalformedObjectNameException
|
||||
*/
|
||||
private ObjectName[] queryNames(ObjectName param)
|
||||
throws IOException, MalformedObjectNameException
|
||||
{
|
||||
ObjectName[] result = null;
|
||||
|
||||
MBeanServerConnection connection = JMXMonitor.getServiceConnection();
|
||||
Set names = connection.queryNames(param, null);
|
||||
if (names != null && names.size() > 0)
|
||||
{
|
||||
result = new ObjectName[names.size()];
|
||||
|
||||
int idx = 0;
|
||||
for(Object name : names)
|
||||
{
|
||||
if (name instanceof ObjectName)
|
||||
result[idx++] = (ObjectName)name;
|
||||
else
|
||||
result[idx++] = new ObjectName(name.toString());
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private ObjectName[] queryNames(String param)
|
||||
throws IOException, MalformedObjectNameException
|
||||
{
|
||||
return queryNames(new ObjectName(param));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,270 @@
|
||||
// ========================================================================
|
||||
// Copyright (c) Webtide LLC
|
||||
// ------------------------------------------------------------------------
|
||||
// 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.monitor.integration;
|
||||
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.lang.management.ThreadInfo;
|
||||
import java.lang.management.ThreadMXBean;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.security.Security;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* Derived from the JMX bean classes created by Kees Jan Koster for the java-monitor
|
||||
* J2EE probe http://code.google.com/p/java-monitor-probes/source/browse/.
|
||||
*
|
||||
* @author kjkoster <kjkoster@gmail.com>
|
||||
*/
|
||||
public class JavaMonitorTools
|
||||
{
|
||||
private static final ThreadMXBean threadMXBean = ManagementFactory.getThreadMXBean();
|
||||
|
||||
private static Method findDeadlockMethod = null;
|
||||
|
||||
static
|
||||
{
|
||||
try
|
||||
{
|
||||
findDeadlockMethod = ThreadMXBean.class.getMethod("findDeadlockedThreads");
|
||||
}
|
||||
catch (Exception ignored)
|
||||
{
|
||||
// this is a 1.5 JVM
|
||||
try
|
||||
{
|
||||
findDeadlockMethod = ThreadMXBean.class.getMethod("findMonitorDeadlockedThreads");
|
||||
}
|
||||
catch (SecurityException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch (NoSuchMethodException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private ThreadInfo[] findDeadlock()
|
||||
throws IllegalAccessException, InvocationTargetException
|
||||
{
|
||||
final long[] threadIds = (long[])findDeadlockMethod.invoke(threadMXBean,(Object[])null);
|
||||
|
||||
if (threadIds == null || threadIds.length < 1)
|
||||
{
|
||||
// no deadlock, we're done
|
||||
return null;
|
||||
}
|
||||
|
||||
final ThreadInfo[] threads = threadMXBean.getThreadInfo(threadIds,Integer.MAX_VALUE);
|
||||
return threads;
|
||||
}
|
||||
|
||||
public String getDeadlockStacktraces()
|
||||
{
|
||||
try
|
||||
{
|
||||
final ThreadInfo[] threads = findDeadlock();
|
||||
if (threads == null)
|
||||
{
|
||||
// no deadlock, we're done
|
||||
return null;
|
||||
}
|
||||
|
||||
return stacktraces(threads,0);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return e.getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
private static final int MAX_STACK = 10;
|
||||
|
||||
private String stacktraces(final ThreadInfo[] threads, final int i)
|
||||
{
|
||||
if (i >= threads.length)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
final ThreadInfo thread = threads[i];
|
||||
|
||||
final StringBuilder trace = new StringBuilder();
|
||||
for (int stack_i = 0; stack_i < Math.min(thread.getStackTrace().length,MAX_STACK); stack_i++)
|
||||
{
|
||||
if (stack_i == (MAX_STACK - 1))
|
||||
{
|
||||
trace.append(" ...");
|
||||
}
|
||||
else
|
||||
{
|
||||
trace.append(" at ").append(thread.getStackTrace()[stack_i]).append("\n");
|
||||
}
|
||||
}
|
||||
|
||||
return "\"" + thread.getThreadName() + "\", id " + thread.getThreadId() + " is " + thread.getThreadState() + " on " + thread.getLockName()
|
||||
+ ", owned by " + thread.getLockOwnerName() + ", id " + thread.getLockOwnerId() + "\n" + trace + "\n\n" + stacktraces(threads,i + 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* We keep track of the last time we sampled the thread states.
|
||||
* It is a crude optimization to avoid having to query for the
|
||||
* threads states very often.
|
||||
*/
|
||||
private long lastSampled = 0L;
|
||||
|
||||
private final Map<Thread.State, Integer> states = new HashMap<Thread.State, Integer>();
|
||||
|
||||
public int getThreadsBlocked()
|
||||
{
|
||||
sampleThreads();
|
||||
|
||||
return states.get(Thread.State.BLOCKED);
|
||||
}
|
||||
|
||||
public int getThreadsNew()
|
||||
{
|
||||
sampleThreads();
|
||||
|
||||
return states.get(Thread.State.NEW);
|
||||
}
|
||||
|
||||
public int getThreadsTerminated()
|
||||
{
|
||||
sampleThreads();
|
||||
|
||||
return states.get(Thread.State.TERMINATED);
|
||||
}
|
||||
|
||||
public int getThreadsTimedWaiting()
|
||||
{
|
||||
sampleThreads();
|
||||
|
||||
return states.get(Thread.State.TIMED_WAITING);
|
||||
}
|
||||
|
||||
public int getThreadsWaiting()
|
||||
{
|
||||
sampleThreads();
|
||||
|
||||
return states.get(Thread.State.WAITING);
|
||||
}
|
||||
|
||||
public int getThreadsRunnable()
|
||||
{
|
||||
sampleThreads();
|
||||
|
||||
return states.get(Thread.State.RUNNABLE);
|
||||
}
|
||||
|
||||
private synchronized void sampleThreads()
|
||||
{
|
||||
if ((lastSampled + 50L) < System.currentTimeMillis())
|
||||
{
|
||||
lastSampled = System.currentTimeMillis();
|
||||
for (final Thread.State state : Thread.State.values())
|
||||
{
|
||||
states.put(state,0);
|
||||
}
|
||||
|
||||
for (final ThreadInfo thread : threadMXBean.getThreadInfo(threadMXBean.getAllThreadIds()))
|
||||
{
|
||||
if (thread != null)
|
||||
{
|
||||
final Thread.State state = thread.getThreadState();
|
||||
states.put(state,states.get(state) + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
states.put(Thread.State.TERMINATED,states.get(Thread.State.TERMINATED) + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static final String POLICY = "sun.net.InetAddressCachePolicy";
|
||||
|
||||
public int getCacheSeconds() throws ClassNotFoundException,
|
||||
IllegalAccessException, InvocationTargetException,
|
||||
NoSuchMethodException {
|
||||
final Class policy = Class.forName(POLICY);
|
||||
final Object returnValue = policy.getMethod("get", (Class[]) null)
|
||||
.invoke(null, (Object[]) null);
|
||||
Integer seconds = (Integer) returnValue;
|
||||
|
||||
return seconds.intValue();
|
||||
}
|
||||
|
||||
public int getCacheNegativeSeconds() throws ClassNotFoundException,
|
||||
IllegalAccessException, InvocationTargetException,
|
||||
NoSuchMethodException {
|
||||
final Class policy = Class.forName(POLICY);
|
||||
final Object returnValue = policy.getMethod("getNegative",
|
||||
(Class[]) null).invoke(null, (Object[]) null);
|
||||
Integer seconds = (Integer) returnValue;
|
||||
|
||||
return seconds.intValue();
|
||||
}
|
||||
|
||||
private static final String DEFAULT = "default";
|
||||
|
||||
private static final String SECURITY = "security";
|
||||
|
||||
private static final String SYSTEM = "system";
|
||||
|
||||
private static final String BOTH = "both";
|
||||
|
||||
private static final String SECURITY_TTL = "networkaddress.cache.ttl";
|
||||
|
||||
private static final String SYSTEM_TTL = "sun.net.inetaddr.ttl";
|
||||
|
||||
private static final String SECURITY_NEGATIVE_TTL = "networkaddress.cache.negative.ttl";
|
||||
|
||||
private static final String SYSTEM_NEGATIVE_TTL = "sun.net.inetaddr.negative.ttl";
|
||||
|
||||
public String getCacheTweakedFrom() {
|
||||
if (Security.getProperty(SECURITY_TTL) != null) {
|
||||
if (System.getProperty(SYSTEM_TTL) != null) {
|
||||
return BOTH;
|
||||
}
|
||||
|
||||
return SECURITY;
|
||||
}
|
||||
|
||||
if (System.getProperty(SYSTEM_TTL) != null) {
|
||||
return SYSTEM;
|
||||
}
|
||||
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
public String getCacheNegativeTweakedFrom() {
|
||||
if (Security.getProperty(SECURITY_NEGATIVE_TTL) != null) {
|
||||
if (System.getProperty(SYSTEM_NEGATIVE_TTL) != null) {
|
||||
return BOTH;
|
||||
}
|
||||
|
||||
return SECURITY;
|
||||
}
|
||||
|
||||
if (System.getProperty(SYSTEM_NEGATIVE_TTL) != null) {
|
||||
return SYSTEM;
|
||||
}
|
||||
|
||||
return DEFAULT;
|
||||
}
|
||||
}
|
@ -0,0 +1,77 @@
|
||||
// ========================================================================
|
||||
// Copyright (c) Webtide LLC
|
||||
// ------------------------------------------------------------------------
|
||||
// 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.monitor.integration;
|
||||
|
||||
import javax.management.MalformedObjectNameException;
|
||||
import javax.management.ObjectName;
|
||||
|
||||
import org.eclipse.jetty.monitor.triggers.AttrEventTrigger;
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
*/
|
||||
public class JavaMonitorTrigger <TYPE extends Comparable<TYPE>>
|
||||
extends AttrEventTrigger<TYPE>
|
||||
{
|
||||
private final String _id;
|
||||
private final String _name;
|
||||
private final boolean _dynamic;
|
||||
private int _count;
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @param nameObject
|
||||
* @param attributeName
|
||||
* @param id
|
||||
* @param dynamic
|
||||
* @throws IllegalArgumentException
|
||||
*/
|
||||
public JavaMonitorTrigger(ObjectName nameObject, String attributeName, String id, String name, boolean dynamic)
|
||||
throws IllegalArgumentException
|
||||
{
|
||||
super(nameObject, attributeName);
|
||||
|
||||
_id = id;
|
||||
_name = name;
|
||||
_dynamic = dynamic;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @see org.eclipse.jetty.monitor.triggers.AttrEventTrigger#match(java.lang.Comparable)
|
||||
*/
|
||||
@Override
|
||||
public boolean match(Comparable<TYPE> value)
|
||||
{
|
||||
return _dynamic ? true : (_count++ < 1);
|
||||
}
|
||||
|
||||
protected boolean getSaveAll()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getID()
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNameString()
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
// ========================================================================
|
||||
// Copyright (c) Webtide LLC
|
||||
// ------------------------------------------------------------------------
|
||||
// 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.monitor.jmx;
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* ConsoleNotifier
|
||||
*
|
||||
* Provides a way to output notification messages to the server console
|
||||
*/
|
||||
public class ConsoleNotifier implements EventNotifier
|
||||
{
|
||||
String _messageFormat;
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* Constructs a new notifier with specified format string
|
||||
*
|
||||
* @param format the {@link java.util.Formatter format string}
|
||||
* @throws IllegalArgumentException
|
||||
*/
|
||||
public ConsoleNotifier(String format)
|
||||
throws IllegalArgumentException
|
||||
{
|
||||
if (format == null)
|
||||
throw new IllegalArgumentException("Message format cannot be null");
|
||||
|
||||
_messageFormat = format;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @see org.eclipse.jetty.monitor.jmx.EventNotifier#notify(org.eclipse.jetty.monitor.jmx.EventTrigger, org.eclipse.jetty.monitor.jmx.EventState, long)
|
||||
*/
|
||||
public void notify(EventTrigger trigger, EventState<?> state, long timestamp)
|
||||
{
|
||||
String output = String.format("%1$tF %1$tT.%1$tL:NOTIFY::", timestamp);
|
||||
|
||||
output += String.format(_messageFormat, state);
|
||||
|
||||
System.out.println(output);
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
// ========================================================================
|
||||
// Copyright (c) Webtide LLC
|
||||
// ------------------------------------------------------------------------
|
||||
// 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.monitor.jmx;
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* EventNotifier
|
||||
*
|
||||
* Interface for classes used to send event notifications
|
||||
*/
|
||||
public interface EventNotifier
|
||||
{
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* This method is called when a notification event is received by the containing object
|
||||
*
|
||||
* @param state an {@link org.eclipse.jetty.monitor.jmx.EventState event state}
|
||||
* @param timestamp time stamp of the event
|
||||
*/
|
||||
public void notify(EventTrigger trigger, EventState<?> state, long timestamp);
|
||||
}
|
@ -0,0 +1,202 @@
|
||||
// ========================================================================
|
||||
// Copyright (c) Webtide LLC
|
||||
// ------------------------------------------------------------------------
|
||||
// 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.monitor.jmx;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* EventState
|
||||
*
|
||||
* Holds the state of one or more {@link org.eclipse.jetty.monitor.jmx.EventTrigger event trigger}
|
||||
* instances to be used when sending notifications as well as executing the actions
|
||||
*/
|
||||
public class EventState<TYPE>
|
||||
{
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* State
|
||||
*
|
||||
* Holds the state of a single {@link org.eclipse.jetty.monitor.jmx.EventTrigger event trigger}
|
||||
*/
|
||||
public static class TriggerState<TYPE>
|
||||
{
|
||||
private final String _id;
|
||||
private final String _desc;
|
||||
private final TYPE _value;
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* Construct a trigger state
|
||||
*
|
||||
* @param id unique identification string of the associated event trigger
|
||||
* @param desc description of the associated event trigger
|
||||
* @param value effective value of the MXBean attribute (if applicable)
|
||||
*/
|
||||
public TriggerState(String id, String desc, TYPE value)
|
||||
{
|
||||
_id = id;
|
||||
_desc = desc;
|
||||
_value = value;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* Retrieve the identification string of associated event trigger
|
||||
*
|
||||
* @return unique identification string
|
||||
*/
|
||||
public String getID()
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* Retrieve the description string set by event trigger
|
||||
*
|
||||
* @return description string
|
||||
*/
|
||||
public String getDescription()
|
||||
{
|
||||
return _desc;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* Retrieve the effective value of the MXBean attribute (if applicable)
|
||||
*
|
||||
* @return attribute value
|
||||
*/
|
||||
public TYPE getValue()
|
||||
{
|
||||
return _value;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @return string representation of the state
|
||||
*/
|
||||
public String toString()
|
||||
{
|
||||
StringBuilder result = new StringBuilder();
|
||||
|
||||
result.append(_desc);
|
||||
result.append('=');
|
||||
result.append(_value);
|
||||
|
||||
return result.toString();
|
||||
}
|
||||
}
|
||||
|
||||
protected Map<String, TriggerState<TYPE>> _states;
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* Constructs an empty event state
|
||||
*/
|
||||
public EventState()
|
||||
{
|
||||
_states = new ConcurrentHashMap<String, TriggerState<TYPE>>();
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* Constructs an event state and adds a specified trigger state to it
|
||||
*
|
||||
* @param id unique identification string of the associated event trigger
|
||||
* @param desc description of the associated event trigger
|
||||
* @param value effective value of the MXBean attribute (if applicable)
|
||||
*/
|
||||
public EventState(String id, String desc, TYPE value)
|
||||
{
|
||||
this();
|
||||
|
||||
add(new TriggerState<TYPE>(id, desc, value));
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* Adds a trigger state to the event state
|
||||
*
|
||||
* @param state trigger state to add
|
||||
*/
|
||||
public void add(TriggerState<TYPE> state)
|
||||
{
|
||||
_states.put(state.getID(), state);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* Adds a collection of trigger states to the event state
|
||||
*
|
||||
* @param entries collection of trigger states to add
|
||||
*/
|
||||
public void addAll(Collection<TriggerState<TYPE>> entries)
|
||||
{
|
||||
for (TriggerState<TYPE> entry : entries)
|
||||
{
|
||||
add(entry);
|
||||
}
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* Retrieves a single trigger state
|
||||
*
|
||||
* @param id unique identification string of the event trigger
|
||||
* @return requested trigger state or null if not found
|
||||
*/
|
||||
public TriggerState<TYPE> get(String id)
|
||||
{
|
||||
return _states.get(id);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* Retrieves a collection of all trigger states of the event state
|
||||
*
|
||||
* @return collection of the trigger states
|
||||
*/
|
||||
public Collection<TriggerState<TYPE>> values()
|
||||
{
|
||||
return Collections.unmodifiableCollection(_states.values());
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* Returns a string representation of the event state
|
||||
*
|
||||
* @return string representation of the event state
|
||||
*/
|
||||
public String toString()
|
||||
{
|
||||
int cnt = 0;
|
||||
StringBuilder result = new StringBuilder();
|
||||
|
||||
for (TriggerState<TYPE> value : _states.values())
|
||||
{
|
||||
result.append(cnt++>0?"#":"");
|
||||
result.append(value.toString());
|
||||
}
|
||||
|
||||
return result.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,69 @@
|
||||
// ========================================================================
|
||||
// Copyright (c) Webtide LLC
|
||||
// ------------------------------------------------------------------------
|
||||
// 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.monitor.jmx;
|
||||
|
||||
import static java.util.UUID.randomUUID;
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* EventTrigger
|
||||
*
|
||||
* Abstract base class for all EventTrigger implementations.
|
||||
* Used to determine whether the necessary conditions for
|
||||
* triggering an event are present.
|
||||
*/
|
||||
public abstract class EventTrigger
|
||||
{
|
||||
private final String _id;
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* Construct an event trigger
|
||||
*/
|
||||
public EventTrigger()
|
||||
{
|
||||
_id = randomUUID().toString();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* Retrieve the identification string of the event trigger
|
||||
*
|
||||
* @return unique identification string
|
||||
*/
|
||||
public String getID()
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* Abstract method to verify if the event trigger conditions
|
||||
* are in the appropriate state for an event to be triggered
|
||||
*
|
||||
* @return true to trigger an event
|
||||
*/
|
||||
public abstract boolean match(long timestamp) throws Exception;
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* Retrieve the event state associated with specified invocation
|
||||
* of the event trigger match method
|
||||
*
|
||||
* @param timestamp time stamp associated with invocation
|
||||
* @return event state or null if not found
|
||||
*/
|
||||
public abstract EventState<?> getState(long timestamp);
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
// ========================================================================
|
||||
// Copyright (c) Webtide LLC
|
||||
// ------------------------------------------------------------------------
|
||||
// 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.monitor.jmx;
|
||||
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* ConsoleNotifier
|
||||
*
|
||||
* Provides a way to output notification messages to a log file
|
||||
*/
|
||||
public class LoggingNotifier implements EventNotifier
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(LoggingNotifier.class);
|
||||
|
||||
String _messageFormat;
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* Constructs a new notifier with specified format string
|
||||
*
|
||||
* @param format the {@link java.util.Formatter format string}
|
||||
* @throws IllegalArgumentException
|
||||
*/
|
||||
public LoggingNotifier(String format)
|
||||
throws IllegalArgumentException
|
||||
{
|
||||
if (format == null)
|
||||
throw new IllegalArgumentException("Message format cannot be null");
|
||||
|
||||
_messageFormat = format;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @see org.eclipse.jetty.monitor.jmx.EventNotifier#notify(org.eclipse.jetty.monitor.jmx.EventTrigger, org.eclipse.jetty.monitor.jmx.EventState, long)
|
||||
*/
|
||||
public void notify(EventTrigger trigger, EventState<?> state, long timestamp)
|
||||
{
|
||||
String output = String.format(_messageFormat, state);
|
||||
|
||||
LOG.info(output);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,174 @@
|
||||
// ========================================================================
|
||||
// Copyright (c) Webtide LLC
|
||||
// ------------------------------------------------------------------------
|
||||
// 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.monitor.jmx;
|
||||
|
||||
import static java.util.UUID.randomUUID;
|
||||
|
||||
import java.security.InvalidParameterException;
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* MonitorAction
|
||||
*
|
||||
* Abstract base class for all MonitorAction implementations.
|
||||
* Receives notification when an associated EventTrigger is matched.
|
||||
*/
|
||||
public abstract class MonitorAction
|
||||
extends NotifierGroup
|
||||
{
|
||||
public static final int DEFAULT_POLL_INTERVAL = 5000;
|
||||
|
||||
private final String _id;
|
||||
private final EventTrigger _trigger;
|
||||
private final EventNotifier _notifier;
|
||||
private final long _pollInterval;
|
||||
private final long _pollDelay;
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* Creates a new monitor action
|
||||
*
|
||||
* @param trigger event trigger to be associated with this action
|
||||
* @throws InvalidParameterException
|
||||
*/
|
||||
public MonitorAction(EventTrigger trigger)
|
||||
throws InvalidParameterException
|
||||
{
|
||||
this(trigger, null, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* Creates a new monitor action
|
||||
*
|
||||
* @param trigger event trigger to be associated with this action
|
||||
* @param notifier event notifier to be associated with this action
|
||||
* @throws InvalidParameterException
|
||||
*/
|
||||
public MonitorAction(EventTrigger trigger, EventNotifier notifier)
|
||||
throws InvalidParameterException
|
||||
{
|
||||
this(trigger, notifier, 0);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* Creates a new monitor action
|
||||
*
|
||||
* @param trigger event trigger to be associated with this action
|
||||
* @param notifier event notifier to be associated with this action
|
||||
* @param pollInterval interval for polling of the JMX server
|
||||
* @throws InvalidParameterException
|
||||
*/
|
||||
public MonitorAction(EventTrigger trigger, EventNotifier notifier, long pollInterval)
|
||||
throws InvalidParameterException
|
||||
{
|
||||
this(trigger, notifier, pollInterval, 0);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* Creates a new monitor action
|
||||
*
|
||||
* @param trigger event trigger to be associated with this action
|
||||
* @param notifier event notifier to be associated with this action
|
||||
* @param pollInterval interval for polling of the JMX server
|
||||
* @param pollDelay delay before starting to poll the JMX server
|
||||
* @throws InvalidParameterException
|
||||
*/
|
||||
public MonitorAction(EventTrigger trigger, EventNotifier notifier, long pollInterval, long pollDelay)
|
||||
throws InvalidParameterException
|
||||
{
|
||||
if (trigger == null)
|
||||
throw new InvalidParameterException("Trigger cannot be null");
|
||||
|
||||
_id = randomUUID().toString();
|
||||
_trigger = trigger;
|
||||
_notifier = notifier;
|
||||
_pollInterval = pollInterval > 0 ? pollInterval : DEFAULT_POLL_INTERVAL;
|
||||
_pollDelay = pollDelay > 0 ? pollDelay : _pollInterval;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* Retrieve the identification string of the monitor action
|
||||
*
|
||||
* @return unique identification string
|
||||
*/
|
||||
|
||||
public final String getID()
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* Retrieve the event trigger of the monitor action
|
||||
*
|
||||
* @return associated event trigger
|
||||
*/
|
||||
public EventTrigger getTrigger()
|
||||
{
|
||||
return _trigger;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* Retrieve the poll interval
|
||||
*
|
||||
* @return interval value (in milliseconds)
|
||||
*/
|
||||
public long getPollInterval()
|
||||
{
|
||||
return _pollInterval;
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/** Retrieve the poll delay
|
||||
* @return delay value (in milliseconds)
|
||||
*/
|
||||
public long getPollDelay()
|
||||
{
|
||||
return _pollDelay;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* This method will be called when event trigger associated
|
||||
* with this monitor action matches its conditions.
|
||||
*
|
||||
* @param timestamp time stamp of the event
|
||||
*/
|
||||
public final void doExecute(long timestamp)
|
||||
{
|
||||
EventState<?> state =_trigger.getState(timestamp);
|
||||
if (_notifier != null)
|
||||
_notifier.notify(_trigger, state, timestamp);
|
||||
execute(_trigger, state, timestamp);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* This method will be called to allow subclass to execute
|
||||
* the desired action in response to the event.
|
||||
*
|
||||
* @param trigger event trigger associated with this monitor action
|
||||
* @param state event state associated with current invocation of event trigger
|
||||
* @param timestamp time stamp of the current invocation of event trigger
|
||||
*/
|
||||
public abstract void execute(EventTrigger trigger, EventState<?> state, long timestamp);
|
||||
}
|
@ -0,0 +1,114 @@
|
||||
// ========================================================================
|
||||
// Copyright (c) Webtide LLC
|
||||
// ------------------------------------------------------------------------
|
||||
// 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.monitor.jmx;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.util.thread.ExecutorThreadPool;
|
||||
import org.eclipse.jetty.util.thread.ThreadPool;
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* MonitorTask
|
||||
*
|
||||
* Invokes polling of the JMX server for the MBean attribute values
|
||||
* through executing timer task scheduled using java.util.Timer
|
||||
* at specified poll interval following a specified delay.
|
||||
*/
|
||||
public class MonitorTask extends TimerTask
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(MonitorTask.class);
|
||||
|
||||
private static Timer __timer = new Timer(true);
|
||||
private static ThreadPool _callback = new ExecutorThreadPool(4,64,60,TimeUnit.SECONDS);;
|
||||
private static Map<String,TimerTask> __tasks = new HashMap<String,TimerTask>();
|
||||
|
||||
private final MonitorAction _action;
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* Creates new instance of MonitorTask
|
||||
*
|
||||
* @param action instance of MonitorAction to use
|
||||
*/
|
||||
private MonitorTask(MonitorAction action)
|
||||
{
|
||||
_action = action;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* Schedule new timer task for specified monitor action
|
||||
*
|
||||
* @param action monitor action
|
||||
*/
|
||||
public static void schedule(MonitorAction action)
|
||||
{
|
||||
TimerTask task = new MonitorTask(action);
|
||||
__timer.scheduleAtFixedRate(task,
|
||||
action.getPollDelay(),
|
||||
action.getPollInterval());
|
||||
|
||||
__tasks.put(action.getID(), task);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* Cancel timer task for specified monitor action
|
||||
*
|
||||
* @param action monitor action
|
||||
*/
|
||||
public static void cancel(MonitorAction action)
|
||||
{
|
||||
TimerTask task = __tasks.remove(action.getID());
|
||||
if (task != null)
|
||||
task.cancel();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* This method is invoked when poll interval has elapsed
|
||||
* to check if the event trigger conditions are satisfied
|
||||
* in order to fire event.
|
||||
*
|
||||
* @see java.util.TimerTask#run()
|
||||
*/
|
||||
@Override
|
||||
public final void run()
|
||||
{
|
||||
final long timestamp = System.currentTimeMillis();
|
||||
final EventTrigger trigger = _action.getTrigger();
|
||||
|
||||
_callback.dispatch(new Runnable() {
|
||||
public void run()
|
||||
{
|
||||
try
|
||||
{
|
||||
if(trigger.match(timestamp))
|
||||
_action.doExecute(timestamp);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LOG.debug(ex);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -0,0 +1,115 @@
|
||||
// ========================================================================
|
||||
// Copyright (c) Webtide LLC
|
||||
// ------------------------------------------------------------------------
|
||||
// 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.monitor.jmx;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* NotifierGroup
|
||||
*
|
||||
* This class allows for grouping of the event notifiers
|
||||
*/
|
||||
public class NotifierGroup implements EventNotifier
|
||||
{
|
||||
private Set<EventNotifier> _group;
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* Create a notifier group
|
||||
*/
|
||||
public NotifierGroup()
|
||||
{
|
||||
_group = new HashSet<EventNotifier>();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* Retrieve all event notifier associated with this group
|
||||
*
|
||||
* @return collection of event notifiers
|
||||
*/
|
||||
public Collection<EventNotifier> getNotifiers()
|
||||
{
|
||||
return Collections.unmodifiableSet(_group);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* Add specified event notifier to event notifier group
|
||||
*
|
||||
* @param notifier event notifier to be added
|
||||
* @return true if successful
|
||||
*/
|
||||
public boolean addNotifier(EventNotifier notifier)
|
||||
{
|
||||
return _group.add(notifier);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* Add a collection of event notifiers to event notifier group
|
||||
*
|
||||
* @param notifiers collection of event notifiers to be added
|
||||
* @return true if successful
|
||||
*/
|
||||
public boolean addNotifiers(Collection<EventNotifier> notifiers)
|
||||
{
|
||||
return _group.addAll(notifiers);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* Remove event notifier from event notifier group
|
||||
*
|
||||
* @param notifier event notifier to be removed
|
||||
* @return true if successful
|
||||
*/
|
||||
public boolean removeNotifier(EventNotifier notifier)
|
||||
{
|
||||
return _group.remove(notifier);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* Remove a collection of event notifiers from event notifier group
|
||||
*
|
||||
* @param notifiers collection of event notifiers to be removed
|
||||
* @return true if successful
|
||||
*/
|
||||
public boolean removeNotifiers(Collection<EventNotifier> notifiers)
|
||||
{
|
||||
return _group.removeAll(notifiers);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* Invoke the notify() method of each of the notifiers in group
|
||||
*
|
||||
* @see org.eclipse.jetty.monitor.jmx.EventNotifier#notify(org.eclipse.jetty.monitor.jmx.EventTrigger, org.eclipse.jetty.monitor.jmx.EventState, long)
|
||||
*/
|
||||
public void notify(EventTrigger trigger, EventState<?> state, long timestamp)
|
||||
{
|
||||
for (EventNotifier notifier: _group)
|
||||
{
|
||||
notifier.notify(trigger, state, timestamp);
|
||||
}
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user