Skip to content

Commit d128191

Browse files
committed
8253473: Javadoc clean up in HttpHandler, HttpPrincipal, HttpContext, and HttpsConfigurator
Reviewed-by: dfuchs
1 parent 379ba80 commit d128191

File tree

4 files changed

+121
-102
lines changed

4 files changed

+121
-102
lines changed

src/jdk.httpserver/share/classes/com/sun/net/httpserver/HttpContext.java

Lines changed: 57 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -28,89 +28,98 @@
2828
import java.util.Map;
2929

3030
/**
31-
* HttpContext represents a mapping between the root URI path of an application
32-
* to a {@link HttpHandler} which is invoked to handle requests destined
33-
* for that path on the associated HttpServer or HttpsServer.
34-
* <p>
35-
* HttpContext instances are created by the create methods in HttpServer
36-
* and HttpsServer
37-
* <p>
38-
* A chain of {@link Filter} objects can be added to a HttpContext. All exchanges processed by the
39-
* context can be pre- and post-processed by each Filter in the chain.
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+
*
4043
* @since 1.6
4144
*/
4245
public abstract class HttpContext {
4346

4447
/**
4548
* Constructor for subclasses to call.
4649
*/
47-
protected HttpContext () {
50+
protected HttpContext() {
4851
}
4952

5053
/**
51-
* returns the handler for this context
52-
* @return the HttpHandler for this context
54+
* Returns the handler for this context.
55+
*
56+
* @return the {@code HttpHandler} for this context
5357
*/
54-
public abstract HttpHandler getHandler () ;
58+
public abstract HttpHandler getHandler();
5559

5660
/**
5761
* Sets the handler for this context, if not already set.
58-
* @param h the handler to set for this context
59-
* @throws IllegalArgumentException if this context's handler is already set.
60-
* @throws NullPointerException if handler is <code>null</code>
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}
6166
*/
62-
public abstract void setHandler (HttpHandler h) ;
67+
public abstract void setHandler(HttpHandler handler);
6368

6469
/**
65-
* returns the path this context was created with
66-
* @return this context's path
70+
* Returns the path this context was created with.
71+
*
72+
* @return the context of this path
6773
*/
68-
public abstract String getPath() ;
74+
public abstract String getPath();
6975

7076
/**
71-
* returns the server this context was created with
72-
* @return this context's server
77+
* Returns the server this context was created with.
78+
*
79+
* @return the context of this server
7380
*/
74-
public abstract HttpServer getServer () ;
81+
public abstract HttpServer getServer();
7582

7683
/**
77-
* returns a mutable Map, which can be used to pass
78-
* configuration and other data to Filter modules
79-
* and to the context's exchange handler.
80-
* <p>
81-
* Every attribute stored in this Map will be visible to
82-
* every HttpExchange processed by this context
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.
8390
*
84-
* @return a map containing the attributes of this context
91+
* @return a {@code Map} containing the attributes of this context
8592
*/
8693
public abstract Map<String,Object> getAttributes() ;
8794

8895
/**
89-
* returns this context's list of Filters. This is the
90-
* actual list used by the server when dispatching requests
91-
* so modifications to this list immediately affect the
92-
* the handling of exchanges.
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
93101
*/
94102
public abstract List<Filter> getFilters();
95103

96104
/**
97-
* Sets the Authenticator for this HttpContext. Once an authenticator
98-
* is establised on a context, all client requests must be
99-
* authenticated, and the given object will be invoked to validate each
100-
* request. Each call to this method replaces any previous value set.
101-
* @param auth the authenticator to set. If <code>null</code> then any
102-
* previously set authenticator is removed,
103-
* and client authentication will no longer be required.
104-
* @return the previous Authenticator, if any set, or <code>null</code>
105-
* otherwise.
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.
106114
*/
107-
public abstract Authenticator setAuthenticator (Authenticator auth);
115+
public abstract Authenticator setAuthenticator(Authenticator auth);
108116

109117
/**
110-
* Returns the currently set Authenticator for this context
118+
* Returns the currently set {@link Authenticator} for this context
111119
* if one exists.
112-
* @return this HttpContext's Authenticator, or <code>null</code>
113-
* if none is set.
120+
*
121+
* @return this {@linkplain HttpContext HttpContext's} {@code Authenticator},
122+
* or {@code null} if none is set
114123
*/
115-
public abstract Authenticator getAuthenticator ();
124+
public abstract Authenticator getAuthenticator();
116125
}

src/jdk.httpserver/share/classes/com/sun/net/httpserver/HttpHandler.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,18 @@
3030
/**
3131
* A handler which is invoked to process HTTP exchanges. Each
3232
* HTTP exchange is handled by one of these handlers.
33+
*
3334
* @since 1.6
3435
*/
3536
public interface HttpHandler {
3637
/**
3738
* Handle the given request and generate an appropriate response.
3839
* See {@link HttpExchange} for a description of the steps
3940
* involved in handling an exchange.
41+
*
4042
* @param exchange the exchange containing the request from the
41-
* client and used to send the response
42-
* @throws NullPointerException if exchange is <code>null</code>
43+
* client and used to send the response
44+
* @throws NullPointerException if exchange is {@code null}
4345
*/
4446
public abstract void handle (HttpExchange exchange) throws IOException;
4547
}

src/jdk.httpserver/share/classes/com/sun/net/httpserver/HttpPrincipal.java

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,14 @@ public class HttpPrincipal implements Principal {
3434
private String username, realm;
3535

3636
/**
37-
* creates a HttpPrincipal from the given username and realm
38-
* @param username The name of the user within the realm
39-
* @param realm The realm.
40-
* @throws NullPointerException if either username or realm are null
37+
* Creates a {@code HttpPrincipal} from the given {@code username} and
38+
* {@code realm}.
39+
*
40+
* @param username the name of the user within the realm
41+
* @param realm the realm for this user
42+
* @throws NullPointerException if either username or realm are {@code null}
4143
*/
42-
public HttpPrincipal (String username, String realm) {
44+
public HttpPrincipal(String username, String realm) {
4345
if (username == null || realm == null) {
4446
throw new NullPointerException();
4547
}
@@ -48,12 +50,16 @@ public HttpPrincipal (String username, String realm) {
4850
}
4951

5052
/**
51-
* Compares two HttpPrincipal. Returns <code>true</code>
52-
* if <i>another</i> is an instance of HttpPrincipal, and its
53-
* username and realm are equal to this object's username
54-
* and realm. Returns <code>false</code> otherwise.
53+
* Compare two instances of {@code HttpPrincipal}. Returns {@code true} if
54+
* <i>another</i> is an instance of {@code HttpPrincipal}, and its username
55+
* and realm are equal to this object's username and realm. Returns {@code false}
56+
* otherwise.
57+
*
58+
* @param another the object to compare this instance of {@code HttpPrincipal} against
59+
* @return {@code true} or {@code false} depending on whether objects are
60+
* equal or not
5561
*/
56-
public boolean equals (Object another) {
62+
public boolean equals(Object another) {
5763
if (!(another instanceof HttpPrincipal)) {
5864
return false;
5965
}
@@ -63,41 +69,47 @@ public boolean equals (Object another) {
6369
}
6470

6571
/**
66-
* returns the contents of this principal in the form
67-
* <i>realm:username</i>
72+
* Returns the contents of this principal in the form
73+
* <i>realm:username</i>.
74+
*
75+
* @return the contents of this principal in the form realm:username
6876
*/
6977
public String getName() {
7078
return username;
7179
}
7280

7381
/**
74-
* returns the username this object was created with.
82+
* Returns the {@code username} this object was created with.
7583
*
76-
* @return The name of the user assoicated with this object
84+
* @return the name of the user associated with this object
7785
*/
7886
public String getUsername() {
7987
return username;
8088
}
8189

8290
/**
83-
* returns the realm this object was created with.
91+
* Returns the {@code realm} this object was created with.
8492
*
85-
* @return The realm associated with this object
93+
* @return the realm associated with this object
8694
*/
8795
public String getRealm() {
8896
return realm;
8997
}
9098

9199
/**
92-
* returns a hashcode for this HttpPrincipal. This is calculated
93-
* as <code>(getUsername()+getRealm().hashCode()</code>
100+
* Returns a hashcode for this {@code HttpPrincipal}. This is calculated
101+
* as {@code (getUsername()+getRealm()).hashCode()}.
102+
*
103+
* @return the hashcode for this object
94104
*/
95105
public int hashCode() {
96106
return (username+realm).hashCode();
97107
}
98108

99109
/**
100-
* returns the same string as getName()
110+
* Returns the same string as {@link #getName()}.
111+
*
112+
* @return the name associated with this object
101113
*/
102114
public String toString() {
103115
return getName();

src/jdk.httpserver/share/classes/com/sun/net/httpserver/HttpsConfigurator.java

Lines changed: 29 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,17 @@
2525

2626
package com.sun.net.httpserver;
2727

28-
import java.net.*;
29-
import java.io.*;
30-
import java.nio.*;
31-
import java.security.*;
32-
import java.nio.channels.*;
33-
import java.util.*;
34-
import java.util.concurrent.*;
35-
import javax.net.ssl.*;
28+
import javax.net.ssl.SSLContext;
29+
import javax.net.ssl.SSLParameters;
3630

3731

3832
/**
3933
* This class is used to configure the https parameters for each incoming
40-
* https connection on a HttpsServer. Applications need to override
34+
* https connection on a {@link HttpsServer}. Applications need to override
4135
* the {@link #configure(HttpsParameters)} method in order to change
4236
* the default configuration.
43-
* <p>
44-
* The following <a id="example">example</a> shows how this may be done:
37+
*
38+
* <p> The following <a id="example">example</a> shows how this may be done:
4539
*
4640
* <blockquote><pre>
4741
* SSLContext sslContext = SSLContext.getInstance (....);
@@ -65,52 +59,54 @@
6559
* }
6660
* });
6761
* </pre></blockquote>
62+
*
6863
* @since 1.6
6964
*/
7065
public class HttpsConfigurator {
7166

7267
private SSLContext context;
7368

7469
/**
75-
* Creates an Https configuration, with the given SSLContext.
76-
* @param context the SSLContext to use for this configurator
77-
* @throws NullPointerException if no SSLContext supplied
70+
* Creates a Https configuration, with the given {@link SSLContext}.
71+
*
72+
* @param context the {@code SSLContext} to use for this configurator
73+
* @throws NullPointerException if no {@code SSLContext} supplied
7874
*/
79-
public HttpsConfigurator (SSLContext context) {
75+
public HttpsConfigurator(SSLContext context) {
8076
if (context == null) {
8177
throw new NullPointerException ("null SSLContext");
8278
}
8379
this.context = context;
8480
}
8581

8682
/**
87-
* Returns the SSLContext for this HttpsConfigurator.
88-
* @return the SSLContext
83+
* Returns the {@link SSLContext} for this {@code HttpsConfigurator}.
84+
*
85+
* @return the {@code SSLContext}
8986
*/
9087
public SSLContext getSSLContext() {
9188
return context;
9289
}
9390

94-
//BEGIN_TIGER_EXCLUDE
9591
/**
96-
* Called by the HttpsServer to configure the parameters
97-
* for a https connection currently being established.
98-
* The implementation of configure() must call
99-
* {@link HttpsParameters#setSSLParameters(SSLParameters)}
100-
* in order to set the SSL parameters for the connection.
101-
* <p>
102-
* The default implementation of this method uses the
103-
* SSLParameters returned from <p>
104-
* {@code getSSLContext().getDefaultSSLParameters()}
105-
* <p>
106-
* configure() may be overridden in order to modify this behavior.
107-
* See, the example <a href="#example">above</a>.
108-
* @param params the HttpsParameters to be configured.
92+
* Called by the {@link HttpsServer} to configure the parameters for a https
93+
* connection currently being established. The implementation of configure()
94+
* must call {@link HttpsParameters#setSSLParameters(SSLParameters)} in order
95+
* to set the SSL parameters for the connection.
96+
*
97+
* <p> The default implementation of this method uses the
98+
* SSLParameters returned from:
99+
*
100+
* <p> {@code getSSLContext().getDefaultSSLParameters()}
101+
*
102+
* <p> configure() may be overridden in order to modify this behavior. See
103+
* example <a href="#example">above</a>.
104+
*
105+
* @param params the {@code HttpsParameters} to be configured
109106
*
110107
* @since 1.6
111108
*/
112-
public void configure (HttpsParameters params) {
109+
public void configure(HttpsParameters params) {
113110
params.setSSLParameters (getSSLContext().getDefaultSSLParameters());
114111
}
115-
//END_TIGER_EXCLUDE
116112
}

0 commit comments

Comments
 (0)