com.sun.jersey.server.impl.application
Class WebApplicationContext

java.lang.Object
  extended by com.sun.jersey.server.impl.application.WebApplicationContext
All Implemented Interfaces:
ExtendedUriInfo, HttpContext, Traceable, UriMatchResultContext, UriRuleContext, UriInfo

public final class WebApplicationContext
extends java.lang.Object
implements UriRuleContext, ExtendedUriInfo

Author:
[email protected]

Field Summary
static java.lang.String HTTP_METHOD_MATCH_RESOURCE
           
 
Constructor Summary
WebApplicationContext(WebApplicationImpl app, ContainerRequest request, ContainerResponse response)
           
 
Method Summary
 WebApplicationContext createMatchResourceContext(java.net.URI u)
           
 java.net.URI getAbsolutePath()
           
 UriBuilder getAbsolutePathBuilder()
           
 java.net.URI getBaseUri()
           
 UriBuilder getBaseUriBuilder()
           
 ContainerRequest getContainerRequest()
          Get the container request.
 ContainerResponse getContainerResponse()
          Get the container response.
 java.lang.Throwable getMappedThrowable()
          Get the throwable that was mapped to a response.
 AbstractResourceMethod getMatchedMethod()
          Get get matched resource method that was invoked.
 java.util.List<java.lang.Object> getMatchedResources()
           
 java.util.List<java.util.regex.MatchResult> getMatchedResults()
          Get a read-only list of MatchResult for matched resources.
 java.util.List<UriTemplate> getMatchedTemplates()
          Get a read-only list of UriTemplate for matched resources.
 java.util.List<java.lang.String> getMatchedURIs()
           
 java.util.List<java.lang.String> getMatchedURIs(boolean decode)
           
 java.util.regex.MatchResult getMatchResult()
          Get the match result
 java.lang.String getPath()
           
 java.lang.String getPath(boolean decode)
           
 MultivaluedMap<java.lang.String,java.lang.String> getPathParameters()
           
 MultivaluedMap<java.lang.String,java.lang.String> getPathParameters(boolean decode)
           
 java.util.List<PathSegment> getPathSegments()
           
 java.util.List<PathSegment> getPathSegments(boolean decode)
           
 java.util.List<PathSegment> getPathSegments(java.lang.String name)
          Get the path segments that contains a template variable.
 java.util.List<PathSegment> getPathSegments(java.lang.String name, boolean decode)
          Get the path segments that contains a template variable.
 java.util.Map<java.lang.String,java.lang.Object> getProperties()
          Get the mutable properties.
 MultivaluedMap<java.lang.String,java.lang.String> getQueryParameters()
           
 MultivaluedMap<java.lang.String,java.lang.String> getQueryParameters(boolean decode)
           
 HttpRequestContext getRequest()
          Get the HTTP request information.
 java.net.URI getRequestUri()
           
 UriBuilder getRequestUriBuilder()
           
 java.lang.Object getResource(java.lang.Class resourceClass)
          Get the resource instance from a resource class.
 HttpResponseContext getResponse()
          Get the HTTP response information.
 java.util.List<ContainerResponseFilter> getResponseFilters()
           
 UriRules<UriRule> getRules(java.lang.Class resourceClass)
          Get the rules for a resource class.
 ExtendedUriInfo getUriInfo()
          Get the extended URI information.
 boolean isTracingEnabled()
          Check if tracing is enabled.
 void pushContainerResponseFilters(java.util.List<ContainerResponseFilter> filters)
          Push a list of container response filters to apply after the container response has been produced.
 void pushMatch(UriTemplate template, java.util.List<java.lang.String> names)
          Push a match.
 void pushMethod(AbstractResourceMethod arm)
          Push the matching resource method.
 void pushResource(java.lang.Object resource)
          Push a matching resource.
 void pushRightHandPathLength(int rhpathlen)
          Push the right hand path length to calculate the entry for the list of matching (ancestor) URI paths.
 void setContainerRequest(ContainerRequest request)
          Set the container request.
 void setContainerResponse(ContainerResponse response)
          Set the container response.
 void setMatchResult(java.util.regex.MatchResult matchResult)
          Set the match result
 void trace(java.lang.String message)
          Add a trace message.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HTTP_METHOD_MATCH_RESOURCE

public static final java.lang.String HTTP_METHOD_MATCH_RESOURCE
See Also:
Constant Field Values
Constructor Detail

WebApplicationContext

public WebApplicationContext(WebApplicationImpl app,
                             ContainerRequest request,
                             ContainerResponse response)
Method Detail

createMatchResourceContext

public WebApplicationContext createMatchResourceContext(java.net.URI u)

getResponseFilters

public java.util.List<ContainerResponseFilter> getResponseFilters()

getRequest

public HttpRequestContext getRequest()
Description copied from interface: HttpContext
Get the HTTP request information.

Specified by:
getRequest in interface HttpContext
Returns:
the HTTP request information

getResponse

public HttpResponseContext getResponse()
Description copied from interface: HttpContext
Get the HTTP response information.

Specified by:
getResponse in interface HttpContext
Returns:
the HTTP response information

getUriInfo

public ExtendedUriInfo getUriInfo()
Description copied from interface: HttpContext
Get the extended URI information.

Specified by:
getUriInfo in interface HttpContext
Returns:
the extended URI information.

getProperties

public java.util.Map<java.lang.String,java.lang.Object> getProperties()
Description copied from interface: HttpContext
Get the mutable properties.

Care should be taken not to clear the properties or remove properties that are unknown otherwise unspecified behaviour may result.

Specified by:
getProperties in interface HttpContext
Returns:
the properties.

isTracingEnabled

public boolean isTracingEnabled()
Description copied from interface: Traceable
Check if tracing is enabled.

Specified by:
isTracingEnabled in interface Traceable
Returns:
true if tracing is enabled, otherwise false.

trace

public void trace(java.lang.String message)
Description copied from interface: Traceable
Add a trace message.

A trace message will be added if Traceable.isTracingEnabled() returns true and tracing contraints are satisfied.

Specified by:
trace in interface Traceable
Parameters:
message - the trace message to add.

getMatchResult

public java.util.regex.MatchResult getMatchResult()
Description copied from interface: UriMatchResultContext
Get the match result

Specified by:
getMatchResult in interface UriMatchResultContext
Returns:
the match result.

setMatchResult

public void setMatchResult(java.util.regex.MatchResult matchResult)
Description copied from interface: UriMatchResultContext
Set the match result

Specified by:
setMatchResult in interface UriMatchResultContext
Parameters:
matchResult - the match result.

getContainerRequest

public ContainerRequest getContainerRequest()
Description copied from interface: UriRuleContext
Get the container request.

Specified by:
getContainerRequest in interface UriRuleContext
Returns:
the container request.

setContainerRequest

public void setContainerRequest(ContainerRequest request)
Description copied from interface: UriRuleContext
Set the container request.

Specified by:
setContainerRequest in interface UriRuleContext
Parameters:
request - the container request.

getContainerResponse

public ContainerResponse getContainerResponse()
Description copied from interface: UriRuleContext
Get the container response.

Specified by:
getContainerResponse in interface UriRuleContext
Returns:
the container response.

setContainerResponse

public void setContainerResponse(ContainerResponse response)
Description copied from interface: UriRuleContext
Set the container response.

Specified by:
setContainerResponse in interface UriRuleContext
Parameters:
response - the container response.

pushContainerResponseFilters

public void pushContainerResponseFilters(java.util.List<ContainerResponseFilter> filters)
Description copied from interface: UriRuleContext
Push a list of container response filters to apply after the container response has been produced.

The list of response filters is processed in reverse order of last to first.

Specified by:
pushContainerResponseFilters in interface UriRuleContext
Parameters:
filters - the list container response filters

getResource

public java.lang.Object getResource(java.lang.Class resourceClass)
Description copied from interface: UriRuleContext
Get the resource instance from a resource class.

Specified by:
getResource in interface UriRuleContext
Parameters:
resourceClass - the resource class
Returns:
the resource instance

getRules

public UriRules<UriRule> getRules(java.lang.Class resourceClass)
Description copied from interface: UriRuleContext
Get the rules for a resource class.

Specified by:
getRules in interface UriRuleContext
Parameters:
resourceClass - the resource class that has rules
Returns:
the rules

pushMatch

public void pushMatch(UriTemplate template,
                      java.util.List<java.lang.String> names)
Description copied from interface: UriRuleContext
Push a match.

Specified by:
pushMatch in interface UriRuleContext
Parameters:
template - the matching URI template.
names - the parameter names associated with the capturing group values.

pushResource

public void pushResource(java.lang.Object resource)
Description copied from interface: UriRuleContext
Push a matching resource.

Specified by:
pushResource in interface UriRuleContext
Parameters:
resource - the matching resource

pushMethod

public void pushMethod(AbstractResourceMethod arm)
Description copied from interface: UriRuleContext
Push the matching resource method.

Specified by:
pushMethod in interface UriRuleContext
Parameters:
arm - the matching resource method.

pushRightHandPathLength

public void pushRightHandPathLength(int rhpathlen)
Description copied from interface: UriRuleContext
Push the right hand path length to calculate the entry for the list of matching (ancestor) URI paths.

Specified by:
pushRightHandPathLength in interface UriRuleContext
Parameters:
rhpathlen - the right hand length

getBaseUri

public java.net.URI getBaseUri()
Specified by:
getBaseUri in interface UriInfo

getBaseUriBuilder

public UriBuilder getBaseUriBuilder()
Specified by:
getBaseUriBuilder in interface UriInfo

getAbsolutePath

public java.net.URI getAbsolutePath()
Specified by:
getAbsolutePath in interface UriInfo

getAbsolutePathBuilder

public UriBuilder getAbsolutePathBuilder()
Specified by:
getAbsolutePathBuilder in interface UriInfo

getRequestUri

public java.net.URI getRequestUri()
Specified by:
getRequestUri in interface UriInfo

getRequestUriBuilder

public UriBuilder getRequestUriBuilder()
Specified by:
getRequestUriBuilder in interface UriInfo

getPath

public java.lang.String getPath()
Specified by:
getPath in interface UriInfo

getPath

public java.lang.String getPath(boolean decode)
Specified by:
getPath in interface UriInfo

getPathSegments

public java.util.List<PathSegment> getPathSegments()
Specified by:
getPathSegments in interface UriInfo

getPathSegments

public java.util.List<PathSegment> getPathSegments(boolean decode)
Specified by:
getPathSegments in interface UriInfo

getQueryParameters

public MultivaluedMap<java.lang.String,java.lang.String> getQueryParameters()
Specified by:
getQueryParameters in interface UriInfo

getQueryParameters

public MultivaluedMap<java.lang.String,java.lang.String> getQueryParameters(boolean decode)
Specified by:
getQueryParameters in interface UriInfo

getPathParameters

public MultivaluedMap<java.lang.String,java.lang.String> getPathParameters()
Specified by:
getPathParameters in interface UriInfo

getPathParameters

public MultivaluedMap<java.lang.String,java.lang.String> getPathParameters(boolean decode)
Specified by:
getPathParameters in interface UriInfo

getMatchedURIs

public java.util.List<java.lang.String> getMatchedURIs()
Specified by:
getMatchedURIs in interface UriInfo

getMatchedURIs

public java.util.List<java.lang.String> getMatchedURIs(boolean decode)
Specified by:
getMatchedURIs in interface UriInfo

getMatchedResources

public java.util.List<java.lang.Object> getMatchedResources()
Specified by:
getMatchedResources in interface UriInfo

getMatchedMethod

public AbstractResourceMethod getMatchedMethod()
Description copied from interface: ExtendedUriInfo
Get get matched resource method that was invoked.

Specified by:
getMatchedMethod in interface ExtendedUriInfo
Returns:
the matched resource method, otherwise null if no resource method was invoked.

getMappedThrowable

public java.lang.Throwable getMappedThrowable()
Description copied from interface: ExtendedUriInfo
Get the throwable that was mapped to a response.

A response filter or a message body writer may utilize this method to determine if a resource method was invoked but did not return a response because an exception was thrown from the resource method, or the resource method returned but a response filter threw an exception.

Specified by:
getMappedThrowable in interface ExtendedUriInfo
Returns:
the throwable that was mapped to a response, otherwise null if no throwable was mapped to a response.
See Also:
ContainerResponse.getMappedThrowable()

getMatchedResults

public java.util.List<java.util.regex.MatchResult> getMatchedResults()
Description copied from interface: ExtendedUriInfo
Get a read-only list of MatchResult for matched resources. Entries are ordered in reverse request URI matching order, with the root resource match result last.

Specified by:
getMatchedResults in interface ExtendedUriInfo
Returns:
a read-only list of match results for matched resources.

getMatchedTemplates

public java.util.List<UriTemplate> getMatchedTemplates()
Description copied from interface: ExtendedUriInfo
Get a read-only list of UriTemplate for matched resources. Each entry is a URI template that is the value of the Path that is a partial path that matched a resource class, a sub-resource method or a sub-resource locator. Entries are ordered in reverse request URI matching order, with the root resource URI template last.

Specified by:
getMatchedTemplates in interface ExtendedUriInfo
Returns:
a read-only list of URI templates for matched resources.

getPathSegments

public java.util.List<PathSegment> getPathSegments(java.lang.String name)
Description copied from interface: ExtendedUriInfo
Get the path segments that contains a template variable. All sequences of escaped octets are decoded, equivalent to getPathSegments(true).

Specified by:
getPathSegments in interface ExtendedUriInfo
Parameters:
name - the template variable name
Returns:
the path segments, the list will be empty the matching path does not contain the template

getPathSegments

public java.util.List<PathSegment> getPathSegments(java.lang.String name,
                                                   boolean decode)
Description copied from interface: ExtendedUriInfo
Get the path segments that contains a template variable.

Specified by:
getPathSegments in interface ExtendedUriInfo
Parameters:
name - the template variable name
decode - controls whether sequences of escaped octets are decoded (true) or not (false).
Returns:
the path segments, the list will be empty the matching path does not contain the template


Copyright © 2013 Oracle Corporation. All Rights Reserved.