Package org.apache.camel.support
Class DefaultHeaderFilterStrategy
java.lang.Object
org.apache.camel.support.DefaultHeaderFilterStrategy
- All Implemented Interfaces:
org.apache.camel.spi.HeaderFilterStrategy
@Metadata(label="bean",
description="The default header filtering strategy. Users can configure which headers is allowed or denied.",
annotations="interfaceName=org.apache.camel.spi.HeaderFilterStrategy")
@Configurer(metadataOnly=true)
public class DefaultHeaderFilterStrategy
extends Object
implements org.apache.camel.spi.HeaderFilterStrategy
The default header filtering strategy. Users can configure filter by setting filter set and/or setting a regular
expression. Subclass can add extended filter logic in
extendedFilter(org.apache.camel.spi.HeaderFilterStrategy.Direction, String, Object, org.apache.camel.Exchange)
Filters are associated with directions (in or out). "In" direction is referred to propagating headers "to" Camel message. The "out" direction is opposite which is referred to propagating headers from Camel message to a native message like JMS and CXF message. You can see example of DefaultHeaderFilterStrategy are being extended and invoked in camel-jms and camel-cxf components.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.camel.spi.HeaderFilterStrategy
org.apache.camel.spi.HeaderFilterStrategy.Direction -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanapplyFilterToCamelHeaders(String headerName, Object headerValue, org.apache.camel.Exchange exchange) booleanapplyFilterToExternalHeaders(String headerName, Object headerValue, org.apache.camel.Exchange exchange) protected booleanextendedFilter(org.apache.camel.spi.HeaderFilterStrategy.Direction direction, String key, Object value, org.apache.camel.Exchange exchange) Gets the "in" direction filter set.Gets the "in" direction filter regular expressionPattern.Gets the "out" direction filter set.Gets the "out" direction filter regular expressionPattern.booleanbooleanGets the caseInsensitive property which is a boolean to determine whether header names should be case insensitive when checking it with the filter set.booleanbooleanGets the isLowercase property which is a boolean to determine whether header names should be converted to lower case before checking it with the filter Set.voidsetAllowNullValues(boolean value) Whether to allow null values.voidsetCaseInsensitive(boolean caseInsensitive) Sets the caseInsensitive property which is a boolean to determine whether header names should be case insensitive when checking it with the filter set.voidsetFilterOnMatch(boolean filterOnMatch) Sets the filterOnMatch property which is a boolean to determine what to do when a pattern or filter set is matched.voidsetInFilter(String value) voidsetInFilter(Set<String> value) Sets the "in" direction filter set.voidsetInFilterPattern(String value) Sets the "in" direction filter regular expressionPattern.voidsetInFilterPattern(Pattern pattern) Sets the "in" direction filter regular expressionPattern.voidsetInFilterStartsWith(String... inFilterStartsWith) Sets the "in" direction filter by starts with pattern.voidsetLowerCase(boolean value) Sets the isLowercase property which is a boolean to determine whether header names should be converted to lower case before checking it with the filter Set.voidsetOutFilter(String value) voidsetOutFilter(Set<String> value) Sets the "out" direction filter set.voidsetOutFilterPattern(String value) Sets the "out" direction filter regular expressionPattern.voidsetOutFilterPattern(Pattern pattern) Sets the "out" direction filter regular expressionPattern.voidsetOutFilterStartsWith(String... outFilterStartsWith) Sets the "out" direction filter by starts with pattern.
-
Field Details
-
CAMEL_FILTER_PATTERN
Deprecated.A filter pattern that only accepts keys starting with Camel or org.apache.camel. -
CAMEL_FILTER_STARTS_WITH
A filter pattern for keys starting with Camel, camel, or org.apache.camel.
-
-
Constructor Details
-
DefaultHeaderFilterStrategy
public DefaultHeaderFilterStrategy()
-
-
Method Details
-
applyFilterToCamelHeaders
public boolean applyFilterToCamelHeaders(String headerName, Object headerValue, org.apache.camel.Exchange exchange) - Specified by:
applyFilterToCamelHeadersin interfaceorg.apache.camel.spi.HeaderFilterStrategy
-
applyFilterToExternalHeaders
public boolean applyFilterToExternalHeaders(String headerName, Object headerValue, org.apache.camel.Exchange exchange) - Specified by:
applyFilterToExternalHeadersin interfaceorg.apache.camel.spi.HeaderFilterStrategy
-
getOutFilter
Gets the "out" direction filter set. The "out" direction is referred to copying headers from a Camel message to an external message.- Returns:
- a set that contains header names that should be excluded.
-
setOutFilter
Sets the "out" direction filter set. The "out" direction is referred to copying headers from a Camel message to an external message.- Parameters:
value- the filter
-
setOutFilter
-
setOutFilterStartsWith
Sets the "out" direction filter by starts with pattern. The "out" direction is referred to copying headers from a Camel message to an external message.- Parameters:
outFilterStartsWith- one or more key names to use for filtering using starts with
-
getOutFilterPattern
Gets the "out" direction filter regular expressionPattern. The "out" direction is referred to copying headers from Camel message to an external message. If the pattern matches a header, the header will be filtered (skipped).- Returns:
- regular expression filter pattern
-
setOutFilterPattern
Sets the "out" direction filter regular expressionPattern. The "out" direction is referred to copying headers from Camel message to an external message. If the pattern matches a header, the header will be filtered (skipped).- Parameters:
value- regular expression filter pattern
-
setOutFilterPattern
Sets the "out" direction filter regular expressionPattern. The "out" direction is referred to copying headers from Camel message to an external message. If the pattern matches a header, the header will be filtered (skipped).- Parameters:
pattern- regular expression filter pattern
-
getInFilter
Gets the "in" direction filter set. The "in" direction is referred to copying headers from an external message to a Camel message.- Returns:
- a set that contains header names that should be excluded.
-
setInFilter
Sets the "in" direction filter set. The "in" direction is referred to copying headers from an external message to a Camel message.- Parameters:
value- the filter
-
setInFilter
-
setInFilterStartsWith
Sets the "in" direction filter by starts with pattern. The "in" direction is referred to copying headers from an external message to a Camel message.- Parameters:
inFilterStartsWith- one or more key names to use for filtering using starts with
-
getInFilterPattern
Gets the "in" direction filter regular expressionPattern. The "in" direction is referred to copying headers from an external message to a Camel message. If the pattern matches a header, the header will be filtered (skipped).- Returns:
- regular expression filter pattern
-
setInFilterPattern
Sets the "in" direction filter regular expressionPattern. The "in" direction is referred to copying headers from an external message to a Camel message. If the pattern matches a header, the header will be filtered (skipped).- Parameters:
value- regular expression filter pattern
-
setInFilterPattern
Sets the "in" direction filter regular expressionPattern. The "in" direction is referred to copying headers from an external message to a Camel message. If the pattern matches a header, the header will be filtered (skipped).- Parameters:
pattern- regular expression filter pattern
-
isLowerCase
public boolean isLowerCase()Gets the isLowercase property which is a boolean to determine whether header names should be converted to lower case before checking it with the filter Set. It does not affect filtering using regular expression pattern. -
setLowerCase
public void setLowerCase(boolean value) Sets the isLowercase property which is a boolean to determine whether header names should be converted to lower case before checking it with the filter Set. It does not affect filtering using regular expression pattern. -
isCaseInsensitive
public boolean isCaseInsensitive()Gets the caseInsensitive property which is a boolean to determine whether header names should be case insensitive when checking it with the filter set. It does not affect filtering using regular expression pattern.- Returns:
- true if header names is case insensitive.
-
setCaseInsensitive
public void setCaseInsensitive(boolean caseInsensitive) Sets the caseInsensitive property which is a boolean to determine whether header names should be case insensitive when checking it with the filter set. It does not affect filtering using regular expression pattern,- Parameters:
caseInsensitive- true if header names is case insensitive.
-
isAllowNullValues
public boolean isAllowNullValues() -
setAllowNullValues
public void setAllowNullValues(boolean value) Whether to allow null values.By default a header is skipped if its value is null. Setting this to true will preserve the header.
-
isFilterOnMatch
public boolean isFilterOnMatch() -
setFilterOnMatch
public void setFilterOnMatch(boolean filterOnMatch) Sets the filterOnMatch property which is a boolean to determine what to do when a pattern or filter set is matched.When set to true, a match will filter out the header. This is the default value for backwards compatibility.
When set to false, the pattern or filter will indicate that the header must be kept; anything not matched will be filtered (skipped).
- Parameters:
filterOnMatch- true if a match filters (skips) the header.
-
extendedFilter
-
CAMEL_FILTER_STARTS_WITH