blob: 2c2da4af3cc90061610cc1d84bead2391edd4e97 [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Apache Wink : JAX-RS Context Information</title>
<link rel="stylesheet" href="styles/site.css" type="text/css" />
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<table class="pagecontent" border="0" cellpadding="0" cellspacing="0" width="100%" bgcolor="#ffffff">
<tr>
<td valign="top" class="pagebody">
<div class="pageheader">
<span class="pagetitle">
Apache Wink : JAX-RS Context Information
</span>
</div>
<div class="pagesubheading">
This page last changed on Aug 24, 2009 by <font color="#0050B2">bluk</font>.
</div>
<h1><a name="JAX-RSContextInformation-ContextInformation"></a>Context Information</h1>
<p>In addition to request parameters and entities, there is more request information that can be accessed via request @Context injected variables.</p>
<p>When a resource method is invoked, the runtime injects the @Context variables.</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
@Path(<span class="code-quote">"/resource"</span>)
<span class="code-keyword">public</span> class Resource {
@Context
<span class="code-keyword">private</span> HttpHeaders headers;
@GET
<span class="code-keyword">public</span> void get(@Context UriInfo uriInfo) {
/* use headers or uriInfo variable here */
}
}
</pre>
</div></div>
<p><a name="JAX-RSContextInformation-HttpHeaders"></a></p>
<h3><a name="JAX-RSContextInformation-javax.ws.rs.core.HttpHeaders"></a>javax.ws.rs.core.HttpHeaders</h3>
<p>HttpHeaders provides methods that allow users to access request headers. A few convenience methods such as #getAcceptableLanguages() and #getAcceptableMediaTypes() provide client preference sorted acceptable responses.</p>
<p><a name="JAX-RSContextInformation-UriInfo"></a></p>
<h3><a name="JAX-RSContextInformation-javax.ws.rs.core.UriInfo"></a>javax.ws.rs.core.UriInfo</h3>
<p>UriInfo provides methods so developers can find or build URI information of the current request.</p>
<p><a name="JAX-RSContextInformation-SecurityContext"></a></p>
<h3><a name="JAX-RSContextInformation-javax.ws.rs.core.SecurityContext"></a>javax.ws.rs.core.SecurityContext</h3>
<p>SecurityContext provides access to the security information.</p>
<p><a name="JAX-RSContextInformation-Request"></a></p>
<h3><a name="JAX-RSContextInformation-javax.ws.rs.core.Request"></a>javax.ws.rs.core.Request</h3>
<p>Request provides methods for evaluating preconditions and for selecting the best response variant based on the request headers.</p>
<p><a name="JAX-RSContextInformation-Providers"></a></p>
<h3><a name="JAX-RSContextInformation-javax.ws.rs.core.Providers"></a>javax.ws.rs.core.Providers</h3>
<p>Providers allows access to the user and runtime provided MessageBodyReaders, MessageBodyWriters, ContextResolvers, and ExceptionMappers. It is useful for other providers but can sometimes be useful for resource methods and classes.</p>
</td>
</tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td height="12" background="http://cwiki.apache.org/confluence/images/border/border_bottom.gif"><img src="images/border/spacer.gif" width="1" height="1" border="0"/></td>
</tr>
<tr>
<td align="center"><font color="grey">Document generated by Confluence on Nov 11, 2009 06:57</font></td>
</tr>
</table>
</body>
</html>