cxf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Hendy Irawan (JIRA)" <>
Subject [jira] Commented: (CXF-2335) Support @Context injection for JAX-RS Subresources
Date Thu, 09 Jul 2009 11:09:15 GMT


Hendy Irawan commented on CXF-2335:

I agree with you.

In practice, I've resolved the problem using the solutions you provided.

I'm still curious though, because I'm not really sure how dependency injection is supposed
to work in "ideal" work.

In a Spring+CXF DI-"controlled" app, beans can be created manually (as in "return new SubResource()")
or by Spring. Furthermore, the beans can be configured by Spring, by CXF, manually, or by
any combination of them.

However, I'm not aware of how to turn a bean that is manually created, into configured by
CXF. I'm thinking of something like:

public SubResource getSub(@Context CXFContext ctx) {
  SubResource subRes = new SubResource();
  ctx.configureBean(subRes); // this will inject any necessary annotated fields etc.
  return subRes;

That way will allow SubResource interface/implementation to change independently, and the
root resource not need to care about injecting CXF/JAX-RS related dependencies. However I'm
not sure if that's the correct approach as well.

I think a best practice for this should be provided in the CXF user guide especially under
JAX-RS page.

> Support @Context injection for JAX-RS Subresources
> --------------------------------------------------
>                 Key: CXF-2335
>                 URL:
>             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.

View raw message