Interface PrioritizedFactory
- All Known Implementing Classes:
Jackson3ChatMessageJsonCodecFactory, Jackson3InMemoryEmbeddingStoreJsonCodecFactory, Jackson3JsonCodecFactory, Jackson3ProviderJsonCodecFactory, Jackson3StateJsonCodecFactory, Jackson3StructuredPromptFactory, Jackson3ToolSpecificationJsonCodecFactory
public interface PrioritizedFactory
Decides which implementation wins when more than one is registered for a service of which only one
is used, such as a JSON codec or a prompt template factory.
Without this, the winner is whatever the ServiceLoader happened to enumerate
first - which can differ between a development run, a shaded jar and a container image.
Higher wins. A factory that does not implement this interface is DEFAULT_PRIORITY,
so an application or framework that supplies its own implementation keeps it: a factory has to
ask to lose. Among equal priorities the ServiceLoader order is preserved, and
ServiceHelper logs a warning naming the winner.
For a service of which every implementation is used, priority decides the order in which they are returned.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe priority of anything that does not implement this interface.static final intA priority for an implementation that should apply only when nothing else is registered for the service - the opt-in JSON codecs use this, so that adding them to an application whose framework already supplies a codec does not silently take that framework's behaviour away. -
Method Summary
-
Field Details
-
DEFAULT_PRIORITY
static final int DEFAULT_PRIORITYThe priority of anything that does not implement this interface.- See Also:
-
YIELDS_TO_OTHERS
static final int YIELDS_TO_OTHERSA priority for an implementation that should apply only when nothing else is registered for the service - the opt-in JSON codecs use this, so that adding them to an application whose framework already supplies a codec does not silently take that framework's behaviour away.- See Also:
-
-
Method Details
-
priority
int priority()
-