This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/master by this push: new 1633722 CAMEL-13712: camel-mail should use hostname and port from custom MailSession if its been configured. 1633722 is described below commit 1633722c072360420d31a67e42937ebdcc3a9260 Author: Claus Ibsen <claus.ib...@gmail.com> AuthorDate: Wed Aug 7 08:58:07 2019 +0200 CAMEL-13712: camel-mail should use hostname and port from custom MailSession if its been configured. --- .../camel-mail/src/main/docs/mail-component.adoc | 2 +- .../camel/component/mail/MailConfiguration.java | 10 +++++- .../endpoint/dsl/MailEndpointBuilderFactory.java | 36 +++++++++++----------- .../springboot/MailComponentConfiguration.java | 6 ++-- 4 files changed, 31 insertions(+), 23 deletions(-) diff --git a/components/camel-mail/src/main/docs/mail-component.adoc b/components/camel-mail/src/main/docs/mail-component.adoc index 1fe6255..946d9ff 100644 --- a/components/camel-mail/src/main/docs/mail-component.adoc +++ b/components/camel-mail/src/main/docs/mail-component.adoc @@ -176,7 +176,7 @@ with the following path and query parameters: | *headerFilterStrategy* (advanced) | To use a custom org.apache.camel.spi.HeaderFilterStrategy to filter headers. | | HeaderFilterStrategy | *ignoreUnsupportedCharset* (advanced) | Option to let Camel ignore unsupported charset in the local JVM when sending mails. If the charset is unsupported then charset=XXX (where XXX represents the unsupported charset) is removed from the content-type and it relies on the platform default instead. | false | boolean | *ignoreUriScheme* (advanced) | Option to let Camel ignore unsupported charset in the local JVM when sending mails. If the charset is unsupported then charset=XXX (where XXX represents the unsupported charset) is removed from the content-type and it relies on the platform default instead. | false | boolean -| *session* (advanced) | Specifies the mail session that camel should use for all mail interactions. Useful in scenarios where mail sessions are created and managed by some other resource, such as a JavaEE container. If this is not specified, Camel automatically creates the mail session for you. | | Session +| *session* (advanced) | Specifies the mail session that camel should use for all mail interactions. Useful in scenarios where mail sessions are created and managed by some other resource, such as a JavaEE container. When using a custom mail session, then the hostname and port from the mail session will be used (if configured on the session). | | Session | *synchronous* (advanced) | Sets whether synchronous processing should be strictly used, or Camel is allowed to use asynchronous processing (if supported). | false | boolean | *useInlineAttachments* (advanced) | Whether to use disposition inline or attachment. | false | boolean | *idempotentRepository* (filter) | A pluggable repository org.apache.camel.spi.IdempotentRepository which allows to cluster consuming from the same mailbox, and let the repository coordinate whether a mail message is valid for the consumer to process. By default no repository is in use. | | IdempotentRepository diff --git a/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailConfiguration.java b/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailConfiguration.java index d1abdd8..abb8dc7 100644 --- a/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailConfiguration.java +++ b/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailConfiguration.java @@ -201,6 +201,14 @@ public class MailConfiguration implements Cloneable { } if (session != null) { answer.setSession(session); + String host = session.getProperty("mail.smtp.host"); + if (host != null && !host.isEmpty()) { + answer.setHost(host); + } + String port = session.getProperty("mail.smtp.port"); + if (port != null && !port.isEmpty()) { + answer.setPort(Integer.parseInt(port)); + } } else { ClassLoader tccl = Thread.currentThread().getContextClassLoader(); try { @@ -394,7 +402,7 @@ public class MailConfiguration implements Cloneable { /** * Specifies the mail session that camel should use for all mail interactions. Useful in scenarios where * mail sessions are created and managed by some other resource, such as a JavaEE container. - * If this is not specified, Camel automatically creates the mail session for you. + * When using a custom mail session, then the hostname and port from the mail session will be used (if configured on the session). */ public void setSession(Session session) { this.session = session; diff --git a/core/camel-endpointdsl/src/main/java/org/apache/camel/builder/endpoint/dsl/MailEndpointBuilderFactory.java b/core/camel-endpointdsl/src/main/java/org/apache/camel/builder/endpoint/dsl/MailEndpointBuilderFactory.java index af2507c..c376b9c 100644 --- a/core/camel-endpointdsl/src/main/java/org/apache/camel/builder/endpoint/dsl/MailEndpointBuilderFactory.java +++ b/core/camel-endpointdsl/src/main/java/org/apache/camel/builder/endpoint/dsl/MailEndpointBuilderFactory.java @@ -1442,9 +1442,9 @@ public interface MailEndpointBuilderFactory { /** * Specifies the mail session that camel should use for all mail * interactions. Useful in scenarios where mail sessions are created and - * managed by some other resource, such as a JavaEE container. If this - * is not specified, Camel automatically creates the mail session for - * you. + * managed by some other resource, such as a JavaEE container. When + * using a custom mail session, then the hostname and port from the mail + * session will be used (if configured on the session). * * The option is a: <code>javax.mail.Session</code> type. * @@ -1457,9 +1457,9 @@ public interface MailEndpointBuilderFactory { /** * Specifies the mail session that camel should use for all mail * interactions. Useful in scenarios where mail sessions are created and - * managed by some other resource, such as a JavaEE container. If this - * is not specified, Camel automatically creates the mail session for - * you. + * managed by some other resource, such as a JavaEE container. When + * using a custom mail session, then the hostname and port from the mail + * session will be used (if configured on the session). * * The option will be converted to a <code>javax.mail.Session</code> * type. @@ -2035,9 +2035,9 @@ public interface MailEndpointBuilderFactory { /** * Specifies the mail session that camel should use for all mail * interactions. Useful in scenarios where mail sessions are created and - * managed by some other resource, such as a JavaEE container. If this - * is not specified, Camel automatically creates the mail session for - * you. + * managed by some other resource, such as a JavaEE container. When + * using a custom mail session, then the hostname and port from the mail + * session will be used (if configured on the session). * * The option is a: <code>javax.mail.Session</code> type. * @@ -2050,9 +2050,9 @@ public interface MailEndpointBuilderFactory { /** * Specifies the mail session that camel should use for all mail * interactions. Useful in scenarios where mail sessions are created and - * managed by some other resource, such as a JavaEE container. If this - * is not specified, Camel automatically creates the mail session for - * you. + * managed by some other resource, such as a JavaEE container. When + * using a custom mail session, then the hostname and port from the mail + * session will be used (if configured on the session). * * The option will be converted to a <code>javax.mail.Session</code> * type. @@ -2488,9 +2488,9 @@ public interface MailEndpointBuilderFactory { /** * Specifies the mail session that camel should use for all mail * interactions. Useful in scenarios where mail sessions are created and - * managed by some other resource, such as a JavaEE container. If this - * is not specified, Camel automatically creates the mail session for - * you. + * managed by some other resource, such as a JavaEE container. When + * using a custom mail session, then the hostname and port from the mail + * session will be used (if configured on the session). * * The option is a: <code>javax.mail.Session</code> type. * @@ -2503,9 +2503,9 @@ public interface MailEndpointBuilderFactory { /** * Specifies the mail session that camel should use for all mail * interactions. Useful in scenarios where mail sessions are created and - * managed by some other resource, such as a JavaEE container. If this - * is not specified, Camel automatically creates the mail session for - * you. + * managed by some other resource, such as a JavaEE container. When + * using a custom mail session, then the hostname and port from the mail + * session will be used (if configured on the session). * * The option will be converted to a <code>javax.mail.Session</code> * type. diff --git a/platforms/spring-boot/components-starter/camel-mail-starter/src/main/java/org/apache/camel/component/mail/springboot/MailComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-mail-starter/src/main/java/org/apache/camel/component/mail/springboot/MailComponentConfiguration.java index 5e975b8..7478acb 100644 --- a/platforms/spring-boot/components-starter/camel-mail-starter/src/main/java/org/apache/camel/component/mail/springboot/MailComponentConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-mail-starter/src/main/java/org/apache/camel/component/mail/springboot/MailComponentConfiguration.java @@ -166,9 +166,9 @@ public class MailComponentConfiguration /** * Specifies the mail session that camel should use for all mail * interactions. Useful in scenarios where mail sessions are created and - * managed by some other resource, such as a JavaEE container. If this - * is not specified, Camel automatically creates the mail session for - * you. + * managed by some other resource, such as a JavaEE container. When + * using a custom mail session, then the hostname and port from the mail + * session will be used (if configured on the session). */ private Session session; /**