Ok, thanks a lot for the advice guys! rod.
On 7 August 2011 14:48, Fred Faber <[email protected]> wrote: > You can use the implementation of RequestScope outside of a servlet > container. > Look here: > http://code.google.com/p/google-guice/source/browse/trunk/extensions/servlet/src/com/google/inject/servlet/ServletScopes.java#231 > You can call this method by wrapping your request thread's entry point in a > Callable. > For instance if your logic now is: > public void handlRequest(...) { > ...handles the request > } > You'd do: > public void handleRequest(...) { > ServletScopes.scopeRequest(new Callable<Void>() { > @Override public Void call() throws Exception { > scopedHandleRequest9); > } > }, Collections.emptyMap()).call(); > } > > /** This is the original handleRequest, but renamed... */ > private void scopedHandleRequest(...) { > .... > } > Fred > On Sun, Aug 7, 2011 at 5:38 AM, rod <[email protected]> wrote: >> >> Hi. Yes I did read these docs, but my app implements it's own simple web >> server and does not use servlets or a servlet container, which is why I was >> confused about if I'd be able to use this. Re reading the docs it still >> doesn't seem possible to use the servlet request scope in my application, >> and it looks like I will need to write a custom scope. Can anyone confirm >> this please? >> >> Thanks a lot, >> Rod. >> >> On Sunday, 7 August 2011, Christopher Currie <[email protected]> >> wrote: >> > Have you looked at the Guice Servlet [1] extension? Among other >> > features, it defines a @Request scope that is designed for exactly >> > what you describe. >> > >> > [1] http://code.google.com/p/google-guice/wiki/Servlets >> > >> > >> > On 8/6/11, rod <[email protected]> wrote: >> >> My application implements its own web server and I'd like to have a >> >> scope for the request/response/etc... objects that get created on each >> >> request and injected into all the individual request handling classes. >> >> at the moment these are being manually created and injected, but i'd >> >> like to be able to do this with guice. i've been reading the docs but >> >> need a little advice - can i accomplish this with any of the built in >> >> guice scopes, or will i need to create a custom scope (docs say this >> >> is not reccomended!). >> >> >> >> thanks, >> >> rod. >> >> >> >> -- >> >> You received this message because you are subscribed to the Google >> >> Groups >> >> "google-guice" group. >> >> To post to this group, send email to [email protected]. >> >> To unsubscribe from this group, send email to >> >> [email protected]. >> >> For more options, visit this group at >> >> http://groups.google.com/group/google-guice?hl=en. >> >> >> >> >> > >> > -- >> > You received this message because you are subscribed to the Google >> > Groups "google-guice" group. >> > To post to this group, send email to [email protected]. >> > To unsubscribe from this group, send email to >> > [email protected]. >> > For more options, visit this group at >> > http://groups.google.com/group/google-guice?hl=en. >> > >> > >> >> -- >> You received this message because you are subscribed to the Google Groups >> "google-guice" group. >> To post to this group, send email to [email protected]. >> To unsubscribe from this group, send email to >> [email protected]. >> For more options, visit this group at >> http://groups.google.com/group/google-guice?hl=en. > > -- > You received this message because you are subscribed to the Google Groups > "google-guice" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/google-guice?hl=en. > -- You received this message because you are subscribed to the Google Groups "google-guice" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-guice?hl=en.
