org.apache.camel.impl
Class DefaultHeaderFilterStrategy

java.lang.Object
  extended by org.apache.camel.impl.DefaultHeaderFilterStrategy
All Implemented Interfaces:
HeaderFilterStrategy

public class DefaultHeaderFilterStrategy
extends Object
implements 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.

Version:

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.apache.camel.spi.HeaderFilterStrategy
HeaderFilterStrategy.Direction
 
Constructor Summary
DefaultHeaderFilterStrategy()
           
 
Method Summary
 boolean applyFilterToCamelHeaders(String headerName, Object headerValue, Exchange exchange)
          Applies filtering logic to Camel Message header that is going to be copied to target message such as CXF and JMS message.
 boolean applyFilterToExternalHeaders(String headerName, Object headerValue, Exchange exchange)
          Applies filtering logic to an external message header such as CXF and JMS message that is going to be copied to Camel message header.
protected  boolean extendedFilter(HeaderFilterStrategy.Direction direction, String key, Object value, Exchange exchange)
           
 Set<String> getInFilter()
          Gets the "in" direction filter set.
 String getInFilterPattern()
          Gets the "in" direction filter regular expression Pattern.
 Set<String> getOutFilter()
          Gets the "out" direction filter set.
 String getOutFilterPattern()
          Gets the "out" direction filter regular expression Pattern.
 boolean isAllowNullValues()
           
 boolean isLowerCase()
          Gets the isLowercase property which is a boolean to determine whether header names should be converted to lowercase before checking it the filter Set.
 void setAllowNullValues(boolean value)
           
 void setInFilter(Set<String> value)
          Sets the "in" direction filter set.
 void setInFilterPattern(String value)
          Sets the "in" direction filter regular expression Pattern.
 void setLowerCase(boolean value)
          Sets the isLowercase property which is a boolean to determine whether header names should be converted to lowercase before checking it the filter Set.
 void setOutFilter(Set<String> value)
          Sets the "out" direction filter set.
 void setOutFilterPattern(String value)
          Sets the "out" direction filter regular expression Pattern.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultHeaderFilterStrategy

public DefaultHeaderFilterStrategy()
Method Detail

applyFilterToCamelHeaders

public boolean applyFilterToCamelHeaders(String headerName,
                                         Object headerValue,
                                         Exchange exchange)
Description copied from interface: HeaderFilterStrategy
Applies filtering logic to Camel Message header that is going to be copied to target message such as CXF and JMS message.

It returns true if the filtering logic return a match. Otherwise, it returns false. A match means the header should be excluded.

Specified by:
applyFilterToCamelHeaders in interface HeaderFilterStrategy
Parameters:
headerName - the header name
headerValue - the header value
exchange - the context to perform filtering
Returns:
true if this header should be filtered out.

applyFilterToExternalHeaders

public boolean applyFilterToExternalHeaders(String headerName,
                                            Object headerValue,
                                            Exchange exchange)
Description copied from interface: HeaderFilterStrategy
Applies filtering logic to an external message header such as CXF and JMS message that is going to be copied to Camel message header.

It returns true if the filtering logic return a match. Otherwise, it returns false. A match means the header should be excluded.

Specified by:
applyFilterToExternalHeaders in interface HeaderFilterStrategy
Parameters:
headerName - the header name
headerValue - the header value
exchange - the context to perform filtering
Returns:
true if this header should be filtered out.

getOutFilter

public Set<String> 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

public void setOutFilter(Set<String> value)
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

getOutFilterPattern

public String getOutFilterPattern()
Gets the "out" direction filter regular expression Pattern. 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 out.

Returns:
regular expression filter pattern

setOutFilterPattern

public void setOutFilterPattern(String value)
Sets the "out" direction filter regular expression Pattern. 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 out.

Parameters:
value - regular expression filter pattern

getInFilter

public Set<String> 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

public void setInFilter(Set<String> value)
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

getInFilterPattern

public String getInFilterPattern()
Gets the "in" direction filter regular expression Pattern. 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 out.

Returns:
regular expression filter pattern

setInFilterPattern

public void setInFilterPattern(String value)
Sets the "in" direction filter regular expression Pattern. 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 out.

Parameters:
value - 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 lowercase before checking it 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 lowercase before checking it the filter Set. It does not affect filtering using regular expression pattern.


isAllowNullValues

public boolean isAllowNullValues()

setAllowNullValues

public void setAllowNullValues(boolean value)

extendedFilter

protected boolean extendedFilter(HeaderFilterStrategy.Direction direction,
                                 String key,
                                 Object value,
                                 Exchange exchange)


Apache CAMEL