Package javax.servlet

Examples of javax.servlet.Filter


            }
        }
        logger.info("Installing Servlet {}", servletClassName);
        filterChain.setServlet(sc, servlet);

        Filter f;
        for (String fClass : filtersClass) {
            try {
                f = (Filter) urlC.loadClass(fClass).newInstance();
            } catch (NullPointerException ex) {
                // We failed to load the Filter, let's try directly.
                f = (Filter) Thread.currentThread().getContextClassLoader()
                        .loadClass(fClass).newInstance();
            }
            FilterConfigImpl fc = new FilterConfigImpl(sc);
            fc.setFilter(f);

            if (filterName == null) {
               if (sc.getInitParameter(APPLICATION_NAME) != null) {
                   filterName = sc.getInitParameter(APPLICATION_NAME);
               } else {
                   filterName = f.getClass().getSimpleName();
               }
            }

            fc.setFilterName(filterName);
            filterChain.addFilter(fc);
View Full Code Here


        FilterMapping map = _filterMap.get(i);

        if (map.isMatch(invocation.getServletName())) {
          String filterName = map.getFilterName();

          Filter filter = _filterManager.createFilter(filterName);
          FilterConfigImpl config = _filterManager.getFilter(filterName);

          if (! config.isAsyncSupported())
            invocation.clearAsyncSupported();

          chain = addFilter(chain, filter);
        }
      }
    }

    synchronized (_filterMap) {
      for (int i = _filterMap.size() - 1; i >= 0; i--) {
        FilterMapping map = _filterMap.get(i);

        if (map.isMatch(invocation)) {
          String filterName = map.getFilterName();

          Filter filter = _filterManager.createFilter(filterName);
          FilterConfigImpl config = _filterManager.getFilter(filterName);

          if (! config.isAsyncSupported())
            invocation.clearAsyncSupported();
View Full Code Here

        FilterMapping map = _filterMap.get(i);

        if (map.isMatch(servletName)) {
          String filterName = map.getFilterName();

          Filter filter = _filterManager.createFilter(filterName);

          chain = addFilter(chain, filter);
        }
      }
    }
View Full Code Here

        SlingHttpServletResponse slingResponse = toSlingResponse(response);

        if (this.current < this.filters.length) {

            // continue filtering with the next filter
            Filter filter = this.filters[this.current];
            trackFilter(slingRequest, filter);
            filter.doFilter(slingRequest, slingResponse, this);

        } else {

            this.render(slingRequest, slingResponse);
View Full Code Here

    public void processComponent(SlingHttpServletRequest request,
            SlingHttpServletResponse response,
            final FilterChainType filterChainType) throws IOException,
            ServletException {

        Filter filters[] = filterManager.getFilters(filterChainType);
        if (filters != null) {

            FilterChain processor = new SlingComponentFilterChain(filters);
            request.getRequestProgressTracker().log(
                "Applying " + filterChainType + "filters");
View Full Code Here

            {
                // Do Nothing
            }
        }), "/test1");

        webAppBundleContext.addFilter(new FilterHolder(new Filter()
        {
            public void init(FilterConfig filterConfig) throws ServletException
            {
                ServletContext context = filterConfig.getServletContext();
View Full Code Here

    @Test
    public void testAddRemoveFilter() throws Exception
    {
        HandlerRegistry hr = new HandlerRegistry();

        Filter filter = Mockito.mock(Filter.class);
        FilterHandler handler = new FilterHandler(null, filter, "/aha", 1, "oho");
        assertEquals("Precondition", 0, hr.getFilters().length);
        hr.addFilter(handler);
        Mockito.verify(filter, Mockito.times(1)).init(Mockito.any(FilterConfig.class));
        assertEquals(1, hr.getFilters().length);
View Full Code Here

    @Test
    public void testAddFilterWhileSameFilterAddedDuringInit() throws Exception
    {
        final HandlerRegistry hr = new HandlerRegistry();

        Filter filter = Mockito.mock(Filter.class);
        final FilterHandler otherHandler = new FilterHandler(null, filter, "/two", 99, "two");

        Mockito.doAnswer(new Answer<Void>()
        {
            boolean registered = false;
View Full Code Here

        ServletHandler servletHandler = new ServletHandler(null, servlet, "/f", "f");
        hr.addServlet(servletHandler);
        Servlet servlet2 = Mockito.mock(Servlet.class);
        ServletHandler servletHandler2 = new ServletHandler(null, servlet2, "/ff", "ff");
        hr.addServlet(servletHandler2);
        Filter filter = Mockito.mock(Filter.class);
        FilterHandler filterHandler = new FilterHandler(null, filter, "/f", 0, "f");
        hr.addFilter(filterHandler);

        assertEquals(2, hr.getServlets().length);
        assertEquals("Most specific Alias should come first",
View Full Code Here

        Boolean bridgeEndpoint = getAndRemoveParameter(parameters, "bridgeEndpoint", Boolean.class);
        Boolean matchOnUriPrefix = getAndRemoveParameter(parameters, "matchOnUriPrefix", Boolean.class);
        Boolean enableJmx = getAndRemoveParameter(parameters, "enableJmx", Boolean.class);
        Boolean enableMultipartFilter = getAndRemoveParameter(parameters, "enableMultipartFilter",
                                                              Boolean.class, true);
        Filter multipartFilter = resolveAndRemoveReferenceParameter(parameters, "multipartFilterRef", Filter.class);
        List<Filter> filters = resolveAndRemoveReferenceListParameter(parameters, "filtersRef", Filter.class);
        Long continuationTimeout = getAndRemoveParameter(parameters, "continuationTimeout", Long.class);
        Boolean useContinuation = getAndRemoveParameter(parameters, "useContinuation", Boolean.class);
        HeaderFilterStrategy headerFilterStrategy = resolveAndRemoveReferenceParameter(parameters, "headerFilterStrategy", HeaderFilterStrategy.class);
        UrlRewrite urlRewrite = resolveAndRemoveReferenceParameter(parameters, "urlRewrite", UrlRewrite.class);
View Full Code Here

TOP

Related Classes of javax.servlet.Filter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.