9/26/2012

Wrapping the call in Seam contexts

http://seamframework.org/Documentation/ReplacingServletsWithSeamResources#H-WrappingTheCallInSeamContexts

1. You can map the <web:context-filter/> in components.xml to wrap all calls on a particular URL pattern, see reference documentation.

2. You can wrap a call manually in a particular Servlet:

class MyServlet extends HttpServlet {

    protected void service(final HttpServletRequest request, final HttpServletResponse response)
            throws ServletException, IOException {

        new ContextualHttpServletRequest(request) {
            @Override
            public void process() throws Exception {
                doWork(request, response);
            }
        }.run();
    }

    private void doWork(HttpServletRequest request, HttpServletResponse response) {
        Component.getInstance(...);
    }

}

No comments:

Post a Comment