001 /*******************************************************************************
002 * Copyright (C) PicoContainer Organization. All rights reserved.
003 * ---------------------------------------------------------------------------
004 * The software in this package is published under the terms of the BSD style
005 * license a copy of which has been included with this distribution in the
006 * LICENSE.txt file.
007 ******************************************************************************/
008 package org.picocontainer.web.struts;
009
010 import org.apache.struts.action.Action;
011 import org.apache.struts.action.ActionMapping;
012 import org.apache.struts.action.ActionServlet;
013
014 import javax.servlet.http.HttpServletRequest;
015
016 /**
017 * Uses Pico to produce Actions and inject dependencies into them. Only use this
018 * class if you are using Struts 1.0. If you are using Struts 1.1, use
019 * {@link PicoRequestProcessor} or {@link PicoTilesRequestProcessor} instead.
020 *
021 * @author Stephen Molitor
022 * @see PicoActionFactory
023 * @see PicoRequestProcessor
024 * @see PicoTilesRequestProcessor
025 */
026 @SuppressWarnings("serial")
027 public class PicoActionServlet extends ActionServlet {
028
029 private final PicoActionFactory actionFactory = new PicoActionFactory();
030
031 /**
032 * Creates or retrieves the action instance. The action is retrieved from
033 * the actions Pico container, using the mapping path as the component key.
034 * If no such action exists, a new one will be instantiated and placed in
035 * the actions container, thus injecting its dependencies.
036 *
037 * @param mapping the action mapping.
038 * @param request the HTTP request.
039 * @return the action instance.
040 */
041 protected Action processActionCreate(ActionMapping mapping, HttpServletRequest request) {
042 return actionFactory.getAction(request, mapping, this);
043 }
044
045 }