org.glassfish.jersey.internal.inject
Class RequestInjectee

java.lang.Object
  extended by org.glassfish.jersey.internal.inject.RequestInjectee
All Implemented Interfaces:
Request

public class RequestInjectee
extends Object
implements Request

Proxiable wrapper for request scoped Request instance.

Author:
Jakub Podlesak (jakub.podlesak at oracle.com)

Constructor Summary
RequestInjectee()
           
 
Method Summary
 Response.ResponseBuilder evaluatePreconditions()
          Evaluate request preconditions for a resource that does not currently exist.
 Response.ResponseBuilder evaluatePreconditions(Date lastModified)
          Evaluate request preconditions based on the passed in value.
 Response.ResponseBuilder evaluatePreconditions(Date lastModified, EntityTag eTag)
          Evaluate request preconditions based on the passed in value.
 Response.ResponseBuilder evaluatePreconditions(EntityTag eTag)
          Evaluate request preconditions based on the passed in value.
 String getMethod()
          Get the request method, e.g.
 Variant selectVariant(List<Variant> variants)
          Select the representation variant that best matches the request.
 void set(Request request)
          Set wrapped instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RequestInjectee

public RequestInjectee()
Method Detail

set

public void set(Request request)
Set wrapped instance. Should be invoked on each incoming request, when a new injectee instance is created by HK2.

Parameters:
request - actual request instance.

getMethod

public String getMethod()
Description copied from interface: Request
Get the request method, e.g. GET, POST, etc.

Specified by:
getMethod in interface Request
Returns:
the request method.
See Also:
HttpMethod

selectVariant

public Variant selectVariant(List<Variant> variants)
                      throws IllegalArgumentException
Description copied from interface: Request
Select the representation variant that best matches the request. Returns null in case there is no matching variant in the list.

More explicit variants are chosen ahead of less explicit ones. A vary header is computed from the supplied list and automatically added to the response.

Specified by:
selectVariant in interface Request
Parameters:
variants - a list of Variant that describe all of the available representation variants.
Returns:
the variant that best matches the request or null if there's no match.
Throws:
IllegalArgumentException - if variants is empty or null.
See Also:
Variant.VariantListBuilder

evaluatePreconditions

public Response.ResponseBuilder evaluatePreconditions(EntityTag eTag)
Description copied from interface: Request
Evaluate request preconditions based on the passed in value.

Specified by:
evaluatePreconditions in interface Request
Parameters:
eTag - an ETag for the current state of the resource
Returns:
null if the preconditions are met or a ResponseBuilder set with the appropriate status if the preconditions are not met. A returned ResponseBuilder will include an ETag header set with the value of eTag, provided none of the precondition evaluation has failed, in which case the ETag header would not be included and the status code of the returned ResponseBuilder would be set to Response.Status.PRECONDITION_FAILED.

evaluatePreconditions

public Response.ResponseBuilder evaluatePreconditions(Date lastModified)
Description copied from interface: Request
Evaluate request preconditions based on the passed in value.

Specified by:
evaluatePreconditions in interface Request
Parameters:
lastModified - a date that specifies the modification date of the resource
Returns:
null if the preconditions are met or a ResponseBuilder set with the appropriate status if the preconditions are not met.

evaluatePreconditions

public Response.ResponseBuilder evaluatePreconditions(Date lastModified,
                                                      EntityTag eTag)
Description copied from interface: Request
Evaluate request preconditions based on the passed in value.

Specified by:
evaluatePreconditions in interface Request
Parameters:
lastModified - a date that specifies the modification date of the resource
eTag - an ETag for the current state of the resource
Returns:
null if the preconditions are met or a ResponseBuilder set with the appropriate status if the preconditions are not met. A returned ResponseBuilder will include an ETag header set with the value of eTag, provided none of the precondition evaluation has failed, in which case the ETag header would not be included and the status code of the returned ResponseBuilder would be set to Response.Status.PRECONDITION_FAILED.

evaluatePreconditions

public Response.ResponseBuilder evaluatePreconditions()
Description copied from interface: Request
Evaluate request preconditions for a resource that does not currently exist. The primary use of this method is to support the If-Match: * and If-None-Match: * preconditions.

Note that both preconditions If-None-Match: * and If-None-Match: something will always be considered to have been met and it is the applications responsibility to enforce any additional method-specific semantics. E.g. a PUT on a resource that does not exist might succeed whereas a GET on a resource that does not exist would likely result in a 404 response. It would be the responsibility of the application to generate the 404 response.

Specified by:
evaluatePreconditions in interface Request
Returns:
null if the preconditions are met or a ResponseBuilder set with the appropriate status if the preconditions are not met.


Copyright © 2007-2014, Oracle and/or its affiliates. All Rights Reserved. Use is subject to license terms.