public void destroy() { if (pipelines != null) { Set<Object> destroyed = newIdentitySet(); for (UrlPipeline p : pipelines) p.destroy(destroyed); pipelines = null; } }
private UrlPipeline find(HttpServletRequest req) throws ServletException { for (UrlPipeline p : getPipelines()) if (p.match(req)) return p; return null; }
/** * Construct a binding for a regular expression. * * @param expression * the regular expression to pattern match the URL against. * @return binder for the passed expression. */ public ServletBinder serveRegex(String expression) { return register(new RegexPipeline.Binder(expression)); }
private UrlPipeline[] createPipelines() throws ServletException { UrlPipeline[] array = new UrlPipeline[bindings.size()]; for (int i = 0; i < bindings.size(); i++) array[i] = bindings.get(i).create(); Set<Object> inited = newIdentitySet(); for (UrlPipeline p : array) p.init(servletContext, inited); return array; } }
UrlPipeline create() { return new RegexPipeline(pattern, getFilters(), getServlet()); } }
UrlPipeline create() { return new SuffixPipeline(suffix, getFilters(), getServlet()); } }
@Override public String getPathTranslated() { final String p = getPathInfo(); return p != null ? getRealPath(p) : null; }
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { HttpServletRequest req = (HttpServletRequest) request; HttpServletResponse res = (HttpServletResponse) response; UrlPipeline p = find(req); if (p != null) p.service(req, res); else chain.doFilter(req, res); }
@Override protected void service(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { filter.doFilter(req, res, new FilterChain() { public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException { ((HttpServletResponse) response).sendError(SC_NOT_FOUND); } }); }
/** * Construct a binding for a specific path. * * @param path * pattern to match. * @return binder for the passed path. */ public ServletBinder serve(String path) { return filter.serve(path); }
/** @return the configured servlet, or singleton returning 404 if none. */ protected HttpServlet getServlet() { if (httpServlet != null) return httpServlet; else return new ErrorServlet(HttpServletResponse.SC_NOT_FOUND); }
/** * Configure a newly created binder. * * @param b * the newly created binder. * @return binder for the caller, potentially after adding one or more * filters into the pipeline. */ protected ServletBinder register(ServletBinder b) { return filter.register(b); } }
private UrlPipeline[] createPipelines() throws ServletException { UrlPipeline[] array = new UrlPipeline[bindings.size()]; for (int i = 0; i < bindings.size(); i++) array[i] = bindings.get(i).create(); Set<Object> inited = newIdentitySet(); for (UrlPipeline p : array) p.init(servletContext, inited); return array; } }
UrlPipeline create() { return new RegexPipeline(pattern, getFilters(), getServlet()); } }
UrlPipeline create() { return new SuffixPipeline(suffix, getFilters(), getServlet()); } }
/** * 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 destroy() { if (pipelines != null) { Set<Object> destroyed = newIdentitySet(); for (UrlPipeline p : pipelines) p.destroy(destroyed); pipelines = null; } }
private UrlPipeline find(HttpServletRequest req) throws ServletException { for (UrlPipeline p : getPipelines()) if (p.match(req)) return p; return null; }
/** * 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)); }
/** * Construct a binding for a regular expression. * * @param expression * the regular expression to pattern match the URL against. * @return binder for the passed expression. */ public ServletBinder serveRegex(String expression) { return register(new RegexPipeline.Binder(expression)); }