Browse Source

Add MetaFilter.serveRegex(Pattern)

This allows the use of precompiled patterns, such as those compiled with
flags.

Change-Id: I1c87fea98e246004aecbae3aabaf1d21fbf3176e
stable-2.1
Dave Borowitz 13 years ago
parent
commit
b12f80e71c
  1. 12
      org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/glue/MetaFilter.java
  2. 4
      org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/glue/RegexPipeline.java

12
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.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.regex.Pattern;
import javax.servlet.Filter; import javax.servlet.Filter;
import javax.servlet.FilterChain; import javax.servlet.FilterChain;
@ -116,6 +117,17 @@ public class MetaFilter implements Filter {
return register(new RegexPipeline.Binder(expression)); 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 { public void init(FilterConfig filterConfig) throws ServletException {
servletContext = filterConfig.getServletContext(); servletContext = filterConfig.getServletContext();
} }

4
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); pattern = Pattern.compile(p);
} }
Binder(final Pattern p) {
pattern = p;
}
UrlPipeline create() { UrlPipeline create() {
return new RegexPipeline(pattern, getFilters(), getServlet()); return new RegexPipeline(pattern, getFilters(), getServlet());
} }

Loading…
Cancel
Save