Interface KeyValueExtractor

All Superinterfaces:
jakarta.enterprise.inject.spi.Prioritized

@Experimental("SmallRye only feature") public interface KeyValueExtractor extends jakarta.enterprise.inject.spi.Prioritized
Class responsible for extracting of the key and value from Messages. When a KeyedMulti is injected, the framework looks for the extractor to use. The selection is based on the canExtract(Message, Type, Type) method, and Prioritized.

The user can create a bean that expose this interface, with a higher priority than the ones provided by the framework.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    The default priority.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    canExtract(Message<?> first, Type keyType, Type valueType)
    Checks if the current extractor can handle the given method to extract a key of type keyType and a value of type valueType.
    extractKey(Message<?> message, Type keyType)
    Extracts the key from the given message.
    extractValue(Message<?> message, Type valueType)
    Extracts the value from the given message.
    default int
     
  • Field Details

    • DEFAULT_PRIORITY

      static final int DEFAULT_PRIORITY
      The default priority.
      See Also:
  • Method Details

    • canExtract

      boolean canExtract(Message<?> first, Type keyType, Type valueType)
      Checks if the current extractor can handle the given method to extract a key of type keyType and a value of type valueType. Note that this method is only called once, for the first received message. Once a matching extractor is found, it is reused for all the other messages.

      Also, this method is not used when Keyed is used.

      This method should not throw an exception, but return false if it cannot handle the extraction.

      Parameters:
      first - the first method, cannot be null
      keyType - the type of the key, cannot be null
      valueType - the type of the value, cannot be null
      Returns:
      true if the current extract can handle the extraction, false otherwise
    • extractKey

      Object extractKey(Message<?> message, Type keyType)
      Extracts the key from the given message.
      Parameters:
      message - the message
      keyType - the type of the key
      Returns:
      the object of type keyType
    • extractValue

      Object extractValue(Message<?> message, Type valueType)
      Extracts the value from the given message.
      Parameters:
      message - the message
      valueType - the type of the value
      Returns:
      the object of type valueType
    • getPriority

      default int getPriority()
      Specified by:
      getPriority in interface jakarta.enterprise.inject.spi.Prioritized