Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/jdk.httpserver/share/classes/com/sun/net/httpserver/HttpContext.java
41159 views
1
/*
2
* Copyright (c) 2005, 2020, 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.util.List;
28
import java.util.Map;
29
30
/**
31
* {@code HttpContext} represents a mapping between the root {@link java.net.URI}
32
* path of an application to a {@link HttpHandler} which is invoked to handle
33
* requests destined for that path on the associated {@link HttpServer} or
34
* {@link HttpsServer}.
35
*
36
* <p> {@code HttpContext} instances are created by the create methods in
37
* {@code HttpServer} and {@code HttpsServer}.
38
*
39
* <p> A chain of {@link Filter} objects can be added to a {@code HttpContext}.
40
* All exchanges processed by the context can be pre- and post-processed by each
41
* {@code Filter} in the chain.
42
*
43
* @since 1.6
44
*/
45
public abstract class HttpContext {
46
47
/**
48
* Constructor for subclasses to call.
49
*/
50
protected HttpContext() {
51
}
52
53
/**
54
* Returns the handler for this context.
55
*
56
* @return the {@code HttpHandler} for this context
57
*/
58
public abstract HttpHandler getHandler();
59
60
/**
61
* Sets the handler for this context, if not already set.
62
*
63
* @param handler the handler to set for this context
64
* @throws IllegalArgumentException if the context for this handler is already set.
65
* @throws NullPointerException if handler is {@code null}
66
*/
67
public abstract void setHandler(HttpHandler handler);
68
69
/**
70
* Returns the path this context was created with.
71
*
72
* @return the context of this path
73
*/
74
public abstract String getPath();
75
76
/**
77
* Returns the server this context was created with.
78
*
79
* @return the context of this server
80
*/
81
public abstract HttpServer getServer();
82
83
/**
84
* Returns a mutable {@link Map}, which can be used to pass configuration
85
* and other data to {@link Filter} modules and to the context's exchange
86
* handler.
87
*
88
* <p> Every attribute stored in this {@code Map} will be visible to every
89
* {@code HttpExchange} processed by this context.
90
*
91
* @return a {@code Map} containing the attributes of this context
92
*/
93
public abstract Map<String,Object> getAttributes() ;
94
95
/**
96
* Returns this context's {@link List} of {@linkplain Filter filters}. This
97
* is the actual list used by the server when dispatching requests so
98
* modifications to this list immediately affect the the handling of exchanges.
99
*
100
* @return a {@link List} containing the filters of this context
101
*/
102
public abstract List<Filter> getFilters();
103
104
/**
105
* Sets the {@link Authenticator} for this {@code HttpContext}. Once an authenticator
106
* is establised on a context, all client requests must be authenticated,
107
* and the given object will be invoked to validate each request. Each call
108
* to this method replaces any previous value set.
109
*
110
* @param auth the {@code Authenticator} to set. If {@code null} then any previously
111
* set {@code Authenticator} is removed, and client authentication
112
* will no longer be required.
113
* @return the previous {@code Authenticator}, if any set, or {@code null} otherwise.
114
*/
115
public abstract Authenticator setAuthenticator(Authenticator auth);
116
117
/**
118
* Returns the currently set {@link Authenticator} for this context
119
* if one exists.
120
*
121
* @return this {@linkplain HttpContext HttpContext's} {@code Authenticator},
122
* or {@code null} if none is set
123
*/
124
public abstract Authenticator getAuthenticator();
125
}
126
127