aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Borowitz2012-06-08 15:13:23 (EDT)
committerDave Borowitz2012-06-08 15:16:31 (EDT)
commitb12f80e71ca2eee6ac121a8e8a3d271408ca3982 (patch)
treea8d869362c024077f448145d9a4889fa1289e52a
parent61c4e39067777633ea5d6d02f7493b4c459aef20 (diff)
downloadjgit-b12f80e71ca2eee6ac121a8e8a3d271408ca3982.zip
jgit-b12f80e71ca2eee6ac121a8e8a3d271408ca3982.tar.gz
jgit-b12f80e71ca2eee6ac121a8e8a3d271408ca3982.tar.bz2
Add MetaFilter.serveRegex(Pattern)refs/changes/03/6303/2
This allows the use of precompiled patterns, such as those compiled with flags. Change-Id: I1c87fea98e246004aecbae3aabaf1d21fbf3176e
-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 8cb3bea..2187cfa 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 384ff45..2ef7136 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());
}