本文整理汇总了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;
}
示例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 );
}