Class SmtpMailNotificationHandler
java.lang.Object
es.kukenan.smartfi.microservice.communication.service.provider.impl.smtp.SmtpMailNotificationHandler
- All Implemented Interfaces:
NotificationProviderHandler
@Component
@RefreshScope
public class SmtpMailNotificationHandler
extends Object
implements NotificationProviderHandler
Service class that holds all the mail notification sending bussiness logic.
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) StringSMTP mail sender.(package private) org.springframework.mail.javamail.JavaMailSenderSmtp Rest client. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanaccepts(NotificationChannel channel, NotificationProvider provider) Return true if this handler is able to send the given notification request.private StringloadhtmlFile(Template template) Load HTML template from file.send(NotificationRequest notificationRequest, Template template, NotificationSenderService.MessageContext messageContext) Send a notification.
-
Field Details
-
mailFrom
SMTP mail sender. -
mailSender
@Autowired org.springframework.mail.javamail.JavaMailSender mailSenderSmtp Rest client.
-
-
Constructor Details
-
SmtpMailNotificationHandler
public SmtpMailNotificationHandler()
-
-
Method Details
-
send
public NotificationResponse send(NotificationRequest notificationRequest, Template template, NotificationSenderService.MessageContext messageContext) Description copied from interface:NotificationProviderHandlerSend a notification.- Specified by:
sendin interfaceNotificationProviderHandler- Parameters:
notificationRequest- notification request.template- the template to use to send the notification request.messageContext- the message context of the notification.- Returns:
- the notification entity to store.
-
accepts
Description copied from interface:NotificationProviderHandlerReturn true if this handler is able to send the given notification request.- Specified by:
acceptsin interfaceNotificationProviderHandler- Parameters:
channel- notification channel.provider- the provider to use.- Returns:
- true if this handler is able to send the given notification request.
-
loadhtmlFile
Load HTML template from file.- Parameters:
template- Template object.- Returns:
- HTML string template.
- Throws:
IOException- if getResource from ResourceLoader fails.
-
from
-