Package org.restlet.service
Class ConnegService
- java.lang.Object
-
- org.restlet.service.Service
-
- org.restlet.service.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 Summary
Constructors Constructor Description ConnegService()
Constructor.ConnegService(boolean enabled)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.boolean
isStrict()
Indicates if the conneg algorithm should strictly respect client preferences or be more flexible.void
setStrict(boolean strict)
Indicates if the conneg algorithm should strictly respect client preferences or be more flexible.-
Methods inherited from class org.restlet.service.Service
createInboundFilter, createOutboundFilter, getContext, isEnabled, isStarted, isStopped, setContext, setEnabled, start, stop
-
-
-
-
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.
-
-