Package org.restlet.service
Class EncoderService
java.lang.Object
org.restlet.service.Service
org.restlet.service.EncoderService
Application service automatically encoding or compressing request entities.
- Author:
- Jerome Louvel
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intIndicates if the encoding should always occur, regardless of the size.static final intIndicates if the default minimum size for encoding to occur. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancanEncode(Representation representation) Indicates if a representation can be encoded.createInboundFilter(Context context) Create the filter that should be invoked for incoming calls.createOutboundFilter(Context context) Create the filter that should be invoked for outgoing calls.Returns the media types that should be encoded.Returns the list of default encoded media types.Returns the list of default ignored media types.Returns the media types that should be ignored.longReturns the minimum size a representation must have before compression is done.voidsetMinimumSize(long mininumSize) Sets the minimum size a representation must have before compression is done.Methods inherited from class org.restlet.service.Service
getContext, isEnabled, isStarted, isStopped, setContext, setEnabled, start, stop
-
Field Details
-
ANY_SIZE
public static final int ANY_SIZEIndicates if the encoding should always occur, regardless of the size.- See Also:
-
DEFAULT_MINIMUM_SIZE
public static final int DEFAULT_MINIMUM_SIZEIndicates if the default minimum size for encoding to occur.- See Also:
-
-
Constructor Details
-
EncoderService
public EncoderService()Constructor. -
EncoderService
public EncoderService(boolean enabled) Constructor. The default minimum size- Parameters:
enabled- True if the service has been enabled.
-
-
Method Details
-
getDefaultAcceptedMediaTypes
Returns the list of default encoded media types. This can be overridden by subclasses. By default, all media types are encoded (except those explicitly ignored).- Returns:
- The list of default encoded media types.
-
getDefaultIgnoredMediaTypes
Returns the list of default ignored media types. This can be overridden by subclasses. By default, all archive, audio, image and video media types are ignored.- Returns:
- The list of default ignored media types.
-
canEncode
Indicates if a representation can be encoded.- Parameters:
representation- The representation to test.- Returns:
- True if the call can be encoded.
-
createInboundFilter
Description copied from class:ServiceCreate the filter that should be invoked for incoming calls.- Overrides:
createInboundFilterin classService- Parameters:
context- The current context.- Returns:
- The new filter or null.
-
createOutboundFilter
Description copied from class:ServiceCreate the filter that should be invoked for outgoing calls.- Overrides:
createOutboundFilterin classService- Parameters:
context- The current context.- Returns:
- The new filter or null.
- See Also:
-
getAcceptedMediaTypes
Returns the media types that should be encoded.- Returns:
- The media types that should be encoded.
-
getIgnoredMediaTypes
Returns the media types that should be ignored.- Returns:
- The media types that should be ignored.
-
getMinimumSize
public long getMinimumSize()Returns the minimum size a representation must have before compression is done.- Returns:
- The minimum size a representation must have before compression is done.
-
setMinimumSize
public void setMinimumSize(long mininumSize) Sets the minimum size a representation must have before compression is done.- Parameters:
mininumSize- The minimum size a representation must have before compression is done.
-