01: /*****************************************************************************
02: * Copyright (C) NanoContainer Organization. All rights reserved. *
03: * ------------------------------------------------------------------------- *
04: * The software in this package is published under the terms of the BSD *
05: * style license a copy of which has been included with this distribution in *
06: * the LICENSE.txt file. *
07: * *
08: *****************************************************************************/package com.opensymphony.webwork.pico;
09:
10: import com.opensymphony.webwork.dispatcher.ServletDispatcher;
11: import com.opensymphony.xwork.ActionProxyFactory;
12: import org.nanocontainer.nanowar.ServletRequestContainerLauncher;
13:
14: import javax.servlet.ServletException;
15: import javax.servlet.http.HttpServletRequest;
16: import javax.servlet.http.HttpServletResponse;
17:
18: /**
19: * Extension to the standard WebWork2 ServletDispatcher that instantiates
20: * a new container in the request scope for each request and disposes of it
21: * correctly at the end of the request.
22: * <p/>
23: * To use, replace the WebWork ServletDispatcher in web.xml with this.
24: *
25: * @deprecated Use {@link PicoFilterDispatcher}
26: * @author <a href="mailto:joe@thoughtworks.net">Joe Walnes</a>
27: */
28: public class PicoWebWork2ServletDispatcher extends ServletDispatcher {
29:
30: public PicoWebWork2ServletDispatcher() {
31: super ();
32: ActionProxyFactory.setFactory(new PicoActionProxyFactory());
33: }
34:
35: public void service(HttpServletRequest request,
36: HttpServletResponse response) throws ServletException {
37: ServletRequestContainerLauncher containerLauncher = new ServletRequestContainerLauncher(
38: getServletContext(), request);
39: try {
40: containerLauncher.startContainer();
41: // process the servlet using webwork2
42: super.service(request, response);
43: } finally {
44: containerLauncher.killContainer();
45: }
46: }
47: }
|