From 5223f5b8bd99f971436b43cc777a3ca6b032f64a Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Tue, 7 Apr 2009 14:22:49 +0000 Subject: [PATCH] various debugging logging improvements git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@118 7e9141cc-0065-0410-87d8-b60c137991c4 --- jetty-assembly-descriptor/pom.xml | 10 ------ .../src/main/resources/assemblies/config.xml | 17 --------- .../resources/assemblies/site-component.xml | 14 -------- .../org/eclipse/jetty/io/AbstractBuffers.java | 8 ++--- .../security/ConstraintSecurityHandler.java | 35 +++++++++++++++++-- .../jetty/security/SecurityHandler.java | 26 ++++++++------ .../authentication/LoginAuthenticator.java | 4 +-- .../jetty/server/HandlerContainer.java | 1 + .../java/org/eclipse/jetty/server/Server.java | 2 ++ .../jetty/server/handler/AbstractHandler.java | 14 +++++--- .../handler/AbstractHandlerContainer.java | 31 ++++++++++++++-- .../jetty/server/handler/ContextHandler.java | 2 +- .../jetty/server/handler/HandlerWrapper.java | 9 +++++ .../jetty/server/handler/HotSwapHandler.java | 9 +++++ .../java/org/eclipse/jetty/DemoServer.java | 3 ++ .../util/component/AbstractLifeCycle.java | 8 ++--- .../eclipse/jetty/webapp/WebAppContext.java | 2 +- 17 files changed, 121 insertions(+), 74 deletions(-) delete mode 100644 jetty-assembly-descriptor/pom.xml delete mode 100644 jetty-assembly-descriptor/src/main/resources/assemblies/config.xml delete mode 100644 jetty-assembly-descriptor/src/main/resources/assemblies/site-component.xml diff --git a/jetty-assembly-descriptor/pom.xml b/jetty-assembly-descriptor/pom.xml deleted file mode 100644 index 496c845ab51..00000000000 --- a/jetty-assembly-descriptor/pom.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - org.eclipse.jetty - jetty-project - 7.0.0.M0-SNAPSHOT - - 4.0.0 - jetty-assembly-descriptor - Jetty :: Assembly Descriptor - diff --git a/jetty-assembly-descriptor/src/main/resources/assemblies/config.xml b/jetty-assembly-descriptor/src/main/resources/assemblies/config.xml deleted file mode 100644 index f24602ad402..00000000000 --- a/jetty-assembly-descriptor/src/main/resources/assemblies/config.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - config - false - - jar - - - - src/main/config - - - ** - - - - diff --git a/jetty-assembly-descriptor/src/main/resources/assemblies/site-component.xml b/jetty-assembly-descriptor/src/main/resources/assemblies/site-component.xml deleted file mode 100644 index cc3f9079da9..00000000000 --- a/jetty-assembly-descriptor/src/main/resources/assemblies/site-component.xml +++ /dev/null @@ -1,14 +0,0 @@ - - site-component - - jar - - - - ${basedir} - - src/main/resources/org/eclipse/** - - - - \ No newline at end of file diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/AbstractBuffers.java b/jetty-io/src/main/java/org/eclipse/jetty/io/AbstractBuffers.java index 515ff3fd58c..bf4cf05baf2 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/AbstractBuffers.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/AbstractBuffers.java @@ -22,15 +22,15 @@ import org.eclipse.jetty.util.component.AbstractLifeCycle; */ public abstract class AbstractBuffers extends AbstractLifeCycle implements Buffers { - private int _headerBufferSize=4*1024; + private int _headerBufferSize=6*1024; private int _requestBufferSize=8*1024; - private int _responseBufferSize=24*1024; + private int _responseBufferSize=12*1024; final static private int __HEADER=0; final static private int __REQUEST=1; final static private int __RESPONSE=2; final static private int __OTHER=3; - final private int[] _pool={2,1,1,2}; + final private int[] _pool={2,1,1,1}; private final ThreadLocal _buffers=new ThreadLocal() { @@ -45,8 +45,6 @@ public abstract class AbstractBuffers extends AbstractLifeCycle implements Buffe super(); } - - public Buffer getBuffer(final int size ) { final int set = (size==_headerBufferSize)?__HEADER diff --git a/jetty-security/src/main/java/org/eclipse/jetty/security/ConstraintSecurityHandler.java b/jetty-security/src/main/java/org/eclipse/jetty/security/ConstraintSecurityHandler.java index 361e45e4415..c13ce0cb789 100644 --- a/jetty-security/src/main/java/org/eclipse/jetty/security/ConstraintSecurityHandler.java +++ b/jetty-security/src/main/java/org/eclipse/jetty/security/ConstraintSecurityHandler.java @@ -14,6 +14,7 @@ package org.eclipse.jetty.security; import java.io.IOException; +import java.util.HashSet; import java.util.Map; import java.util.Set; @@ -84,6 +85,20 @@ public class ConstraintSecurityHandler extends SecurityHandler implements Constr return _roles; } + /* ------------------------------------------------------------ */ + /** + * Process the constraints following the combining rules in Servlet 3.0 EA + * spec section 13.7.1 Note that much of the logic is in the RoleInfo class. + * + * @param constraintMappings + * The contraintMappings to set, from which the set of known roles + * is determined. + */ + public void setConstraintMappings(ConstraintMapping[] constraintMappings) + { + setConstraintMappings(constraintMappings,null); + } + /* ------------------------------------------------------------ */ /** * Process the constraints following the combining rules in Servlet 3.0 EA @@ -91,13 +106,29 @@ public class ConstraintSecurityHandler extends SecurityHandler implements Constr * * @param constraintMappings * The contraintMappings to set. - * @param roles + * @param roles The known roles (or null to determine them from the mappings) */ public void setConstraintMappings(ConstraintMapping[] constraintMappings, Set roles) { if (isStarted()) throw new IllegalStateException("Started"); _constraintMappings = constraintMappings; + + if (roles==null) + { + roles = new HashSet(); + for (ConstraintMapping cm : constraintMappings) + { + String[] cmr = cm.getConstraint().getRoles(); + if (cmr!=null) + { + for (String r : cmr) + if (!"*".equals(r)) + roles.add(r); + } + } + } + this._roles = roles; } @@ -110,7 +141,7 @@ public class ConstraintSecurityHandler extends SecurityHandler implements Constr protected void doStart() throws Exception { _constraintMap.clear(); - if (_constraintMappings != null) + if (_constraintMappings!=null) { for (ConstraintMapping mapping : _constraintMappings) { diff --git a/jetty-security/src/main/java/org/eclipse/jetty/security/SecurityHandler.java b/jetty-security/src/main/java/org/eclipse/jetty/security/SecurityHandler.java index 23644067cf8..45fc2937910 100644 --- a/jetty-security/src/main/java/org/eclipse/jetty/security/SecurityHandler.java +++ b/jetty-security/src/main/java/org/eclipse/jetty/security/SecurityHandler.java @@ -300,7 +300,7 @@ public abstract class SecurityHandler extends HandlerWrapper implements Authenti if (_identityService==null) _identityService=findIdentityService(); - if (_identityService==null) + if (_identityService==null && _realmName!=null) _identityService=new DefaultIdentityService(); } @@ -315,23 +315,27 @@ public abstract class SecurityHandler extends HandlerWrapper implements Authenti if (!_loginServiceShared && _loginService instanceof LifeCycle) ((LifeCycle)_loginService).start(); - if (_authenticator==null && _authenticatorFactory!=null) + if (_authenticator==null && _authenticatorFactory!=null && _identityService!=null) { _authenticator=_authenticatorFactory.getAuthenticator(getServer(),ContextHandler.getCurrentContext(),this); if (_authenticator!=null) _authMethod=_authenticator.getAuthMethod(); } - if (_authenticator==null) + if (_authenticator==null) { - Log.warn("No ServerAuthentication for "+this); - throw new IllegalStateException("No ServerAuthentication"); + if (_realmName!=null) + { + Log.warn("No ServerAuthentication for "+this); + throw new IllegalStateException("No ServerAuthentication"); + } + } + else + { + _authenticator.setConfiguration(this); + if (_authenticator instanceof LifeCycle) + ((LifeCycle)_authenticator).start(); } - - _authenticator.setConfiguration(this); - if (_authenticator instanceof LifeCycle) - ((LifeCycle)_authenticator).start(); - super.doStart(); } @@ -384,7 +388,7 @@ public abstract class SecurityHandler extends HandlerWrapper implements Authenti if (handler==null) return; - if (checkSecurity(base_request)) + if (_authenticator!=null && checkSecurity(base_request)) { Object constraintInfo = prepareConstraintInfo(pathInContext, base_request); diff --git a/jetty-security/src/main/java/org/eclipse/jetty/security/authentication/LoginAuthenticator.java b/jetty-security/src/main/java/org/eclipse/jetty/security/authentication/LoginAuthenticator.java index 444d2498536..7cb82c060e6 100644 --- a/jetty-security/src/main/java/org/eclipse/jetty/security/authentication/LoginAuthenticator.java +++ b/jetty-security/src/main/java/org/eclipse/jetty/security/authentication/LoginAuthenticator.java @@ -30,10 +30,10 @@ public abstract class LoginAuthenticator implements Authenticator { _loginService=configuration.getLoginService(); if (_loginService==null) - throw new IllegalStateException("No LoginService for "+this); + throw new IllegalStateException("No LoginService for "+this+" in "+configuration); _identityService=configuration.getIdentityService(); if (_identityService==null) - throw new IllegalStateException("No IdentityService for "+this); + throw new IllegalStateException("No IdentityService for "+this+" in "+configuration); } public LoginService getLoginService() diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/HandlerContainer.java b/jetty-server/src/main/java/org/eclipse/jetty/server/HandlerContainer.java index 6129c685ca1..208cdeefcc7 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/HandlerContainer.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/HandlerContainer.java @@ -24,6 +24,7 @@ import org.eclipse.jetty.util.component.LifeCycle; */ public interface HandlerContainer extends LifeCycle { + public Handler[] getHandlers(); public Handler[] getChildHandlers(); public Handler[] getChildHandlersByClass(Class byclass); public Handler getChildHandlerByClass(Class byclass); diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/Server.java b/jetty-server/src/main/java/org/eclipse/jetty/server/Server.java index 0f98b16a4f5..ac972f379b2 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/Server.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/Server.java @@ -236,6 +236,8 @@ public class Server extends HandlerWrapper implements Attributes } } } + if (Log.isDebugEnabled()) + Log.debug(dump()); mex.ifExceptionThrow(); } diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/AbstractHandler.java b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/AbstractHandler.java index a09c5989ece..6cba3d819b7 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/AbstractHandler.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/AbstractHandler.java @@ -27,7 +27,6 @@ import org.eclipse.jetty.util.log.Log; */ public abstract class AbstractHandler extends AbstractLifeCycle implements Handler { - protected String _string; private Server _server; /* ------------------------------------------------------------ */ @@ -59,12 +58,17 @@ public abstract class AbstractHandler extends AbstractLifeCycle implements Handl /* ------------------------------------------------------------ */ public String toString() { - if (_string==null) + StringBuilder b=new StringBuilder(); + String s=super.toString(); + b.append(s,s.lastIndexOf('.')+1,s.length()); + ContextHandler.Context ctx = ContextHandler.getCurrentContext(); + if (ctx!=null && ctx.getContextPath()!=null && !(this instanceof ContextHandler)) { - _string=super.toString(); - _string=_string.substring(_string.lastIndexOf('.')+1); + b.append('@'); + b.append(ctx.getContextPath()); + } - return _string; + return b.toString(); } /* ------------------------------------------------------------ */ diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/AbstractHandlerContainer.java b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/AbstractHandlerContainer.java index b5eeb780bbb..d899b7458cd 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/AbstractHandlerContainer.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/AbstractHandlerContainer.java @@ -32,7 +32,7 @@ public abstract class AbstractHandlerContainer extends AbstractHandler implement public AbstractHandlerContainer() { } - + /* ------------------------------------------------------------ */ public Handler[] getChildHandlers() { @@ -83,6 +83,33 @@ public abstract class AbstractHandlerContainer extends AbstractHandler implement return list; } + + /* ------------------------------------------------------------ */ + public String dump() + { + StringBuilder b = new StringBuilder(); + dump(b,this,0); + return b.toString(); + } - + + /* ------------------------------------------------------------ */ + protected void dump(StringBuilder b,Handler handler,int indent) + { + for (int i=0;i