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 -
Method Summary
Modifier and TypeMethodDescriptionbooleancanExtract(Message<?> first, Type keyType, Type valueType) Checks if the current extractor can handle the given method to extract a key of typekeyTypeand a value of typevalueType.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_PRIORITYThe default priority.- See Also:
-
-
Method Details
-
canExtract
Checks if the current extractor can handle the given method to extract a key of typekeyTypeand a value of typevalueType. 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
Keyedis used.This method should not throw an exception, but return
falseif it cannot handle the extraction.- Parameters:
first- the first method, cannot benullkeyType- the type of the key, cannot benullvalueType- the type of the value, cannot benull- Returns:
trueif the current extract can handle the extraction,falseotherwise
-
extractKey
Extracts the key from the given message.- Parameters:
message- the messagekeyType- the type of the key- Returns:
- the object of type
keyType
-
extractValue
Extracts the value from the given message.- Parameters:
message- the messagevalueType- the type of the value- Returns:
- the object of type
valueType
-
getPriority
default int getPriority()- Specified by:
getPriorityin interfacejakarta.enterprise.inject.spi.Prioritized
-