Class ConnegService


  • public class ConnegService
    extends Service
    Application service negotiating the preferred resource variants. This service is leveraged by server-side and client-side content negotiation, annotated method dispatching, and so on.
    Author:
    Jerome Louvel
    • Constructor Detail

      • ConnegService

        public ConnegService()
        Constructor.
      • ConnegService

        public ConnegService​(boolean enabled)
        Constructor.
        Parameters:
        enabled - True if the service has been enabled.
    • Method Detail

      • getPreferredVariant

        public Variant getPreferredVariant​(java.util.List<? extends Variant> variants,
                                           Request request,
                                           MetadataService metadataService)
        Returns the best variant representation for a given resource according the the client preferences.
        A default language is provided in case the variants don't match the client preferences.
        Parameters:
        variants - The list of variants to compare.
        request - The request including client preferences.
        metadataService - The metadata service used to get default metadata values.
        Returns:
        The preferred variant.
        See Also:
        Apache content negotiation algorithm
      • isStrict

        public boolean isStrict()
        Indicates if the conneg algorithm should strictly respect client preferences or be more flexible. Value is false by default.
        Returns:
        True if the conneg algorithm should strictly respect client preferences.
      • setStrict

        public void setStrict​(boolean strict)
        Indicates if the conneg algorithm should strictly respect client preferences or be more flexible.
        Parameters:
        strict - True if the conneg algorithm should strictly respect client preferences.