On 21/01/11 22:10, cowwoc wrote:
Hi Willi,
How do you do that? Can you please post some code that shows
cleaning up Closeables on scope shutdown?
Take a look at some classes in https://github.com/palava/palava-scope.
Note that these are totally custom made scopes,
i have no idea how to do that with the RequestScope. I think guiceyfruit
supports that but they rely
on a patched version of Guice, so that is not really an option (for me).
Thank you,
Gili
On 21/01/2011 3:52 PM, Willi Schönborn wrote:
I successfully used custom scope implementations which check for
instances which require proper destruction (Closeables, @PreDestroy,
...).
This requires of course some kind of a strictly defined exit point.
On 21/01/11 21:49, cowwoc wrote:
Good point. Is there a way to check if a Connection has already
been instantiated?
Also, is there a cleaner way of passing an Injector to
ConnectionFilter? Right now I am depending upon the fact that
GuiceServletContextFilter sets an attribute with the name
"Injector.class.getName()". This is an implementation detail that
may change in the future. Is there a way for me to pass an Injector
from GuiceServletContextFilter as a filter parameter? I saw thought
of passing parameters using:
filter("/*").through(ConnectionFilter.class, param);
but the Injector hasn't been instantiated at that point.
Thanks,
Gili
On 21/01/2011 3:38 PM, Willi Schönborn wrote:
You should be aware that this might create and open
a jdbc connection just to close it right away.
On 21/01/11 21:36, cowwoc wrote:
Hi,
Following up on this earlier discussion:
http://groups.google.com/group/google-guice/browse_frm/thread/7252f908ef00638a/9a59803c16a9583e?lnk=gst&q=clean+%40requestscoped#9a59803c16a9583e
What is the best way to clean up a @RequestScoped JDBC connection? Am
I supposed to register a second ServletFilter after GuiceFilter
(shown
below) or is there an easier way?
public class ConnectionFilter implements Filter
{
private ServletContext context;
@Override
public void init(FilterConfig filterConfig) throws
ServletException
{
this.context = filterConfig.getServletContext();
}
@Override
public void doFilter(ServletRequest servletRequest,
ServletResponse
servletResponse,
FilterChain chain)
throws IOException, ServletException
{
Injector injector = (Injector)
context.getAttribute(Injector.class.getName());
Connection connection =
injector.getInstance(Connection.class);
try
{
chain.doFilter(servletRequest, servletResponse);
}
finally
{
connection.close();
}
}
@Override
public void destroy()
{
}
}
Thanks,
Gili
--
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.