From b12f80e71ca2eee6ac121a8e8a3d271408ca3982 Mon Sep 17 00:00:00 2001 From: Dave Borowitz Date: Fri, 8 Jun 2012 12:13:23 -0700 Subject: Add MetaFilter.serveRegex(Pattern) This allows the use of precompiled patterns, such as those compiled with flags. Change-Id: I1c87fea98e246004aecbae3aabaf1d21fbf3176e --- .../src/org/eclipse/jgit/http/server/glue/MetaFilter.java | 12 ++++++++++++ .../src/org/eclipse/jgit/http/server/glue/RegexPipeline.java | 4 ++++ 2 files changed, 16 insertions(+) (limited to 'org.eclipse.jgit.http.server/src/org/eclipse') diff --git a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/glue/MetaFilter.java b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/glue/MetaFilter.java index 8cb3bea1f9..2187cfaa42 100644 --- a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/glue/MetaFilter.java +++ b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/glue/MetaFilter.java @@ -52,6 +52,7 @@ import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.regex.Pattern; import javax.servlet.Filter; import javax.servlet.FilterChain; @@ -116,6 +117,17 @@ public class MetaFilter implements Filter { return register(new RegexPipeline.Binder(expression)); } + /** + * Construct a binding for a regular expression. + * + * @param pattern + * the regular expression to pattern match the URL against. + * @return binder for the passed expression. + */ + public ServletBinder serveRegex(Pattern pattern) { + return register(new RegexPipeline.Binder(pattern)); + } + public void init(FilterConfig filterConfig) throws ServletException { servletContext = filterConfig.getServletContext(); } diff --git a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/glue/RegexPipeline.java b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/glue/RegexPipeline.java index 384ff45a38..2ef71368d0 100644 --- a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/glue/RegexPipeline.java +++ b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/glue/RegexPipeline.java @@ -91,6 +91,10 @@ class RegexPipeline extends UrlPipeline { pattern = Pattern.compile(p); } + Binder(final Pattern p) { + pattern = p; + } + UrlPipeline create() { return new RegexPipeline(pattern, getFilters(), getServlet()); } -- cgit v1.2.3