當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。