Hi Jerome,

yes, should be a solution for it.
But it's not the JAX-RS like injection, what a JAX-RS developer now.

best regards
   Stephan

Jerome Louvel schrieb:
> Hi Stephan,
>
> Can't he just use the static accessor instead?
>
>       Context.getCurrent().getParameters();
>
> Best regards,
> Jerome Louvel
> --
> Restlet ~ Founder and Lead developer ~ http://www.restlet.org
> Noelios Technologies ~ Co-founder ~ http://www.noelios.com
>
>
> -----Message d'origine-----
> De : [email protected] [mailto:[email protected]] 
> Envoye : vendredi 30 janvier 2009 09:17
> A : [email protected]
> Objet : Re: JAX-RS and context/application attributes
>
> Hi,
>
> this is not supported for now. The reason ist, that values injected to 
> @Context must be accessable from different threads, and every thread mus 
> get the values for it's own thread. This requires a Context (Request, 
> Response, ...) subclass which contains a ThreadLocal variable to the 
> Context (...) for every method and so on. If Context (...) are 
> interfaces, this is easy, now you have to ensure that the subclass 
> override all public methods ith the right behaviour. If someone knows an 
> easy way to generate this at runtime (javassist, ??), please let me know.
>
> best regards
>    Stephan
>   
>> Could anyone please provide the example how to pass the application 
>> deployment attributes (that I set up when rest application
>>     
> starts) to the concrete JAX-RS Resource.
>   
>> Example:
>>
>> I want to provide the parameter to my JAXRSApplication 
>> // create JAX-RS runtime environment
>> Context c  = comp.getContext().createChildContext();
>> c.getParameters().add("key", "value");
>> final JaxRsApplication application = new JaxRsApplication(c);
>>
>> And later I want to get the access to them in Resource
>> @Path("path")
>> public class WeaveVersionResource {
>> @Context org.restlet.Context 
>> {            
>> System.err.println(context.getParameters().getFirstValue("key"));
>> }
>>
>>
>> When execute this code, it states that "class org.restlet.Context must not 
>> be annotated with @Context"
>>
>> How can I access these values? I assume I may need to register (use) 
>> javax.ws.rs.ext.Providers for this purpose, but don't know
>>     
> how. 
>   
>> If I would play with standard (regular) restlet I will have "MyResource 
>> extends Resource"  and will use inherited getContext() for
>>     
> this purpose. 
>   
>> Thus any example how to do this with JAX-RS is needed.

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=1081724

Reply via email to