Blossom is a Java framework based on Spring-Boot which enables you to realize your projects quickly and smoothly. It comes with several modules and tools made to ease and speed up your development process.
The goals of this new interface avoid doubling the number of methods for each new functionality, like what happened with addresses going from String to InternetAddress ; as well as being easier to work with by only using the methods you need.
How it works:
MailSender is now a simple interface with only one method: create BlossomMailBuilder
BlossomMailBuilder is an interface for mail parameters, including subject, body, sender, recipients, filters, attachments...
BlossomMail is an interface once a mail has been built, to send it off synchronously or asynchronously
BlossomMail's default implementation stores parameters, and passes them back to the MailSender's default implementation
Note on async: since the "send" method is now not part of the MailSender but of an object created from it (and not managed by Spring, so no AOP available there), another service (AsyncMailSender) is used to benefit from Spring's @Async.
The default AsyncMailSender implementation simply calls the synchronous send method benefiting from Spring's Async.
Deprecated by this PR:
All 16 methods from MailSender ; moved to a DeprecatedMailSender interface pending deletion
MailFilter's interface, since it is replaced by filters on the builder directly.
Still undecided:
Since the MailFilter was the only way to access the underlying MimeMessageHelper, it has been abused to implement functionalities not available in the MailSender in projects using Blossom. Should a "catch all" functionality be added in the Builder's interface to account for such needs? Something like:
and have the finalizer be called right before sending the email.
Even without having a generic "finalizer" parameter, should all functionalities of the MimeMessageHelper be available in the BlossomMailBuilder? Compared to the previous MailSender functionalities, this PR already added "reply to" ; but it is still missing stuff like setting sent date, finer priority setting, finer body management, inline elements...
String -> InternetAddress methods in BlossomMailBuilder propagate their exceptions as is, not sure if they should be hidden (as RuntimeExceptions) to avoid being bound to these exceptions in the interface in the future
Coverage increased (+2.2%) to 56.251% when pulling 139185ada90ce1068edbc875f6b20245a6d26a83 on RLejolivet:mailsender-interface into 4178c32039e9a68b6a7bfd3bf03506b5fa1705fc on blossom-project:master.
Rework MailSender's interface.
The goals of this new interface avoid doubling the number of methods for each new functionality, like what happened with addresses going from
String
toInternetAddress
; as well as being easier to work with by only using the methods you need.How it works:
Note on async: since the "send" method is now not part of the MailSender but of an object created from it (and not managed by Spring, so no AOP available there), another service (AsyncMailSender) is used to benefit from Spring's
@Async
.The default AsyncMailSender implementation simply calls the synchronous
send
method benefiting from Spring's Async.Deprecated by this PR:
DeprecatedMailSender
interface pending deletionStill undecided:
and have the finalizer be called right before sending the email.