[
https://issues.apache.org/jira/browse/CXF-2335?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12729198#action_12729198
]
Sergey Beryozkin commented on CXF-2335:
---------------------------------------
This will always work, irrespectively of the combination of various underlying
technologies and it will be a thread-safe solution :
public class GroupsResource {
private UriInfo uriInfo;
private GroupResource gr1 = new GroupResource();
@Context
public void setUriInfo(UriInfo ui) {
uriInfo = ui;
gr1.setUriInfo(uriInfo);
}
@Path("group1")
public GroupResource group1() {
return gr1;
}
@Path("group2")
public GroupResource group2() {
GroupResource gr2 = new GroupResource();
gr2.setUriInfo(uriInfo);
return gr2;
}
}
It will also work well in cases when users try to do proxy-based client
invocations, as client proxies do not support @Context parameters on resource
methods.
In meantime I will see what I can do with respect to the context injection into
subresources... Perhaps in some cases modifying the subresource classes with
extra methods might not be an option.
> Support @Context injection for JAX-RS Subresources
> --------------------------------------------------
>
> Key: CXF-2335
> URL: https://issues.apache.org/jira/browse/CXF-2335
> Project: CXF
> Issue Type: Improvement
> Components: REST
> Affects Versions: 2.2.2
> Reporter: Hendy Irawan
>
> This works in Jersey, but not in CXF:
> class ........ {
> @Context
> private UriInfo context;
> }
> The alternative, works on both CXF and Jersey:
> class ...... {
> @GET
> public void something(@Context UriInfo context) {
> ...
> }
> }
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.