Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/com/sun/net/httpserver/HttpContext.java
38922 views
/*1* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package com.sun.net.httpserver;26import java.net.*;27import java.io.*;28import java.util.*;2930/**31* HttpContext represents a mapping between the root URI path of an application32* to a {@link HttpHandler} which is invoked to handle requests destined33* for that path on the associated HttpServer or HttpsServer.34* <p>35* HttpContext instances are created by the create methods in HttpServer36* and HttpsServer37* <p>38* A chain of {@link Filter} objects can be added to a HttpContext. All exchanges processed by the39* context can be pre- and post-processed by each Filter in the chain.40* @since 1.641*/42@jdk.Exported43public abstract class HttpContext {4445protected HttpContext () {46}4748/**49* returns the handler for this context50* @return the HttpHandler for this context51*/52public abstract HttpHandler getHandler () ;5354/**55* Sets the handler for this context, if not already set.56* @param h the handler to set for this context57* @throws IllegalArgumentException if this context's handler is already set.58* @throws NullPointerException if handler is <code>null</code>59*/60public abstract void setHandler (HttpHandler h) ;6162/**63* returns the path this context was created with64* @return this context's path65*/66public abstract String getPath() ;6768/**69* returns the server this context was created with70* @return this context's server71*/72public abstract HttpServer getServer () ;7374/**75* returns a mutable Map, which can be used to pass76* configuration and other data to Filter modules77* and to the context's exchange handler.78* <p>79* Every attribute stored in this Map will be visible to80* every HttpExchange processed by this context81*/82public abstract Map<String,Object> getAttributes() ;8384/**85* returns this context's list of Filters. This is the86* actual list used by the server when dispatching requests87* so modifications to this list immediately affect the88* the handling of exchanges.89*/90public abstract List<Filter> getFilters();9192/**93* Sets the Authenticator for this HttpContext. Once an authenticator94* is establised on a context, all client requests must be95* authenticated, and the given object will be invoked to validate each96* request. Each call to this method replaces any previous value set.97* @param auth the authenticator to set. If <code>null</code> then any98* previously set authenticator is removed,99* and client authentication will no longer be required.100* @return the previous Authenticator, if any set, or <code>null</code>101* otherwise.102*/103public abstract Authenticator setAuthenticator (Authenticator auth);104105/**106* Returns the currently set Authenticator for this context107* if one exists.108* @return this HttpContext's Authenticator, or <code>null</code>109* if none is set.110*/111public abstract Authenticator getAuthenticator ();112}113114115