users@jersey.java.net

[Jersey] Re: Can _at_Context annotation be used be used in any class?

From: Farrukh Najmi <farrukh_at_wellfleetsoftware.com>
Date: Fri, 17 Feb 2012 09:48:38 -0500

Thanks Pavel, That worked fine. I got jersey to set the "@Context
UriInfo uriInfo;" in my MessageBodyWriter impl class. Then in that class
I called the new constructor to the ObjectWRapper impl class with the
new UriInfo parameter. Thanks again.

On 02/17/2012 09:20 AM, Pavel Bucek wrote:
> Hello,
>
> @Context annotated fields/params can be injected only into classes
> which are managed by Jersey. Resource and providers classes for example.
>
> If I understand correctly what you are doing, you should be able to
> create constructor for ObjectWrapper which would take UriInfo injected
> into current resource.
>
> Regards,
> Pavel
>
> On 2/17/12 3:03 PM, Farrukh Najmi wrote:
>>
>> Hi Guys,
>>
>> I am trying to use the "@Context UriInfo uriInfo;" annotation in a
>> ObjectWRapper impl class for a freemarker template and finding that
>> it is not being set.
>> The package for the class is declared in the init property
>> "com.sun.jersey.config.property.packages" for the
>> com.sun.jersey.spi.spring.container.servlet.SpringServlet used by the
>> webapp for my REST endpoint.
>>
>> Is there some other restriction that could be preventing jersey
>> runtime to be setting the "@Context UriInfo uriInfo;"?
>>
>> Thanks for any guidance on this.
>>
>


-- 
Regards,
Farrukh Najmi
Web: http://www.wellfleetsoftware.com