Package org.apache.sling.servlets.annotations

## Annotation Type SlingServletFilter

    @ComponentPropertyType
    public @interface SlingServletFilter

Component Property Type (as defined by OSGi DS 1.4) for Sling Servlet Filters. Takes care of writing the relevant service properties as being used by the Sling Servlet Resolver (`ServletResolverConstants`) to register the annotated servlet filter component as Sling servlet filter.
The order of the filter is determined by the property `service.ranking`. To set it use the annotation `ServiceRanking`. Its value is used to sort the filters. Filters with a higher order are executed before a filter with a lower order. If two filters have the same order, the one with the lower service id is executed first.
Please note that the ordering is actually depending on the used Apache Sling Engine bundle version. Version older than 2.3.4 of that bundle are sorting the filters in the wrong reverse order. Make sure to run a newer version of the Sling engine to get the correct ordering (see also SLING-2920).

See Also:
  Felix SCR annotation, Sling Servlet Filter

### Field Summary

Fields
`static String` `PREFIX_` Prefix for every property being generated from the annotations elements (as defined in OSGi 7 Compendium, 112.8.2.1)

### Optional Element Summary

Optional Elements
`String[]` `extensions` Restrict the filter to extensions that match request's.
`String[]` `methods` Restrict the filter to methods that match request's.
`String` `pattern` Restrict the filter to resource or request paths that match the supplied regular expression.
`String` `request_pattern` Restrict the filter to request paths that match the supplied regular expression.
`String` `resource_pattern` Restrict the filter to resource paths that match the supplied regular expression.
`String[]` `resourceTypes` Restrict the filter to resources that match any of the supplied resource types.
`SlingServletFilterScope[]` `scope` The scopes of the filter.
`String[]` `selectors` Restrict the filter to request selectors that match any of the request's.
`String` `suffix_pattern` Restrict the filter to request suffixes that match the supplied regular expression.

### Field Detail

#### PREFIX_

    static final String PREFIX_

Prefix for every property being generated from the annotations elements (as defined in OSGi 7 Compendium, 112.8.2.1)

### Element Detail

#### scope

    SlingServletFilterScope[] scope

The scopes of the filter. If the filter has request scope, it is run once for a request. If the filter has component scope, it is run once for every included component (rendering).

Returns:
  the scope of the filter

Default:
  {org.apache.sling.servlets.annotations.SlingServletFilterScope.REQUEST}

#### pattern

    String pattern

Restrict the filter to resource or request paths that match the supplied regular expression. Important: The regex is matched against both, the request path and, the resolved resource path excluding selectors, extension and suffix. Empty value will not restrict the filter on path(s).

Sling Engine version < 2.6.14 : Only the request path is checked. Sling Engine version >= 2.6.14 and < 2.7.0 : Only the resource path is checked. Requires Sling Engine 2.4.0.

Returns:
  the path pattern to restrict the filter

Default:
  ""

#### resource_pattern

    String resource_pattern

Restrict the filter to resource paths that match the supplied regular expression. Important: The regex is matched against the resolved resource path excluding selectors, extension and suffix. Empty value will not restrict the filter. Requires Sling Engine 2.7.0.

Returns:
  the resource path pattern to restrict the filter

Default:
  ""

#### request_pattern

    String request_pattern

Restrict the filter to request paths that match the supplied regular expression. Important: The regex is matched against the request path excluding selectors, extension and suffix! Empty value will not restrict the filter. Requires Sling Engine 2.7.0.

Returns:
  the resource path pattern to restrict the filter

Default:
  ""

#### suffix_pattern

    String suffix_pattern

Restrict the filter to request suffixes that match the supplied regular expression. Empty value will not restrict the filter on request suffix. Requires Sling Engine 2.7.0.

Returns:
  the suffix pattern to restrict the filter

Default:
  ""

#### resourceTypes

    String[] resourceTypes

Restrict the filter to resources that match any of the supplied resource types. Please note this is a sling resource API `isResourceType()` match, not a string match. Empty value will not restrict the filter on request's resource type. Requires Sling Engine 2.7.0.

Returns:
  the resourceTypes to restrict the filter

Default:
  {}

#### methods

    String[] methods

Restrict the filter to methods that match request's. Empty value will not restrict the filter on request method. Requires Sling Engine 2.7.0.

Returns:
  the methods to restrict the filter

Default:
  {}

#### extensions

    String[] extensions

Restrict the filter to extensions that match request's. Empty value will not restrict the filter on request extension. Requires Sling Engine 2.7.0.

Returns:
  the extensions to restrict the filter

Default:
  {}

#### selectors

    String[] selectors

Restrict the filter to request selectors that match any of the request's. At least one selector must match one of the provided selectors. Empty value will not restrict the filter on request selectors. Requires Sling Engine 2.7.0.

Returns:
  the selectors to restrict the filter

Default:
  {}