当前位置: 首页>>代码示例>>Java>>正文


Java ContainerRequest.getMediaType方法代码示例

本文整理汇总了Java中com.sun.jersey.spi.container.ContainerRequest.getMediaType方法的典型用法代码示例。如果您正苦于以下问题:Java ContainerRequest.getMediaType方法的具体用法?Java ContainerRequest.getMediaType怎么用?Java ContainerRequest.getMediaType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.sun.jersey.spi.container.ContainerRequest的用法示例。


在下文中一共展示了ContainerRequest.getMediaType方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: filter

import com.sun.jersey.spi.container.ContainerRequest; //导入方法依赖的package包/类
@Override
public ContainerRequest filter(final ContainerRequest req) {
	
	if (log.isTraceEnabled()) {
		String baseUri = req.getBaseUri().getPath();
		String method = req.getMethod();
		String path = req.getPath();
		MediaType mediaType = req.getMediaType();
		
		String dbg = Strings.of("\r\nRESTEndPoint: {}"  +														
				  				"\r\n---------------------------------------------------------------------"  +				
				  				"\r\n       Method: {}"  +
				  				"\r\n        Path: {}" + 
				  				"\r\nContent-Type: {}" +
				  				"\r\n---------------------------------------------------------------------")
				  			.customizeWith(baseUri,
				  					       method,
				  					       path,
				  					       mediaType != null ? mediaType
				  					    		   			 : "not specified")
				  			.asString();
		log.trace(dbg);
	}
	return req;
}
 
开发者ID:opendata-euskadi,项目名称:r01fb,代码行数:26,代码来源:RESTLogRequestFilter.java

示例2: filter

import com.sun.jersey.spi.container.ContainerRequest; //导入方法依赖的package包/类
@Override
public ContainerRequest filter(final ContainerRequest request) {
	if (logger.isInfoEnabled()) {
		String requestInfo = request.getPath() + " (" + request.getMethod() +
				(request.getMediaType() == null ? "" : " " + request.getMediaType()) + ")";
		logger.info(requestInfo);

		StringBuilder parameters = new StringBuilder("Params: ");
		Set<Entry<String, List<String>>> entrySet = request.getFormParameters().entrySet();
		for (Entry<String, List<String>> parameter : entrySet) {
			parameters.append(parameter.getKey()).append(":").append(parameter.getValue()).append(", ");
		}
		if (!entrySet.isEmpty()) {
			parameters.setLength(parameters.length() - ", ".length());
			logger.info(parameters.toString());
		}

	}
	return request;
}
 
开发者ID:LemoProject,项目名称:lemo2,代码行数:21,代码来源:RequestLoggingFilter.java

示例3: filter

import com.sun.jersey.spi.container.ContainerRequest; //导入方法依赖的package包/类
@Override
public ContainerRequest filter(final ContainerRequest request) {
	if (logger.isInfoEnabled()) {
		String requestInfo = request.getPath() + " (" + request.getMethod() +
				(request.getMediaType() == null ? "" : " " + request.getMediaType()) + ")";
		logger.debug(requestInfo);

		StringBuilder parameters = new StringBuilder("Params: ");
		Set<Entry<String, List<String>>> entrySet = request.getFormParameters().entrySet();
		for (Entry<String, List<String>> parameter : entrySet) {
			parameters.append(parameter.getKey()).append(":").append(parameter.getValue()).append(", ");
		}
		if (!entrySet.isEmpty()) {
			parameters.setLength(parameters.length() - ", ".length());
			logger.debug(parameters.toString());
		}

	}
	return request;
}
 
开发者ID:LemoProject,项目名称:Lemo-Data-Management-Server,代码行数:21,代码来源:RequestLoggingFilter.java

示例4: filter

import com.sun.jersey.spi.container.ContainerRequest; //导入方法依赖的package包/类
@Override
public ContainerRequest filter(ContainerRequest request) {
    if (request.getMediaType() != null &&
        request.getMediaType()
            .isCompatible(MediaType.APPLICATION_JSON_TYPE)) {
        adjustContentType(request);
        validate(request);
    }
    return request;
}
 
开发者ID:enviroCar,项目名称:enviroCar-server,代码行数:11,代码来源:JSONSchemaResourceFilterFactory.java

示例5: adjustContentType

import com.sun.jersey.spi.container.ContainerRequest; //导入方法依赖的package包/类
protected void adjustContentType(ContainerRequest request) {
    MediaType newMt = new MediaType("application", "json", ImmutableMap
            .<String, String>builder()
            .putAll(request.getMediaType().getParameters())
            .put(MediaTypes.SCHEMA_ATTRIBUTE, schema).build());
    // container request caches the header......
    request.getRequestHeaders().remove(HttpHeaders.CONTENT_TYPE);
    request.getMediaType();
    request.getRequestHeaders()
            .putSingle(HttpHeaders.CONTENT_TYPE, newMt.toString());
}
 
开发者ID:enviroCar,项目名称:enviroCar-server,代码行数:12,代码来源:JSONSchemaResourceFilterFactory.java


注:本文中的com.sun.jersey.spi.container.ContainerRequest.getMediaType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。