/** Empty servlet with no bindings. */ public MetaServlet() { this(new MetaFilter()); }
private UrlPipeline[] getPipelines() throws ServletException { UrlPipeline[] r = pipelines; if (r == null) { synchronized (bindings) { r = pipelines; if (r == null) { r = createPipelines(); pipelines = r; } } } return r; }
public void destroy() { filter.destroy(); }
/** * 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); } }
public void destroy() { if (pipelines != null) { Set<Object> destroyed = newIdentitySet(); for (UrlPipeline p : pipelines) p.destroy(destroyed); pipelines = null; } }
@Override public void init(ServletConfig config) throws ServletException { String name = filter.getClass().getName(); ServletContext ctx = config.getServletContext(); filter.init(new NoParameterFilterConfig(name, ctx)); }
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); } }); }
private UrlPipeline find(HttpServletRequest req) throws ServletException { for (UrlPipeline p : getPipelines()) if (p.match(req)) return p; return null; }
/** * 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); }
/** * 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); } }
public void destroy() { if (pipelines != null) { Set<Object> destroyed = newIdentitySet(); for (UrlPipeline p : pipelines) p.destroy(destroyed); pipelines = null; } }
@Override public void init(ServletConfig config) throws ServletException { String name = filter.getClass().getName(); ServletContext ctx = config.getServletContext(); filter.init(new NoParameterFilterConfig(name, ctx)); }
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); } }); }
private UrlPipeline find(HttpServletRequest req) throws ServletException { for (UrlPipeline p : getPipelines()) if (p.match(req)) return p; return null; }
/** * 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); }
/** * 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)); }
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; } }
@Override public void init(FilterConfig filterConfig) throws ServletException { super.init(filterConfig);