/*
 * The contents of this file are subject to the Mozilla Public License Version 1.1
 * (the "License"); you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
 * 
 * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
 * WARRANTY OF ANY KIND, either express or implied. See the License for the specific
 * language governing rights and limitations under the License.
 * 
 * The Original Code is the Venice Web Communities System.
 * 
 * The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
 * for Silverwrist Design Studios.  Portions created by Eric J. Bowersox are
 * Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios.  All Rights Reserved.
 * 
 * Contributor(s): 
 */
package com.silverwrist.venice.ui.servlet;

import javax.servlet.*;
import org.apache.log4j.*;
import com.silverwrist.venice.core.*;
import com.silverwrist.venice.ui.*;
import com.silverwrist.venice.ui.config.*;

public class RemapperServlet extends BaseServlet
{
  /*--------------------------------------------------------------------------------
   * Static data members
   *--------------------------------------------------------------------------------
   */

  private static Category logger = Category.getInstance(RemapperServlet.class);

  private static final String REMAPPER_ATTR = "servlets.remapper.Remapper";

  /*--------------------------------------------------------------------------------
   * Implementations from class BaseServlet
   *--------------------------------------------------------------------------------
   */

  protected void init(ServletConfig config, ServletContext ctxt, VeniceEngine engine, RootConfig root,
		      String root_file_path)
  {
    Remapper r = root.getRemapper();
    RequestImpl.setAppAttribute(ctxt,REMAPPER_ATTR,r);

  } // end init

  public Object process(RequestInput req)
  {
    Remapper r = (Remapper)(req.getAppAttribute(REMAPPER_ATTR));
    return r.remapRequest(req);

  } // end process

} // end class RemapperServlet
