summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.http.server/src/org/eclipse/jgit
diff options
context:
space:
mode:
authorDave Borowitz <dborowitz@google.com>2012-06-08 12:13:23 -0700
committerDave Borowitz <dborowitz@google.com>2012-06-08 12:16:31 -0700
commitb12f80e71ca2eee6ac121a8e8a3d271408ca3982 (patch)
treea8d869362c024077f448145d9a4889fa1289e52a /org.eclipse.jgit.http.server/src/org/eclipse/jgit
parent61c4e39067777633ea5d6d02f7493b4c459aef20 (diff)
downloadjgit-b12f80e71ca2eee6ac121a8e8a3d271408ca3982.tar.gz
jgit-b12f80e71ca2eee6ac121a8e8a3d271408ca3982.zip
Add MetaFilter.serveRegex(Pattern)
This allows the use of precompiled patterns, such as those compiled with flags. Change-Id: I1c87fea98e246004aecbae3aabaf1d21fbf3176e
Diffstat (limited to 'org.eclipse.jgit.http.server/src/org/eclipse/jgit')
-rw-r--r--org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/glue/MetaFilter.java12
-rw-r--r--org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/glue/RegexPipeline.java4
2 files changed, 16 insertions, 0 deletions
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());
}