This is an automated email from the ASF dual-hosted git repository. ahuber pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/causeway.git
commit 1b2bf6842a8def044c623097d75b1890a56cc892 Author: Andi Huber <[email protected]> AuthorDate: Wed Jan 24 11:34:31 2024 +0100 CAUSEWAY-3668: deprecates previous emails service config --- .../core/config/CausewayConfiguration.java | 97 +++++++++++++++++++--- 1 file changed, 85 insertions(+), 12 deletions(-) diff --git a/core/config/src/main/java/org/apache/causeway/core/config/CausewayConfiguration.java b/core/config/src/main/java/org/apache/causeway/core/config/CausewayConfiguration.java index 7f05a9e4e1..79e67cba29 100644 --- a/core/config/src/main/java/org/apache/causeway/core/config/CausewayConfiguration.java +++ b/core/config/src/main/java/org/apache/causeway/core/config/CausewayConfiguration.java @@ -57,8 +57,6 @@ import javax.validation.constraints.Min; import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotNull; -import org.apache.causeway.applib.query.Query; - import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.DeprecatedConfigurationProperty; @@ -77,6 +75,7 @@ import org.apache.causeway.applib.annotation.LabelPosition; import org.apache.causeway.applib.annotation.PromptStyle; import org.apache.causeway.applib.annotation.SemanticsOf; import org.apache.causeway.applib.annotation.TableDecorator; +import org.apache.causeway.applib.query.Query; import org.apache.causeway.applib.services.i18n.Mode; import org.apache.causeway.applib.services.iactn.Execution; import org.apache.causeway.applib.services.publishing.spi.CommandSubscriber; @@ -171,7 +170,6 @@ public class CausewayConfiguration { * Or at least, from the {@link org.springframework.core.env.PropertySource} obtained from * {@link ConfigurableEnvironment#getPropertySources()} that are also {@link EnumerablePropertySource}s. * </p> - * @return */ public Stream<String> streamConfigurationPropertyNames() { MutablePropertySources propertySources = environment.getPropertySources(); @@ -189,7 +187,7 @@ public class CausewayConfiguration { * * @param configurationPropertyName - eg as obtained from {@link #streamConfigurationPropertyNames()}. */ - public Optional<String> valueOf(String configurationPropertyName) { + public Optional<String> valueOf(final String configurationPropertyName) { return Optional.ofNullable(environment.getProperty(configurationPropertyName)); } @@ -1813,18 +1811,49 @@ public class CausewayConfiguration { private final Email email = new Email(); @Data public static class Email { + + @Deprecated + private int port = 587; + /** * The port to use for sending email. + * + * @deprecated - ignored, instead use <code>spring.mail.port</code> */ - private int port = 587; + @Deprecated + @DeprecatedConfigurationProperty(replacement = "spring.mail.port") + public int getPort() { + return port; + } + + @Deprecated + private int socketConnectionTimeout = 2000; + /** * The maximum number of millseconds to wait to obtain a socket connection before timing out. + * + * @deprecated - ignored, instead use <code>spring.mail.properties.mail.smtp.connectiontimeout</code> */ - private int socketConnectionTimeout = 2000; + @Deprecated + @DeprecatedConfigurationProperty(replacement = "spring.mail.properties.mail.smtp.connectiontimeout") + public int getSocketConnectionTimeout() { + return socketConnectionTimeout; + } + + @Deprecated + private int socketTimeout = 2000; + /** * The maximum number of millseconds to wait to obtain a socket before timing out. + * + * @deprecated - ignored, instead use <code>spring.mail.properties.mail.smtp.timeout</code> */ - private int socketTimeout = 2000; + @Deprecated + @DeprecatedConfigurationProperty(replacement = "spring.mail.properties.mail.smtp.timeout") + public int getSocketTimeout() { + return socketTimeout; + } + /** * If an email fails to send, whether to propagate the exception (meaning that potentially the end-user * might see the exception), or whether instead to just indicate failure through the return value of @@ -1859,6 +1888,10 @@ public class CausewayConfiguration { private final Sender sender = new Sender(); @Data public static class Sender { + + @Deprecated + private String hostname; + /** * Specifies the host running the SMTP service. * @@ -1866,16 +1899,37 @@ public class CausewayConfiguration { * If not specified, then the value used depends upon the email implementation. The default * implementation will use the <code>mail.smtp.host</code> system property. * </p> + * + * @deprecated - now ignored, instead use <code>spring.mail.host</code> */ - private String hostname; + @Deprecated + @DeprecatedConfigurationProperty(replacement = "spring.mail.host") + public String getHostname() { + return hostname; + } + + @Deprecated + private String username; + /** * Specifies the username to use to connect to the SMTP service. * * <p> * If not specified, then the sender's {@link #getAddress() email address} will be used instead. * </p> + * + * @deprecated - now ignored, instead use <code>spring.mail.username</code> */ - private String username; + @Deprecated + @DeprecatedConfigurationProperty(replacement = "spring.mail.username") + public String getUsername() { + return username; + } + + @Deprecated + private String password; + + /** * Specifies the password (corresponding to the {@link #getUsername() username} to connect to the * SMTP service. @@ -1884,8 +1938,15 @@ public class CausewayConfiguration { * This configuration property is mandatory (for the default implementation of the * {@link org.apache.causeway.applib.services.email.EmailService}, at least). * </p> + * + * @deprecated - now ignored, instead use <code>spring.mail.password</code> */ - private String password; + @Deprecated + @DeprecatedConfigurationProperty(replacement = "spring.mail.password") + public String getPassword() { + return password; + } + /** * Specifies the email address of the user sending the email. * @@ -1903,13 +1964,24 @@ public class CausewayConfiguration { private String address; } + @Deprecated private final Tls tls = new Tls(); + @Deprecated @Data public static class Tls { + @Deprecated + private boolean enabled = true; + /** * Whether TLS encryption should be started (that is, <code>STARTTLS</code>). + * + * @deprecated - now ignored, instead use <code>spring.mail.javamail.properties.mail.smtp.starttls.enable</code> */ - private boolean enabled = true; + @Deprecated + @DeprecatedConfigurationProperty(replacement = "spring.mail.javamail.properties.mail.smtp.starttls.enable") + public boolean isEnabled() { + return enabled; + } } } @@ -1939,6 +2011,7 @@ public class CausewayConfiguration { * * @deprecated - use instead <code>causeway.persistence.commons.repository-service.disable-auto-flush</code> */ + @Deprecated @DeprecatedConfigurationProperty(replacement = "causeway.persistence.commons.repository-service.disable-auto-flush") public boolean isDisableAutoFlush() { return disableAutoFlush; @@ -3967,4 +4040,4 @@ public class CausewayConfiguration { } } -} +} \ No newline at end of file
