001/* 002 * This library is part of OpenCms - 003 * the Open Source Content Management System 004 * 005 * Copyright (c) Alkacon Software GmbH & Co. KG (http://www.alkacon.com) 006 * 007 * This library is free software; you can redistribute it and/or 008 * modify it under the terms of the GNU Lesser General Public 009 * License as published by the Free Software Foundation; either 010 * version 2.1 of the License, or (at your option) any later version. 011 * 012 * This library is distributed in the hope that it will be useful, 013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 015 * Lesser General Public License for more details. 016 * 017 * For further information about Alkacon Software GmbH & Co. KG, please see the 018 * company website: http://www.alkacon.com 019 * 020 * For further information about OpenCms, please see the 021 * project website: http://www.opencms.org 022 * 023 * You should have received a copy of the GNU Lesser General Public 024 * License along with this library; if not, write to the Free Software 025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 026 */ 027 028package org.opencms.main; 029 030import org.opencms.configuration.CmsParameterConfiguration; 031 032import java.io.IOException; 033 034import javax.servlet.ServletException; 035import javax.servlet.http.HttpServletRequest; 036import javax.servlet.http.HttpServletResponse; 037 038/** 039 * Describes an OpenCms request handler.<p> 040 * 041 * Request handlers are used for special requests to OpenCms 042 * that should NOT be mapped to a VFS resource. 043 * A request handler URI always start with <code>/handle</code> and then 044 * one or more possible handler names as defined with the {@link #getHandlerNames()} 045 * method.<p> 046 * 047 * For example, if a registerd request handler has the name <code>"MyName"</code>, 048 * any request (in a simple setup) to <code>/opencms/opencms/handlerMyName...</code> will directly be transfered 049 * to the {@link #handle(HttpServletRequest, HttpServletResponse, String)} method of this 050 * handler.<p> 051 * 052 * In essence, the request handlers are like simplified mini-servlets that run inside OpenCms. 053 * Of course they are not intended as replacements for real servlets. 054 * In case you require sophisticated lifecycle support use a genuine servlet instead.<p> 055 * 056 * @since 6.0.0 057 */ 058public interface I_CmsRequestHandler { 059 060 /** 061 * Gets the configuration. 062 * 063 * @return the configuration 064 */ 065 default CmsParameterConfiguration getConfiguration() { 066 067 return new CmsParameterConfiguration(); 068 } 069 070 /** 071 * Returns the handler name.<p> 072 * 073 * @return the handler name 074 */ 075 String[] getHandlerNames(); 076 077 /** 078 * Handles an OpenCms request.<p> 079 * 080 * @param req the current request 081 * @param res the current response 082 * @param name the handler name to invoke 083 * @throws ServletException in case an error occurs 084 * @throws IOException in case an error occurs 085 */ 086 void handle(HttpServletRequest req, HttpServletResponse res, String name) throws IOException, ServletException; 087 088 /** 089 * Initializes parameters. 090 * 091 * @param params the map of parameters 092 */ 093 default void initParameters(CmsParameterConfiguration params) { 094 095 // do nothing 096 } 097}