Interface HeadersMapFactory


public interface HeadersMapFactory
SPI factory that creates the Map implementation used to store headers on a Message.

The factory is discovered via the service key FACTORY. The default implementation (DefaultHeadersMapFactory in camel-base-engine) returns a case-insensitive linked hash map, which is important for HTTP-style protocols where header names such as content-type and Content-Type must be treated as equal. An alternative implementation (FastHeadersMapFactory in camel-headersmap) provides higher-throughput concurrent access. Custom implementations must correctly implement isInstanceOf(java.util.Map) (so Camel can detect whether a given map was created by this factory) and newMap(java.util.Map) (defensive copy semantics for Message.setHeaders(Map)).

See Exchange in the Camel user manual.

See Also:
  • Field Details

  • Method Details

    • newMap

      Map<String,Object> newMap()
      Creates a new empty Map
      Returns:
      new empty map
    • newMap

      Map<String,Object> newMap(Map<String,Object> map)
      Creates a new Map and copies over all the content from the existing map.

      The copy of the content should use defensive copy, so the returned map can add/remove/change the content without affecting the existing map.

      Parameters:
      map - existing map to copy over (must use defensive copy)
      Returns:
      new map with the content from the existing map
    • isInstanceOf

      boolean isInstanceOf(Map<String,Object> map)
      Whether the given Map implementation is created by this factory?
      Returns:
      true if created from this factory, false if not
    • isCaseInsensitive

      boolean isCaseInsensitive()
      Whether the created Map are case insensitive or not.

      Important: When using case sensitive (this method return false). Then the map is case sensitive which means headers such as content-type and Content-Type are two different keys which can be a problem for some protocols such as HTTP based, which rely on case insensitive headers. However case sensitive implementations can yield faster performance. Therefore use case sensitive implementation with care.