Skip to content

Commit

Permalink
Merge pull request #4 from dynamiatools/3.x
Browse files Browse the repository at this point in the history
crud listener
  • Loading branch information
marioserrano09 authored Sep 6, 2024
2 parents 1cf9521 + f949e51 commit 6d340f3
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package tools.dynamia.modules.email.listeners;

import tools.dynamia.domain.util.CrudServiceListenerAdapter;
import tools.dynamia.integration.sterotypes.Listener;
import tools.dynamia.modules.email.domain.EmailAccount;
import tools.dynamia.modules.email.services.EmailService;

@Listener
public class EmailAccountCrudListener extends CrudServiceListenerAdapter<EmailAccount> {

private final EmailService emailService;

public EmailAccountCrudListener(EmailService emailService) {
this.emailService = emailService;
}

@Override
public void afterUpdate(EmailAccount entity) {
if (entity != null) {
emailService.clearCache(entity);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
* @author Mario Serrano Leones
*/
@Service
public class EmailServiceImpl extends CrudServiceListenerAdapter<EmailAccount> implements EmailService {
public class EmailServiceImpl implements EmailService {

private final SimpleCache<Long, MailSender> MAIL_SENDERS = new SimpleCache<>();

Expand All @@ -95,10 +95,8 @@ public Future<EmailSendResult> send(String to, String subject, String content) {
public Future<EmailSendResult> send(final EmailMessage mailMessage) {
try {


loadEmailAccount(mailMessage);
return SchedulerUtil.runWithResult(new TaskWithResult<>() {

@Override
public EmailSendResult doWorkWithResult() {
return sendAndWait(mailMessage);
Expand Down Expand Up @@ -509,12 +507,7 @@ private void fireOnMailSendFail(EmailMessage message, Throwable cause) {
}
}

@Override
public void afterUpdate(EmailAccount entity) {
if (entity != null) {
clearCache(entity);
}
}


@Override
public void logEmailAddress(EmailAccount emailAccount, EmailMessage message) {
Expand Down

0 comments on commit 6d340f3

Please sign in to comment.