Class FilterRegistration

java.lang.Object
org.glassfish.grizzly.servlet.Registration
org.glassfish.grizzly.servlet.FilterRegistration
All Implemented Interfaces:
FilterRegistration, FilterRegistration.Dynamic, Registration, Registration.Dynamic

public class FilterRegistration extends Registration implements FilterRegistration.Dynamic
Allows customization of a Filter registered with the WebappContext.
Since:
2.2
  • Field Details

    • filterClass

      protected Class<? extends Filter> filterClass
    • filter

      protected Filter filter
    • isAsyncSupported

      protected boolean isAsyncSupported
  • Constructor Details

    • FilterRegistration

      protected FilterRegistration(WebappContext ctx, String name, String filterClassName)
      Creates a new FilterRegistration associated with the specified WebappContext.
      Parameters:
      ctx - the owning WebappContext.
      name - the name of the Filter.
      filterClassName - the fully qualified class name of the Filter implementation.
    • FilterRegistration

      protected FilterRegistration(WebappContext ctx, String name, Class<? extends Filter> filter)
      Creates a new FilterRegistration associated with the specified WebappContext.
      Parameters:
      ctx - the owning WebappContext.
      name - name the name of the Filter.
      filter - the class of the Filter implementation
    • FilterRegistration

      protected FilterRegistration(WebappContext ctx, String name, Filter filter)
      Creates a new FilterRegistration associated with the specified WebappContext.
      Parameters:
      ctx - the owning WebappContext.
      name - name the name of the Filter.
      filter - the Filter instance.
  • Method Details

    • addMappingForServletNames

      public void addMappingForServletNames(EnumSet<DispatcherType> dispatcherTypes, String... servletNames)
      Adds a filter mapping with the given servlet names and dispatcher types for the Filter represented by this FilterRegistration.

      Filter mappings are matched in the order in which they were added.

      If this method is called multiple times, each successive call adds to the effects of the former.

      Parameters:
      dispatcherTypes - the dispatcher types of the filter mapping, or null if the default DispatcherType.REQUEST is to be used
      servletNames - the servlet names of the filter mapping
      Throws:
      IllegalArgumentException - if servletNames is null or empty
      IllegalStateException - if the ServletContext from which this FilterRegistration was obtained has already been initialized
    • addMappingForServletNames

      public void addMappingForServletNames(EnumSet<DispatcherType> dispatcherTypes, boolean isMatchAfter, String... servletNames)
      Adds a filter mapping with the given servlet names and dispatcher types for the Filter represented by this FilterRegistration.

      Filter mappings are matched in the order in which they were added.

      Depending on the value of the isMatchAfter parameter, the given filter mapping will be considered after or before any declared filter mappings of the ServletContext from which this FilterRegistration was obtained.

      If this method is called multiple times, each successive call adds to the effects of the former.

      Specified by:
      addMappingForServletNames in interface FilterRegistration
      Parameters:
      dispatcherTypes - the dispatcher types of the filter mapping, or null if the default DispatcherType.REQUEST is to be used
      isMatchAfter - true if the given filter mapping should be matched after any declared filter mappings, and false if it is supposed to be matched before any declared filter mappings of the ServletContext from which this FilterRegistration was obtained
      servletNames - the servlet names of the filter mapping
    • getServletNameMappings

      public Collection<String> getServletNameMappings()
      Gets the currently available servlet name mappings of the Filter represented by this FilterRegistration.

      If permitted, any changes to the returned Collection must not affect this FilterRegistration.

      Specified by:
      getServletNameMappings in interface FilterRegistration
      Returns:
      a (possibly empty) Collection of the currently available servlet name mappings of the Filter represented by this FilterRegistration
    • addMappingForUrlPatterns

      public void addMappingForUrlPatterns(EnumSet<DispatcherType> dispatcherTypes, String... urlPatterns)
      Adds a filter mapping with the given url patterns and dispatcher types for the Filter represented by this FilterRegistration.

      Filter mappings are matched in the order in which they were added.

      If this method is called multiple times, each successive call adds to the effects of the former.

      Parameters:
      dispatcherTypes - the dispatcher types of the filter mapping, or null if the default DispatcherType.REQUEST is to be used
      urlPatterns - the url patterns of the filter mapping
      Throws:
      IllegalArgumentException - if urlPatterns is null or empty
      IllegalStateException - if the ServletContext from which this FilterRegistration was obtained has already been initialized
    • addMappingForUrlPatterns

      public void addMappingForUrlPatterns(EnumSet<DispatcherType> dispatcherTypes, boolean isMatchAfter, String... urlPatterns)
      Adds a filter mapping with the given url patterns and dispatcher types for the Filter represented by this FilterRegistration.

      Filter mappings are matched in the order in which they were added.

      Depending on the value of the isMatchAfter parameter, the given filter mapping will be considered after or before any declared filter mappings of the ServletContext from which this FilterRegistration was obtained.

      If this method is called multiple times, each successive call adds to the effects of the former.

      Specified by:
      addMappingForUrlPatterns in interface FilterRegistration
      Parameters:
      dispatcherTypes - the dispatcher types of the filter mapping, or null if the default DispatcherType.REQUEST is to be used
      isMatchAfter - true if the given filter mapping should be matched after any declared filter mappings, and false if it is supposed to be matched before any declared filter mappings of the ServletContext from which this FilterRegistration was obtained
      urlPatterns - the url patterns of the filter mapping
    • getUrlPatternMappings

      public Collection<String> getUrlPatternMappings()
      Gets the currently available URL pattern mappings of the Filter represented by this FilterRegistration.

      If permitted, any changes to the returned Collection must not affect this FilterRegistration.

      Specified by:
      getUrlPatternMappings in interface FilterRegistration
      Returns:
      a (possibly empty) Collection of the currently available URL pattern mappings of the Filter represented by this FilterRegistration
    • setAsyncSupported

      public void setAsyncSupported(boolean isAsyncSupported)
      Configures the Servlet or Filter represented by this dynamic Registration as supporting asynchronous operations or not.

      By default, servlet and filters do not support asynchronous operations.

      A call to this method overrides any previous setting.

      Specified by:
      setAsyncSupported in interface Registration.Dynamic
      Parameters:
      isAsyncSupported - true if the Servlet or Filter represented by this dynamic Registration supports asynchronous operations, false otherwise