/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common Development * and Distribution License("CDDL") (collectively, the "License"). You * may not use this file except in compliance with the License. You can * obtain a copy of the License at * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html * or packager/legal/LICENSE.txt. See the License for the specific * language governing permissions and limitations under the License. * * When distributing the software, include this License Header Notice in each * file and include the License file at packager/legal/LICENSE.txt. * * GPL Classpath Exception: * Oracle designates this particular file as subject to the "Classpath" * exception as provided by Oracle in the GPL Version 2 section of the License * file that accompanied this code. * * Modifications: * If applicable, add the following below the License Header, with the fields * enclosed by brackets [] replaced by your own identifying information: * "Portions Copyright [year] [name of copyright owner]" * * Contributor(s): * If you wish your version of this file to be governed by only the CDDL or * only the GPL Version 2, indicate your decision by adding "[Contributor] * elects to include this software in this distribution under the [CDDL or GPL * Version 2] license." If you don't indicate a single choice of license, a * recipient has the option to distribute your version of this file under * either the CDDL, the GPL Version 2 or to extend the choice of license to * its licensees as provided above. However, if you add GPL Version 2 code * and therefore, elected the GPL Version 2 license, then the option applies * only if the new code is made subject to such option by the copyright * holder. * * * This file incorporates work covered by the following copyright and * permission notice: * * Copyright 2004 The Apache Software Foundation * * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.catalina; import org.glassfish.web.valve.GlassFishValve; import javax.servlet.ServletException; import java.io.IOException; /** * <p>Interface describing a collection of Valves that should be executed * in sequence when the <code>invoke()</code> method is invoked. It is * required that a Valve somewhere in the pipeline (usually the last one) * must process the request and create the corresponding response, rather * than trying to pass the request on.</p> * * <p>There is generally a single Pipeline instance associated with each * Container. The container's normal request processing functionality is * generally encapsulated in a container-specific Valve, which should always * be executed at the end of a pipeline. To facilitate this, the * <code>setBasic()</code> method is provided to set the Valve instance that * will always be executed last. Other Valves will be executed in the order * that they were added, before the basic Valve is executed.</p> * * @author Craig R. McClanahan * @author Peter Donald * @version $Revision: 1.2 $ $Date: 2005/12/08 01:27:18 $ */ public interface Pipeline { // ------------------------------------------------------------- Properties /** * <p>Return the Valve instance that has been distinguished as the basic * Valve for this Pipeline (if any). */ public GlassFishValve getBasic(); /** * <p>Set the Valve instance that has been distinguished as the basic * Valve for this Pipeline (if any). Prior to setting the basic Valve, * the Valve's <code>setContainer()</code> will be called, if it * implements <code>Contained</code>, with the owning Container as an * argument. The method may throw an <code>IllegalArgumentException</code> * if this Valve chooses not to be associated with this Container, or * <code>IllegalStateException</code> if it is already associated with * a different Container.</p> * * @param valve Valve to be distinguished as the basic Valve */ public void setBasic(GlassFishValve valve); /** * @return true if this pipeline has any non basic valves, false * otherwise */ public boolean hasNonBasicValves(); // --------------------------------------------------------- Public Methods /** * <p>Add a new Valve to the end of the pipeline associated with this * Container. Prior to adding the Valve, the Valve's * <code>setContainer()</code> method will be called, if it implements * <code>Contained</code>, with the owning Container as an argument. * The method may throw an * <code>IllegalArgumentException</code> if this Valve chooses not to * be associated with this Container, or <code>IllegalStateException</code> * if it is already associated with a different Container.</p> * * @param valve Valve to be added * * @exception IllegalArgumentException if this Container refused to * accept the specified Valve * @exception IllegalArgumentException if the specified Valve refuses to be * associated with this Container * @exception IllegalStateException if the specified Valve is already * associated with a different Container */ public void addValve(GlassFishValve valve); /** * Add Tomcat-style valve. * * @param valve the Tomcat-style valve to be added */ public void addValve(Valve valve); /** * Return the set of Valves in the pipeline associated with this * Container, including the basic Valve (if any). If there are no * such Valves, a zero-length array is returned. */ public GlassFishValve[] getValves(); /** * Cause the specified request and response to be processed by the Valves * associated with this pipeline, until one of these valves causes the * response to be created and returned. The implementation must ensure * that multiple simultaneous requests (on different threads) can be * processed through the same Pipeline without interfering with each * other's control flow. * * @param request The servlet request we are processing * @param response The servlet response we are creating * * @exception IOException if an input/output error occurs * @exception ServletException if a servlet exception is thrown */ public void invoke(Request request, Response response) throws IOException, ServletException; /** * Remove the specified Valve from the pipeline associated with this * Container, if it is found; otherwise, do nothing. If the Valve is * found and removed, the Valve's <code>setContainer(null)</code> method * will be called if it implements <code>Contained</code>. * * @param valve Valve to be removed */ public void removeValve(GlassFishValve valve); }