当前位置: 首页>>代码示例>>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;未经允许,请勿转载。