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


Java Response.getAttributes方法代码示例

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


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

示例1: getResponseHeaders

import org.restlet.Response; //导入方法依赖的package包/类
/**
 * Gets the response headers, making sure to create them if they don't
 * exist.
 * 
 * @param response
 *        The response
 * @return The headers
 */
public static Series<Header> getResponseHeaders( Response response )
{
	ConcurrentMap<String, Object> attributes = response.getAttributes();
	@SuppressWarnings("unchecked")
	Series<Header> headers = (Series<Header>) attributes.get( HeaderConstants.ATTRIBUTE_HEADERS );
	if( headers == null )
	{
		headers = new Series<Header>( Header.class );
		@SuppressWarnings("unchecked")
		Series<Header> existing = (Series<Header>) attributes.putIfAbsent( HeaderConstants.ATTRIBUTE_HEADERS, headers );
		if( existing != null )
			headers = existing;
	}
	return headers;
}
 
开发者ID:tliron,项目名称:prudence,代码行数:24,代码来源:RestletUtil.java

示例2: toRepresentation

import org.restlet.Response; //导入方法依赖的package包/类
@Override
public Representation toRepresentation( Status status, Request request, Response response )
{
	if( isEnabled() )
	{
		ConcurrentMap<String, Object> attributes = response.getAttributes();

		Object passthrough = attributes.get( PASSTHROUGH_ATTRIBUTE );
		if( ( passthrough != null ) && (Boolean) passthrough )
			// Pass through
			return response.getEntity();

		Restlet handler = handlers.get( status.getCode() );
		if( handler != null )
		{
			// Reset the response
			response.setStatus( Status.SUCCESS_OK );
			response.setEntity( null );

			// Clean up saved information
			CachingUtil.clearExistingValidDocumentName( request );

			// Delegate
			handler.handle( request, response );

			// Return the status
			response.setStatus( status );

			Representation representation = response.getEntity();
			if( representation != null )
			{
				// Avoid client caching, which would require other
				// interchanges with the client that we can't handle from
				// here
				representation.setExpirationDate( null );
				representation.setModificationDate( null );
				representation.setTag( null );
			}

			attributes.put( PASSTHROUGH_ATTRIBUTE, true );
			return representation;
		}

		if( isFallback )
			// Fallbacks don't override the entity if there are no handlers
			return response.getEntity();

		if( isDebugging() && ( status.getThrowable() != null ) )
		{
			// Use the debug representation for exceptions
			attributes.put( PASSTHROUGH_ATTRIBUTE, true );
			if( debugHeader != null )
				RestletUtil.getResponseHeaders( response ).set( debugHeader, "error" );
			return createDebugRepresentation( status, request, response );
		}
	}

	return super.toRepresentation( status, request, response );
}
 
开发者ID:tliron,项目名称:prudence,代码行数:60,代码来源:DelegatedStatusService.java


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