package org.seasar.struts;

import java.io.IOException;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.logging.Log;
import org.apache.struts.action.ActionServlet;
import org.apache.struts.action.RequestProcessor;
import org.apache.struts.config.ModuleConfig;
import org.seasar.framework.container.S2Container;
import org.seasar.framework.container.factory.SingletonS2ContainerFactory;
import org.seasar.struts.processor.Acceptor;
import org.seasar.struts.processor.RequestProcessorFactory;

/**
 * @deprecated will delete it by the version of 1.2.X or more. 
 * @author Satoshi Kimura
 */
public class RequestProcessorUtil {

    private RequestProcessorUtil() {
    }

    public static void process(org.seasar.struts.processor.ExternalRequestProcessor processor,
            HttpServletRequest request, HttpServletResponse response, Log log) throws IOException, ServletException {
        Acceptor.process(processor, request, response, log);
    }

    public static RequestProcessor getRequestProcessor(ModuleConfig config, ServletContext context,
            ActionServlet actionServlet) throws ServletException {
        return getRequestProcessorCreator().getRequestProcessor(config, context, actionServlet);
    }

    private static RequestProcessorFactory getRequestProcessorCreator() {
        S2Container container = SingletonS2ContainerFactory.getContainer();
        return (RequestProcessorFactory) container.getComponent(RequestProcessorFactory.class);
    }
}