org.restlet.Response.getAttributes()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(9.4k)|赞(0)|评价(0)|浏览(142)

本文整理了Java中org.restlet.Response.getAttributes方法的一些代码示例,展示了Response.getAttributes的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Response.getAttributes方法的具体详情如下:
包路径:org.restlet.Response
类名称:Response
方法名:getAttributes

Response.getAttributes介绍

暂无

代码示例

代码示例来源:origin: org.restlet.jee/org.restlet.ext.jaxrs

/**
 * Returns the HTTP headers of the Restlet {@link Response} as {@link Series}.
 * 
 * @param response
 * @return Returns the HTTP headers of the Response.
 */
@SuppressWarnings("unchecked")
public static Series<Header> getHttpHeaders(Response response) {
  Series<Header> headers = (Series<Header>) response.getAttributes().get(
      HeaderConstants.ATTRIBUTE_HEADERS);
  if (headers == null) {
    headers = new Series<Header>(Header.class);
    response.getAttributes().put(HeaderConstants.ATTRIBUTE_HEADERS,
        headers);
  }
  return headers;
}

代码示例来源:origin: ontopia/ontopia

protected Map<Class<?>, Class<?>> getMixInAnnotationsMap() {
  ConcurrentMap<String, Object> attributes = getResponse().getAttributes();
  @SuppressWarnings(value = "unchecked")
  Map<Class<?>, Class<?>> mixins = (Map<Class<?>, Class<?>>) attributes.get(JacksonRepresentationImpl.ADDITIONAL_MIXINS_ATTRIBUTE);
  if (mixins == null) {
    mixins = new HashMap<>();
    attributes.put(JacksonRepresentationImpl.ADDITIONAL_MIXINS_ATTRIBUTE, mixins);
  }
  return mixins;
}

代码示例来源:origin: org.restlet.osgi/org.restlet

/**
 * Returns the response attributes.
 * 
 * @return The response attributes.
 * @see Response#getAttributes()
 */
public Map<String, Object> getResponseAttributes() {
  return getResponse() == null ? null : getResponse().getAttributes();
}

代码示例来源:origin: org.restlet.osgi/org.restlet

return getWrappedResponse().getAttributes();

代码示例来源:origin: org.restlet.osgi/org.restlet

/**
 * Optionally updates the response sent in the {@link #MODE_SERVER_INBOUND}
 * and {@link #MODE_SERVER_OUTBOUND} modes. By default, it leverages the
 * {@link #headersCleaning} attribute in order to clean the headers: if set
 * to true, it removes all headers, otherwise it keeps only the extension
 * (or non HTTP standard) headers<br>
 * 
 * @param initialResponse
 *            The initial response returned.
 */
protected void rewrite(Response initialResponse) {
  if (isHeadersCleaning()) {
    initialResponse.getAttributes().remove(
        HeaderConstants.ATTRIBUTE_HEADERS);
  } else {
    HeaderUtils.keepExtensionHeadersOnly(initialResponse);
  }
}

代码示例来源:origin: com.github.ansell.restlet-utils/restlet-utils

@SuppressWarnings("unchecked")
@Override
protected void afterHandle(final Request request, final Response response)
{
  super.afterHandle(request, response);
  
  final ConcurrentMap<String, Object> responseAttributes = response.getAttributes();
  
  Series<Header> responseHeaders = (Series<Header>)responseAttributes.get(HeaderConstants.ATTRIBUTE_HEADERS);
  
  if(responseHeaders == null)
  {
    responseHeaders = new Series<Header>(Header.class);
    final Series<Header> putIfAbsent =
        (Series<Header>)responseAttributes.putIfAbsent(HeaderConstants.ATTRIBUTE_HEADERS, responseHeaders);
    
    if(putIfAbsent != null)
    {
      responseHeaders = putIfAbsent;
    }
  }
  
  // Allow all origins
  responseHeaders.add("Access-Control-Allow-Origin", "*");
}

代码示例来源:origin: org.restlet.osgi/org.restlet

/**
 * Reads the response headers of a handled HTTP client call to update the
 * original uniform call.
 * 
 * @param httpCall
 *            The handled HTTP client call.
 * @param response
 *            The high-level response to update.
 */
protected void readResponseHeaders(ClientCall httpCall, Response response) {
  try {
    Series<Header> responseHeaders = httpCall.getResponseHeaders();
    // Put the response headers in the call's attributes map
    response.getAttributes().put(HeaderConstants.ATTRIBUTE_HEADERS, responseHeaders);
    HeaderUtils.copyResponseTransportHeaders(responseHeaders, response);
  } catch (Exception e) {
    getLogger()
        .log(Level.FINE,
            "An error occurred during the processing of the HTTP response.",
            e);
    response.setStatus(Status.CONNECTOR_ERROR_INTERNAL, e);
  }
}

代码示例来源:origin: org.restlet.jse/org.restlet.example

private void sendXRDSLocation() {
  ConcurrentMap<String, Object> attribs = getContext().getAttributes();
  String id = getQuery().getFirstValue("id");
  String xrds = attribs.get("xrds").toString();
  String location = (id != null) ? xrds + "?id=" + id : xrds;
  getLogger().info("XRDS endpoint = " + xrds);
  @SuppressWarnings("unchecked")
  Series<Header> headers = (Series<Header>) getResponse().getAttributes()
      .get(HeaderConstants.ATTRIBUTE_HEADERS);
  if (headers == null) {
    headers = new Series<Header>(Header.class);
    headers.add("X-XRDS-Location", location);
    getResponse().getAttributes().put(
        HeaderConstants.ATTRIBUTE_HEADERS, headers);
  } else {
    headers.add("X-XRDS-Location", location);
  }
  getLogger().info("Sending empty representation.");
}

代码示例来源:origin: org.restlet.osgi/org.restlet.ext.platform

@Override
public int handle(Request request, Response response,
    CounterResult counterResult) {
  Series<Header> headers = response.getHeaders();
  headers.set(
      "X-RateLimit-Remaining",
      Integer.toString(getLimit(request,
          counterResult.getCountedValue())
          - counterResult.getConsumed()));
  headers.set(
      "X-RateLimit-Limit",
      Integer.toString(getLimit(request,
          counterResult.getCountedValue())));
  headers.set("X-RateLimit-Reset",
      Long.toString(counterResult.getReset()));
  response.getAttributes()
      .put(HeaderConstants.ATTRIBUTE_HEADERS, headers);
  return super.handle(request, response, counterResult);
}

代码示例来源:origin: org.restlet.jee/org.restlet.ext.platform

@Override
public int handle(Request request, Response response,
    CounterResult counterResult) {
  Series<Header> headers = response.getHeaders();
  headers.set(
      "X-RateLimit-Remaining",
      Integer.toString(getLimit(request,
          counterResult.getCountedValue())
          - counterResult.getConsumed()));
  headers.set(
      "X-RateLimit-Limit",
      Integer.toString(getLimit(request,
          counterResult.getCountedValue())));
  headers.set("X-RateLimit-Reset",
      Long.toString(counterResult.getReset()));
  response.getAttributes()
      .put(HeaderConstants.ATTRIBUTE_HEADERS, headers);
  return super.handle(request, response, counterResult);
}

代码示例来源:origin: org.restlet.gae/org.restlet.ext.platform

@Override
public int handle(Request request, Response response,
    CounterResult counterResult) {
  Series<Header> headers = response.getHeaders();
  headers.set(
      "X-RateLimit-Remaining",
      Integer.toString(getLimit(request,
          counterResult.getCountedValue())
          - counterResult.getConsumed()));
  headers.set(
      "X-RateLimit-Limit",
      Integer.toString(getLimit(request,
          counterResult.getCountedValue())));
  headers.set("X-RateLimit-Reset",
      Long.toString(counterResult.getReset()));
  response.getAttributes()
      .put(HeaderConstants.ATTRIBUTE_HEADERS, headers);
  return super.handle(request, response, counterResult);
}

代码示例来源:origin: org.restlet.jee/org.restlet.ext.apispark

@Override
public int handle(Request request, Response response,
    CounterResult counterResult) {
  Series<Header> headers = response.getHeaders();
  headers.set(
      "X-RateLimit-Remaining",
      Integer.toString(getLimit(request,
          counterResult.getCountedValue())
          - counterResult.getConsumed()));
  headers.set(
      "X-RateLimit-Limit",
      Integer.toString(getLimit(request,
          counterResult.getCountedValue())));
  headers.set("X-RateLimit-Reset",
      Long.toString(counterResult.getReset()));
  response.getAttributes()
      .put(HeaderConstants.ATTRIBUTE_HEADERS, headers);
  return super.handle(request, response, counterResult);
}

代码示例来源:origin: org.restlet.jse/org.restlet.ext.platform

@Override
public int handle(Request request, Response response,
    CounterResult counterResult) {
  Series<Header> headers = response.getHeaders();
  headers.set(
      "X-RateLimit-Remaining",
      Integer.toString(getLimit(request,
          counterResult.getCountedValue())
          - counterResult.getConsumed()));
  headers.set(
      "X-RateLimit-Limit",
      Integer.toString(getLimit(request,
          counterResult.getCountedValue())));
  headers.set("X-RateLimit-Reset",
      Long.toString(counterResult.getReset()));
  response.getAttributes()
      .put(HeaderConstants.ATTRIBUTE_HEADERS, headers);
  return super.handle(request, response, counterResult);
}

代码示例来源:origin: org.restlet.jse/org.restlet.example

response.getAttributes().put(HeaderConstants.ATTRIBUTE_HEADERS,
    headers);

代码示例来源:origin: org.metaeffekt.dcc/dcc-agent-core

if (!getHeaderFilterStrategy().applyFilterToCamelHeaders(
    entry.getKey(), entry.getValue(), exchange)) {
  response.getAttributes().put(entry.getKey(), entry.getValue());

代码示例来源:origin: ontopia/ontopia

Map<Class<?>, Class<?>> additional = (Map<Class<?>, Class<?>>) Response.getCurrent().getAttributes().get(ADDITIONAL_MIXINS_ATTRIBUTE);

代码示例来源:origin: org.daisy.libs/com.xmlcalabash

Series<Header> responseHeaders = (Series<Header>) getResponse().getAttributes().get("org.restlet.http.headers");
if (responseHeaders == null) {
  responseHeaders = new Series(Header.class);
  getResponse().getAttributes().put("org.restlet.http.headers", responseHeaders);

代码示例来源:origin: com.xmlcalabash/xmlcalabash

Series<Header> responseHeaders = (Series<Header>) getResponse().getAttributes().get("org.restlet.http.headers");
if (responseHeaders == null) {
  responseHeaders = new Series(Header.class);
  getResponse().getAttributes().put("org.restlet.http.headers", responseHeaders);

代码示例来源:origin: org.restlet.jse/org.restlet.example

response.getAttributes().remove(
    HeaderConstants.ATTRIBUTE_HEADERS);
request.setResourceRef(resourceRef);

代码示例来源:origin: org.restlet.osgi/org.restlet

@Override
public Object resolve(String variableName) {
  Object result = (this.response != null) ? this.response.getAttributes().get(variableName) : null;
  if (result != null) {
    return result;

相关文章