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

    Fields
    Modifier and Type
    Field
    Description
    static final int
    The priority of anything that does not implement this interface.
    static final int
    A 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

    Modifier and Type
    Method
    Description
    int
     
  • Field Details

    • DEFAULT_PRIORITY

      static final int DEFAULT_PRIORITY
      The priority of anything that does not implement this interface.
      See Also:
    • YIELDS_TO_OTHERS

      static final int YIELDS_TO_OTHERS
      A 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()