Fix missing metadata for nested POJO

This commit fixes missing descriptions and default values when
applicable for `management.server.ssl`, `server.compression`,
`server.http2`, `server.servlet.jsp`, `server.servlet.session` and
`server.ssl`.

Those nested namespace are managed by a POJO that is declared outside
of the module of the target @ConfigurationProperties type using it. As
a result, the annotation processor has no access to the source model and
can't extract the description and the default value, if any.

This commit migrates the misleading field-level Javadoc to manual meta
data for the time being.

Closes gh-14669
This commit is contained in:
Stephane Nicoll
2018-10-04 15:49:04 +02:00
parent a2203268f9
commit 1b10d3fcbf
8 changed files with 441 additions and 179 deletions

View File

@@ -21,32 +21,25 @@ package org.springframework.boot.web.server;
*
* @author Ivan Sopov
* @author Andy Wilkinson
* @author Stephane Nicoll
* @since 2.0.0
*/
public class Compression {
/**
* Whether response compression is enabled.
*/
private boolean enabled = false;
/**
* Comma-separated list of MIME types that should be compressed.
*/
private String[] mimeTypes = new String[] { "text/html", "text/xml", "text/plain",
"text/css", "text/javascript", "application/javascript", "application/json",
"application/xml" };
/**
* Comma-separated list of user agents for which responses should not be compressed.
*/
private String[] excludedUserAgents = null;
/**
* Minimum "Content-Length" value that is required for compression to be performed.
*/
private int minResponseSize = 2048;
/**
* Return whether response compression is enabled.
* @return {@code true} if response compression is enabled
*/
public boolean getEnabled() {
return this.enabled;
}
@@ -55,6 +48,10 @@ public class Compression {
this.enabled = enabled;
}
/**
* Return the MIME types that should be compressed.
* @return the MIME types that should be compressed
*/
public String[] getMimeTypes() {
return this.mimeTypes;
}
@@ -63,14 +60,10 @@ public class Compression {
this.mimeTypes = mimeTypes;
}
public int getMinResponseSize() {
return this.minResponseSize;
}
public void setMinResponseSize(int minSize) {
this.minResponseSize = minSize;
}
/**
* Return the user agents for which responses should not be compressed.
* @return the user agents for which responses should not be compressed.
*/
public String[] getExcludedUserAgents() {
return this.excludedUserAgents;
}
@@ -79,4 +72,17 @@ public class Compression {
this.excludedUserAgents = excludedUserAgents;
}
/**
* Return the minimum "Content-Length" value that is required for compression to be
* performed.
* @return the minimum content size in bytes that is required for compression
*/
public int getMinResponseSize() {
return this.minResponseSize;
}
public void setMinResponseSize(int minSize) {
this.minResponseSize = minSize;
}
}

View File

@@ -24,11 +24,12 @@ package org.springframework.boot.web.server;
*/
public class Http2 {
/**
* Whether to enable HTTP/2 support, if the current environment supports it.
*/
private boolean enabled = false;
/**
* Return whether to enable HTTP/2 support, if the current environment supports it.
* @return {@code true} to enable HTTP/2 support
*/
public boolean isEnabled() {
return this.enabled;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2017 the original author or authors.
* Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,86 +21,45 @@ package org.springframework.boot.web.server;
*
* @author Andy Wilkinson
* @author Vladimir Tsanev
* @author Stephane Nicoll
* @since 2.0.0
*/
public class Ssl {
/**
* Whether to enable SSL support.
*/
private boolean enabled = true;
/**
* Whether client authentication is wanted ("want") or needed ("need"). Requires a
* trust store.
*/
private ClientAuth clientAuth;
/**
* Supported SSL ciphers.
*/
private String[] ciphers;
/**
* Enabled SSL protocols.
*/
private String[] enabledProtocols;
/**
* Alias that identifies the key in the key store.
*/
private String keyAlias;
/**
* Password used to access the key in the key store.
*/
private String keyPassword;
/**
* Path to the key store that holds the SSL certificate (typically a jks file).
*/
private String keyStore;
/**
* Password used to access the key store.
*/
private String keyStorePassword;
/**
* Type of the key store.
*/
private String keyStoreType;
/**
* Provider for the key store.
*/
private String keyStoreProvider;
/**
* Trust store that holds SSL certificates.
*/
private String trustStore;
/**
* Password used to access the trust store.
*/
private String trustStorePassword;
/**
* Type of the trust store.
*/
private String trustStoreType;
/**
* Provider for the trust store.
*/
private String trustStoreProvider;
/**
* SSL protocol to use.
*/
private String protocol = "TLS";
/**
* Return whether to enable SSL support.
* @return whether to enable SSL support
*/
public boolean isEnabled() {
return this.enabled;
}
@@ -109,6 +68,11 @@ public class Ssl {
this.enabled = enabled;
}
/**
* Return Whether client authentication is wanted ("want") or needed ("need").
* Requires a trust store.
* @return the {@link ClientAuth} to use
*/
public ClientAuth getClientAuth() {
return this.clientAuth;
}
@@ -117,6 +81,10 @@ public class Ssl {
this.clientAuth = clientAuth;
}
/**
* Return the supported SSL ciphers.
* @return the supported SSL ciphers
*/
public String[] getCiphers() {
return this.ciphers;
}
@@ -125,54 +93,10 @@ public class Ssl {
this.ciphers = ciphers;
}
public String getKeyAlias() {
return this.keyAlias;
}
public void setKeyAlias(String keyAlias) {
this.keyAlias = keyAlias;
}
public String getKeyPassword() {
return this.keyPassword;
}
public void setKeyPassword(String keyPassword) {
this.keyPassword = keyPassword;
}
public String getKeyStore() {
return this.keyStore;
}
public void setKeyStore(String keyStore) {
this.keyStore = keyStore;
}
public String getKeyStorePassword() {
return this.keyStorePassword;
}
public void setKeyStorePassword(String keyStorePassword) {
this.keyStorePassword = keyStorePassword;
}
public String getKeyStoreType() {
return this.keyStoreType;
}
public void setKeyStoreType(String keyStoreType) {
this.keyStoreType = keyStoreType;
}
public String getKeyStoreProvider() {
return this.keyStoreProvider;
}
public void setKeyStoreProvider(String keyStoreProvider) {
this.keyStoreProvider = keyStoreProvider;
}
/**
* Return the enabled SSL protocols.
* @return the enabled SSL protocols.
*/
public String[] getEnabledProtocols() {
return this.enabledProtocols;
}
@@ -181,6 +105,83 @@ public class Ssl {
this.enabledProtocols = enabledProtocols;
}
/**
* Return the alias that identifies the key in the key store.
* @return the key alias
*/
public String getKeyAlias() {
return this.keyAlias;
}
public void setKeyAlias(String keyAlias) {
this.keyAlias = keyAlias;
}
/**
* Return the password used to access the key in the key store.
* @return the key password
*/
public String getKeyPassword() {
return this.keyPassword;
}
public void setKeyPassword(String keyPassword) {
this.keyPassword = keyPassword;
}
/**
* Return the path to the key store that holds the SSL certificate (typically a jks
* file).
* @return the path to the key store
*/
public String getKeyStore() {
return this.keyStore;
}
public void setKeyStore(String keyStore) {
this.keyStore = keyStore;
}
/**
* Return the password used to access the key store.
* @return the key store password
*/
public String getKeyStorePassword() {
return this.keyStorePassword;
}
public void setKeyStorePassword(String keyStorePassword) {
this.keyStorePassword = keyStorePassword;
}
/**
* Return the type of the key store.
* @return the key store type
*/
public String getKeyStoreType() {
return this.keyStoreType;
}
public void setKeyStoreType(String keyStoreType) {
this.keyStoreType = keyStoreType;
}
/**
* Return the provider for the key store.
* @return the key store provider
*/
public String getKeyStoreProvider() {
return this.keyStoreProvider;
}
public void setKeyStoreProvider(String keyStoreProvider) {
this.keyStoreProvider = keyStoreProvider;
}
/**
* Return the trust store that holds SSL certificates.
* @return the trust store
*/
public String getTrustStore() {
return this.trustStore;
}
@@ -189,6 +190,10 @@ public class Ssl {
this.trustStore = trustStore;
}
/**
* Return the password used to access the trust store.
* @return the trust store password
*/
public String getTrustStorePassword() {
return this.trustStorePassword;
}
@@ -197,6 +202,10 @@ public class Ssl {
this.trustStorePassword = trustStorePassword;
}
/**
* Return the type of the trust store.
* @return the trust store type
*/
public String getTrustStoreType() {
return this.trustStoreType;
}
@@ -205,6 +214,10 @@ public class Ssl {
this.trustStoreType = trustStoreType;
}
/**
* Return the provider for the trust store.
* @return the trust store provider
*/
public String getTrustStoreProvider() {
return this.trustStoreProvider;
}
@@ -213,6 +226,10 @@ public class Ssl {
this.trustStoreProvider = trustStoreProvider;
}
/**
* Return the SSL protocol to use.
* @return the SSL protocol
*/
public String getProtocol() {
return this.protocol;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2017 the original author or authors.
* Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,21 +23,17 @@ import java.util.Map;
* Configuration for the server's JSP servlet.
*
* @author Andy Wilkinson
* @author Stephane Nicoll
* @since 2.0.0
*/
public class Jsp {
/**
* The class name of the servlet to use for JSPs. If registered is true and this class
* is on the classpath then it will be registered. Since both Tomcat and Jetty use
* Jasper for their JSP implementation the default is
* org.apache.jasper.servlet.JspServlet.
* Class name of the servlet to use for JSPs. If registered is true and this class is
* on the classpath then it will be registered.
*/
private String className = "org.apache.jasper.servlet.JspServlet";
/**
* Init parameters used to configure the JSP servlet.
*/
private Map<String, String> initParameters = new HashMap<>();
/**
@@ -49,6 +45,12 @@ public class Jsp {
this.initParameters.put("development", "false");
}
/**
* Return the class name of the servlet to use for JSPs. If {@link #getRegistered()
* registered} is {@code true} and this class is on the classpath then it will be
* registered.
* @return the class name of the servlet to use for JSPs
*/
public String getClassName() {
return this.className;
}
@@ -57,6 +59,10 @@ public class Jsp {
this.className = className;
}
/**
* Return the init parameters used to configure the JSP servlet.
* @return the init parameters
*/
public Map<String, String> getInitParameters() {
return this.initParameters;
}
@@ -65,6 +71,10 @@ public class Jsp {
this.initParameters = initParameters;
}
/**
* Return whether the JSP servlet is registered.
* @return {@code true} to register the JSP servlet
*/
public boolean getRegistered() {
return this.registered;
}

View File

@@ -31,20 +31,11 @@ import org.springframework.boot.convert.DurationUnit;
*/
public class Session {
/**
* Session timeout. If a duration suffix is not specified, seconds will be used.
*/
@DurationUnit(ChronoUnit.SECONDS)
private Duration timeout = Duration.ofMinutes(30);
/**
* Session tracking modes (one or more of the following: "cookie", "url", "ssl").
*/
private Set<Session.SessionTrackingMode> trackingModes;
/**
* Whether to persist session data between restarts.
*/
private boolean persistent;
/**
@@ -68,6 +59,10 @@ public class Session {
this.timeout = timeout;
}
/**
* Return the {@link SessionTrackingMode session tracking modes}.
* @return the session tracking modes
*/
public Set<Session.SessionTrackingMode> getTrackingModes() {
return this.trackingModes;
}
@@ -76,6 +71,10 @@ public class Session {
this.trackingModes = trackingModes;
}
/**
* Return whether to persist session data between restarts.
* @return {@code true} to persist session data between restarts.
*/
public boolean isPersistent() {
return this.persistent;
}
@@ -84,6 +83,10 @@ public class Session {
this.persistent = persistent;
}
/**
* Return the directory used to store session data.
* @return the session data store directory
*/
public File getStoreDir() {
return this.storeDir;
}
@@ -102,42 +105,25 @@ public class Session {
*/
public static class Cookie {
/**
* Session cookie name.
*/
private String name;
/**
* Domain for the session cookie.
*/
private String domain;
/**
* Path of the session cookie.
*/
private String path;
/**
* Comment for the session cookie.
*/
private String comment;
/**
* "HttpOnly" flag for the session cookie.
*/
private Boolean httpOnly;
/**
* "Secure" flag for the session cookie.
*/
private Boolean secure;
/**
* Maximum age of the session cookie.
*/
@DurationUnit(ChronoUnit.SECONDS)
private Duration maxAge;
/**
* Return the session cookie name.
* @return the session cookie name
*/
public String getName() {
return this.name;
}
@@ -146,6 +132,10 @@ public class Session {
this.name = name;
}
/**
* Return the domain for the session cookie.
* @return the session cookie domain
*/
public String getDomain() {
return this.domain;
}
@@ -154,6 +144,10 @@ public class Session {
this.domain = domain;
}
/**
* Return the path of the session cookie.
* @return the session cookie path
*/
public String getPath() {
return this.path;
}
@@ -162,6 +156,10 @@ public class Session {
this.path = path;
}
/**
* Return the comment for the session cookie.
* @return the session cookie comment
*/
public String getComment() {
return this.comment;
}
@@ -170,6 +168,10 @@ public class Session {
this.comment = comment;
}
/**
* Return whether to use "HttpOnly" cookies for session cookies.
* @return {@code true} to use "HttpOnly" cookies for session cookies.
*/
public Boolean getHttpOnly() {
return this.httpOnly;
}
@@ -178,6 +180,11 @@ public class Session {
this.httpOnly = httpOnly;
}
/**
* Return whether to always mark the session cookie as secure.
* @return {@code true} to mark the session cookie as secure even if the request
* that initiated the corresponding session is using plain HTTP
*/
public Boolean getSecure() {
return this.secure;
}
@@ -186,6 +193,10 @@ public class Session {
this.secure = secure;
}
/**
* Return the maximum age of the session cookie.
* @return the maximum age of the session cookie
*/
public Duration getMaxAge() {
return this.maxAge;
}