Dumpable RewriteHandler (#3800)

RewriteHandler dumps it's rules

Signed-off-by: Greg Wilkins <gregw@webtide.com>
This commit is contained in:
Greg Wilkins 2019-06-21 21:03:38 +02:00 committed by GitHub
parent 5e3cecee6f
commit d2e4830d5c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 4 deletions

View File

@ -27,7 +27,9 @@ import org.eclipse.jetty.deploy.bindings.DebugListenerBinding;
import org.eclipse.jetty.deploy.providers.WebAppProvider;
import org.eclipse.jetty.http.HttpVersion;
import org.eclipse.jetty.jmx.MBeanContainer;
import org.eclipse.jetty.rewrite.handler.MsieSslRule;
import org.eclipse.jetty.rewrite.handler.RewriteHandler;
import org.eclipse.jetty.rewrite.handler.ValidUrlRule;
import org.eclipse.jetty.security.HashLoginService;
import org.eclipse.jetty.server.AsyncRequestLogWriter;
import org.eclipse.jetty.server.CustomRequestLog;
@ -103,7 +105,7 @@ public class LikeJettyXml
server.setHandler(handlers);
// Extra options
server.setDumpAfterStart(false);
server.setDumpAfterStart(true);
server.setDumpBeforeStop(false);
server.setStopAtShutdown(true);
@ -189,6 +191,8 @@ public class LikeJettyXml
RewriteHandler rewrite = new RewriteHandler();
rewrite.setHandler(server.getHandler());
server.setHandler(rewrite);
rewrite.addRule(new MsieSslRule());
rewrite.addRule(new ValidUrlRule());
// === jetty-requestlog.xml ===
AsyncRequestLogWriter logWriter = new AsyncRequestLogWriter(jetty_home + "/logs/yyyy_mm_dd.request.log");

View File

@ -21,7 +21,6 @@ package org.eclipse.jetty.rewrite.handler;
import java.io.IOException;
import java.util.Arrays;
import java.util.EnumSet;
import javax.servlet.DispatcherType;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
@ -179,6 +178,7 @@ public class RewriteHandler extends HandlerWrapper
public RewriteHandler()
{
_rules = new RuleContainer();
addBean(_rules);
}
/* ------------------------------------------------------------ */
@ -219,6 +219,7 @@ public class RewriteHandler extends HandlerWrapper
*/
public void setRuleContainer(RuleContainer rules)
{
updateBean(_rules, rules);
_rules = rules;
}

View File

@ -19,13 +19,13 @@
package org.eclipse.jetty.rewrite.handler;
import java.io.IOException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.util.ArrayUtil;
import org.eclipse.jetty.util.URIUtil;
import org.eclipse.jetty.util.component.Dumpable;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
@ -33,7 +33,7 @@ import org.eclipse.jetty.util.log.Logger;
* Base container to group rules. Can be extended so that the contained rules
* will only be applied under certain conditions
*/
public class RuleContainer extends Rule
public class RuleContainer extends Rule implements Dumpable
{
public static final String ORIGINAL_QUERYSTRING_ATTRIBUTE_SUFFIX = ".QUERYSTRING";
private static final Logger LOG = Log.getLogger(RuleContainer.class);
@ -214,4 +214,10 @@ public class RuleContainer extends Rule
return target;
}
@Override
public void dump(Appendable out, String indent) throws IOException
{
Dumpable.dumpObjects(out, indent, this, _rules);
}
}