001    /*****************************************************************************
002     * Copyright (C) NanoContainer Organization. All rights reserved.            *
003     * ------------------------------------------------------------------------- *
004     * The software in this package is published under the terms of the BSD      *
005     * style license a copy of which has been included with this distribution in *
006     * the LICENSE.txt file.                                                     *
007     *                                                                           *
008     *****************************************************************************/
009    package org.nanocontainer.nanowar.axis;
010    
011    import org.apache.axis.transport.http.AxisServlet;
012    import org.nanocontainer.nanowar.ServletRequestContainerLauncher;
013    
014    import javax.servlet.ServletException;
015    import javax.servlet.http.HttpServletRequest;
016    import javax.servlet.http.HttpServletResponse;
017    import java.io.IOException;
018    
019    /**
020     * Extends AxisServlet to build a container for the request and kill it when
021     * the request is complete.
022     * 
023     * @author <a href="mailto:evan@bottch.com">Evan Bottcher</a>
024     */
025    public class NanoAxisServlet extends AxisServlet {
026    
027        public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException {
028            ServletRequestContainerLauncher containerLauncher = new ServletRequestContainerLauncher(getServletContext(), request);
029            try {
030                containerLauncher.startContainer();
031                super.service(request, response);
032            } catch (IOException e) {
033                throw new ServletException(e);
034            } finally {
035                containerLauncher.killContainer();
036            }
037        }
038    
039    }