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 javax.servlet.http.HttpServletRequest;
011 import javax.servlet.http.HttpServletResponse;
012
013 import org.apache.struts.action.Action;
014 import org.apache.struts.action.ActionMapping;
015 import org.apache.struts.tiles.TilesRequestProcessor;
016
017 /**
018 * Uses Pico to produce Actions and inject dependencies into them. Use this
019 * class if you are using the Tiles library. If not, you can use the
020 * {@link org.picocontainer.web.struts.PicoRequestProcessor} instead.
021 *
022 * @author Stephen Molitor
023 * @see PicoActionFactory
024 * @see org.picocontainer.web.struts.PicoRequestProcessor
025 */
026 public class PicoTilesRequestProcessor extends TilesRequestProcessor {
027
028 private final PicoActionFactory actionFactory = new PicoActionFactory();
029
030 /**
031 * Creates or retrieves the action instance. The action is retrieved from
032 * the actions Pico container, using the mapping path as the component key.
033 * If no such action exists, a new one will be instantiated and placed in
034 * the actions container, thus injecting its dependencies.
035 *
036 * @param request the HTTP request object.
037 * @param response the HTTP response object.
038 * @param mapping the action mapping.
039 * @return the action instance.
040 */
041 protected Action processActionCreate(HttpServletRequest request, HttpServletResponse response, ActionMapping mapping) {
042 return actionFactory.getAction(request, mapping, servlet);
043 }
044
045 }