This content has been marked as final.
Show 2 replies
-
1. Re: How to manage conversation with restful application
diegocoronel Dec 23, 2011 10:41 AM (in response to diegocoronel)Hi, i did a filter to enable conversation and everything is working as expected, but i wanna know if can i have any problems or memory leaks with my solution:
@WebFilter( urlPatterns = "/rest/*") public class RestFilter implements Filter { @Override public void destroy() { } @Override public void doFilter(ServletRequest arg0, ServletResponse arg1, FilterChain arg2) throws IOException, ServletException { String cid = ( String ) arg0.getParameterMap().get("cid")[0]; ConversationContext conversationContext = instance().select(HttpConversationContext.class).get(); if ( !conversationContext.isActive() ) { try { conversationContext.activate( cid ); } catch ( NonexistentConversationException non ) { } } arg2.doFilter(arg0, arg1); conversationContext.invalidate(); conversationContext.deactivate(); } @Override public void init(FilterConfig arg0) throws ServletException { } private static Instance<Context> instance() { return Container.instance().deploymentManager().instance().select(Context.class); } }
This filter is applied only for my rest services.
-
2. Re: How to manage conversation with restful application
jharting Jan 10, 2012 3:55 AM (in response to diegocoronel)FYI, Weld 2 (not released yet) has conversation support for every Servlet request. See WeldListener for details.