You could write a simple filter("/*")... that injects and calls close() on
the PersistenceManager in a try/finally block.

FYI guice-persist will provide some kind of automation for this particular
use case.

Dhanji.

On Fri, Jul 2, 2010 at 1:06 PM, Andrew Wiley <[email protected]> wrote:

> If I have an object that is RequestScoped, and I use a Provider to get
> instances of it while processing requests, is there any way to call a method
> on the object when request processing is complete? Specifically, on the
> Google App Engine, my understanding is that PersistenceManagers should be
> RequestScoped because they aren't thread safe, but I need to call the
> close() methodwhen I finish handling the Request. The danger is that if I
> get the same PersistenceManager in multiple methods, it becomes hard to know
> when to close it and when not to.
> I guess I could just create one whenever I needed it instead of tying it to
> the Request, but each PersistenceManager embodies a database connection in
> JDO. I'll have to look up how that works when it's tied to the BigTable
> backend and see whether having possibly hundreds or thousands of
> PersistenceManagers is okay in that case, but I know it's not normally okay.
> Could anyone advise me here?
>
> Andrew Wiley
>
> --
> 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]<google-guice%[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.

Reply via email to