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.struts;
010
011 import org.apache.struts.action.Action;
012 import org.apache.struts.action.ActionMapping;
013 import org.apache.struts.action.ActionServlet;
014
015 import javax.servlet.http.HttpServletRequest;
016
017 /**
018 * Uses Pico to produce Actions and inject dependencies into them. Only use this class if you are using
019 * Struts 1.0. If you are using Struts 1.1, use {@link PicoRequestProcessor} or {@link PicoTilesRequestProcessor}
020 * instead.
021 *
022 * @author Stephen Molitor
023 * @see ActionFactory
024 * @see PicoRequestProcessor
025 * @see PicoTilesRequestProcessor
026 */
027 public class PicoActionServlet extends ActionServlet {
028
029 private final ActionFactory actionFactory = new ActionFactory();
030
031 /**
032 * Creates or retrieves the action instance. The action is retrieved from the actions
033 * Pico container, using the mapping path as the component key. If no such action exists,
034 * a new one will be instantiated and placed in the actions container, thus injecting
035 * 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,
042 HttpServletRequest request) {
043 return actionFactory.getAction(request, mapping, this);
044 }
045
046 }