當前位置: 首頁>>代碼示例>>Java>>正文


Java ContainerResponseContext.getMediaType方法代碼示例

本文整理匯總了Java中javax.ws.rs.container.ContainerResponseContext.getMediaType方法的典型用法代碼示例。如果您正苦於以下問題:Java ContainerResponseContext.getMediaType方法的具體用法?Java ContainerResponseContext.getMediaType怎麽用?Java ContainerResponseContext.getMediaType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.ws.rs.container.ContainerResponseContext的用法示例。


在下文中一共展示了ContainerResponseContext.getMediaType方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: processResponse

import javax.ws.rs.container.ContainerResponseContext; //導入方法依賴的package包/類
@Override
public void processResponse(ContainerRequestContext requestContext, ContainerResponseContext responseContext,
		ResourceInfo resourceInfo) {
	MediaType mediaType = responseContext.getMediaType();
	if (mediaType != null && MediaType.APPLICATION_JSON_TYPE.equals(mediaType)) {
		Object responseData = responseContext.getEntity();
		WrapperResponseEntity jsonResponse;

		if (responseData instanceof WrapperResponseEntity) {
			jsonResponse = (WrapperResponseEntity) responseData;
		} else {
			jsonResponse = new WrapperResponseEntity(ResponseCode.OK);
			jsonResponse.setData(responseData);
		}
		responseContext.setStatus(ResponseCode.OK.getCode());

		responseContext.setEntity(jsonResponse);

	}
}
 
開發者ID:vakinge,項目名稱:jeesuite-libs,代碼行數:21,代碼來源:ResponseWrapperHandler.java

示例2: processResponse

import javax.ws.rs.container.ContainerResponseContext; //導入方法依賴的package包/類
@Override
public void processResponse(ContainerRequestContext requestContext,
                            ContainerResponseContext responseContext,
                            ResourceInfo resourceInfo) {
    MediaType mediaType = responseContext.getMediaType();
    if (mediaType != null && MediaType.APPLICATION_JSON_TYPE.equals(mediaType)) {
        Object responseData = responseContext.getEntity();
        WrapperResponseEntity jsonResponse;

        if (responseData instanceof WrapperResponseEntity) {
            jsonResponse = (WrapperResponseEntity) responseData;
        } else {
            jsonResponse = new WrapperResponseEntity(ResponseCode.OK);
            jsonResponse.setData(responseData);
        }
        responseContext.setStatus(ResponseCode.OK.getCode());

        responseContext.setEntity(jsonResponse);

    }
}
 
開發者ID:warlock-china,項目名稱:azeroth,代碼行數:22,代碼來源:ResponseWrapperHandler.java

示例3: filter

import javax.ws.rs.container.ContainerResponseContext; //導入方法依賴的package包/類
@Override
public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext) throws IOException {
  String version = Version.get(requestContext);
  if (version != null) {
    MediaType mediaType = responseContext.getMediaType();
    if (mediaType != null) {
      Map<String, String> parameters = new HashMap<String, String>(mediaType.getParameters());
      parameters.put(parameterName, version);
      mediaType = new MediaType(mediaType.getType(), mediaType.getSubtype(), parameters);
      responseContext.getHeaders().putSingle("Content-Type", mediaType.toString());
    }
  }
}
 
開發者ID:openknowledge,項目名稱:jaxrs-versioning,代碼行數:14,代碼來源:VersionMediaTypeParameterFilter.java

示例4: filter

import javax.ws.rs.container.ContainerResponseContext; //導入方法依賴的package包/類
public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext)
        throws IOException {
    MediaType mediaType = responseContext.getMediaType();
    responseContext.getHeaders().putSingle("Content-Type", mediaType.withCharset("utf-8").toString());
}
 
開發者ID:Remper,項目名稱:sociallink,代碼行數:6,代碼來源:EncodingResponseFilter.java

示例5: filter

import javax.ws.rs.container.ContainerResponseContext; //導入方法依賴的package包/類
/**
 * Filter method called after a response has been provided for a request
 * (either by a {@link ContainerRequestFilter request filter} or by a
 * matched resource method.
 * <p>
 * Filters in the filter chain are ordered according to their {@code javax.annotation.Priority}
 * class-level annotation value.
 * </p>
 *
 * @param requestContext  request context.
 * @param responseContext response context.
 * @throws IOException if an I/O exception occurs.
 */
@Override
public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext) throws IOException {
    MediaType contentType = responseContext.getMediaType();
    if (contentType != null) {
        responseContext.getHeaders().putSingle("Content-Type", contentType.toString() + ";charset=UTF-8");
    }
}
 
開發者ID:dockstore,項目名稱:write_api_service,代碼行數:21,代碼來源:CharsetResponseFilter.java


注:本文中的javax.ws.rs.container.ContainerResponseContext.getMediaType方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。