Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/com/sun/net/httpserver/HttpContext.java
38922 views
1
/*
2
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation. Oracle designates this
8
* particular file as subject to the "Classpath" exception as provided
9
* by Oracle in the LICENSE file that accompanied this code.
10
*
11
* This code is distributed in the hope that it will be useful, but WITHOUT
12
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14
* version 2 for more details (a copy is included in the LICENSE file that
15
* accompanied this code).
16
*
17
* You should have received a copy of the GNU General Public License version
18
* 2 along with this work; if not, write to the Free Software Foundation,
19
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20
*
21
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22
* or visit www.oracle.com if you need additional information or have any
23
* questions.
24
*/
25
26
package com.sun.net.httpserver;
27
import java.net.*;
28
import java.io.*;
29
import java.util.*;
30
31
/**
32
* HttpContext represents a mapping between the root URI path of an application
33
* to a {@link HttpHandler} which is invoked to handle requests destined
34
* for that path on the associated HttpServer or HttpsServer.
35
* <p>
36
* HttpContext instances are created by the create methods in HttpServer
37
* and HttpsServer
38
* <p>
39
* A chain of {@link Filter} objects can be added to a HttpContext. All exchanges processed by the
40
* context can be pre- and post-processed by each Filter in the chain.
41
* @since 1.6
42
*/
43
@jdk.Exported
44
public abstract class HttpContext {
45
46
protected HttpContext () {
47
}
48
49
/**
50
* returns the handler for this context
51
* @return the HttpHandler for this context
52
*/
53
public abstract HttpHandler getHandler () ;
54
55
/**
56
* Sets the handler for this context, if not already set.
57
* @param h the handler to set for this context
58
* @throws IllegalArgumentException if this context's handler is already set.
59
* @throws NullPointerException if handler is <code>null</code>
60
*/
61
public abstract void setHandler (HttpHandler h) ;
62
63
/**
64
* returns the path this context was created with
65
* @return this context's path
66
*/
67
public abstract String getPath() ;
68
69
/**
70
* returns the server this context was created with
71
* @return this context's server
72
*/
73
public abstract HttpServer getServer () ;
74
75
/**
76
* returns a mutable Map, which can be used to pass
77
* configuration and other data to Filter modules
78
* and to the context's exchange handler.
79
* <p>
80
* Every attribute stored in this Map will be visible to
81
* every HttpExchange processed by this context
82
*/
83
public abstract Map<String,Object> getAttributes() ;
84
85
/**
86
* returns this context's list of Filters. This is the
87
* actual list used by the server when dispatching requests
88
* so modifications to this list immediately affect the
89
* the handling of exchanges.
90
*/
91
public abstract List<Filter> getFilters();
92
93
/**
94
* Sets the Authenticator for this HttpContext. Once an authenticator
95
* is establised on a context, all client requests must be
96
* authenticated, and the given object will be invoked to validate each
97
* request. Each call to this method replaces any previous value set.
98
* @param auth the authenticator to set. If <code>null</code> then any
99
* previously set authenticator is removed,
100
* and client authentication will no longer be required.
101
* @return the previous Authenticator, if any set, or <code>null</code>
102
* otherwise.
103
*/
104
public abstract Authenticator setAuthenticator (Authenticator auth);
105
106
/**
107
* Returns the currently set Authenticator for this context
108
* if one exists.
109
* @return this HttpContext's Authenticator, or <code>null</code>
110
* if none is set.
111
*/
112
public abstract Authenticator getAuthenticator ();
113
}
114
115