You can -- that's what Request.getCurrent() gives you. Be careful not to
over-use thread-local context, though, particularly if you use or intend to
use asynchronous request handling (connectors for which are available in
recent Restlet releases). I'm not sure what happens when you call
Request.getCurrent() -- or any of the other getCurrent() static methods --
during handling that doesn't take place on the original request thread.

In the long run, your code will be more robust if you don't rely on
assumptions about thread-local context.

--tim

On Wed, Mar 28, 2012 at 2:32 AM, Mutaz Qasem <[email protected]> wrote:

> Thanks Tim. Actually the Validator is initiated in a Mapper class and the
> mapper class is initiated in the Resource that is handling the request. I
> asked my question because in Python, wherever your code is, you are still
> able to use  local()  which returns a dictionary of the contextual
> information of any executing thread.
> Of course you can add and remove entries form the local() dictionary as you
> wish.
>
> I thought, instead of having a chain of passing contextual data to the
> Mapper and then to the validator and change my code a lot to a fit the new
> change. I could have something similar to python that holds the executing
> thread context.
>
>
> Regards
> Mutaz
>
> --
> View this message in context:
> http://restlet-discuss.1400322.n2.nabble.com/Get-language-code-from-the-executing-thread-tp7409075p7412529.html
> Sent from the Restlet Discuss mailing list archive at Nabble.com.
>
> ------------------------------------------------------
>
> http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2941495
>

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

Reply via email to