Hi Sam,
I am not able to reuse the guice servlet module. I checked the sources
and Guice turned out to be dead simple when it comes to scopes. So it
really surprised me that I am just free to use any means I want to store
and maintain scoped instances.
I just wrote a custom member injector referring to the RequestContext
object bound to the current thread directly and it was done. I was really
concerned that I would miss something might result into a side effect that
I should have been aware of, but it appears to be side effect free.
Cheers,
Martin (Kersten)
Am Sonntag, 10. November 2013 00:32:44 UTC+1 schrieb Sam Berlin:
>
> If I understand correctly, you should be able to use @RequestScoped and
> ServletScopes to do what you need. There's a transferRequest method that
> can transfer the scope to a callable that can be called from another
> thread. If you want to begin a new request scope for non-HTTP contexts,
> you can also use scopeRequest.
>
> We use the latter internally to scope requests non-HTTP requests, and the
> former to detach while waiting on blocking calls (and re-attach later).
>
> sam
> On Nov 9, 2013 6:25 PM, "Martin Kersten" <[email protected]<javascript:>>
> wrote:
>
>> Hi there,
>>
>> I am not new to Guice but was not using it for quite some years.
>> Currently I need a custom small web
>> framework that uses multi-pass document oriented rendering (creating and
>> manipulating a DOM tree instead
>> of rendering directly to output).
>>
>> I have the scopes PerThread and PerRequest. Those threads / requests are
>> asynchronous and therefore
>> can simple be detached and reattached to a worker thread.
>>
>> I checked the implementation of the Scopes for the Servlet and the
>> Singleton. It does looks straight forward
>> to implement such a detachable solution.
>>
>> Also I am using a RequestContext that stores all parts needed to process
>> (dispatch, model, render etc) a
>> request. So I simply bind the scopes to use the current request context
>> bind to the thread.
>>
>> Is there anything I have to remember or double check when I just detach
>> the context meaning replace one
>> with another or am I free to go ahead?
>>
>>
>> Cheers,
>>
>> Martin (Kersten),
>> Germany
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "google-guice" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected] <javascript:>.
>> To post to this group, send email to [email protected]<javascript:>
>> .
>> Visit this group at http://groups.google.com/group/google-guice.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
--
You received this message because you are subscribed to the Google Groups
"google-guice" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-guice.
For more options, visit https://groups.google.com/groups/opt_out.