public class MediaTypeHelper
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String | COPYRIGHT
IBM Copyright notice field.
|
static java.lang.String | FORMAT_ATOM
The response format value for Atom feeds.
|
static java.lang.String | FORMAT_JSON
The response format value for JSON.
|
static java.lang.String | FORMAT_XHTML
The response format value for XHTML.
|
static java.lang.String | FORMAT_XML
The response format value for XML.
|
Modifier | Constructor and Description |
---|---|
protected | MediaTypeHelper() |
Modifier and Type | Method and Description |
---|---|
static void | createInstance(java.lang.String respFormatMappingLocation)
Creates the instance based on configuration file.
|
static MediaTypeHelper | getInstance()
Gets the single instance of MediaTypeHelper.
|
javax.ws.rs.core.MediaType | getResponseMediaType(java.lang.String responseFormatShortcut, javax.ws.rs.core.Request request)
Returns a selected media type for the specified response format and request.
|
protected void | loadConfig(java.io.File baseConfigLoc)
Instantiates a new security config manager.
|
public static final java.lang.String COPYRIGHT
public static final java.lang.String FORMAT_ATOM
public static final java.lang.String FORMAT_JSON
public static final java.lang.String FORMAT_XHTML
public static final java.lang.String FORMAT_XML
public static MediaTypeHelper getInstance()
public static void createInstance(java.lang.String respFormatMappingLocation)
protected void loadConfig(java.io.File baseConfigLoc)
public javax.ws.rs.core.MediaType getResponseMediaType(java.lang.String responseFormatShortcut, javax.ws.rs.core.Request request)
If response format shortcut is specified, then this method returns the media type corresponding to the response format shortcut using the response format shortcut mappings specified in the resource bundles /WEB-INF/config/responseformat-mapping and /WEB-INF/config/responseformat-mapping-ext.
If response format shortcut is not specified, then this method uses the request object to select a media type. It checks the list of acceptable media types specified by the client in the Accept request header and returns a matching media type in the list of media types supported by the application. The list of supported media types are derived based on the media types supported by all the entity providers in the application using the javax.ws.rs.Produces annotation. The application entity providers are specified in the resource bundles /WEB-INF/config/providers and /WEB-INF/config/providers-ext.
If a media type is not resolved using either of response format shortcut or the request object, then this method returns application/json as the media type.